(hass: HomeAssistant, data: RequestData, message: dict[str, Any])
return {'devices': devices}
Handle /user/devices/action request.

    https://yandex.ru/dev/dialogs/alice/doc/smart-home/reference/post-action-docpage/
Handle /user/devices/action request.
Handle / user / devices / action request .
async def async_devices_execute(hass: HomeAssistant, data: RequestData, message: dict[str, Any]) -> dict[str, Any]:
    """Handle /user/devices/action request.

    https://yandex.ru/dev/dialogs/alice/doc/smart-home/reference/post-action-docpage/
    """
    devices = []

    for device in message['payload']['devices']:
        entity_id = device['id']
        state = hass.states.get(entity_id)

        if state is None or state.state == STATE_UNAVAILABLE:
            devices.append({
                'id': entity_id,
                'error_code': ERR_DEVICE_UNREACHABLE,
            })
            continue

        entity = YandexEntity(hass, data.config, state)

        capabilities_result = []
        for capability in device['capabilities']:
            capability_type = capability['type']
            instance = capability['state']['instance']

            try:
                await entity.execute(data, capability_type, instance, capability['state'])
            except SmartHomeError as e:
                _LOGGER.error(f'{e.code}: {e.message}')

                capabilities_result.append({
                    'type': capability_type,
                    'state': {
                        'instance': instance,
                        'action_result': {
                            'status': 'ERROR',
                            'error_code': e.code
                        }
                    }
                })
                continue

            capabilities_result.append({
                'type': capability_type,
                'state': {
                    'instance': instance,
                    'action_result': {
                        'status': 'DONE',
                    }
                }
            })

        devices.append({
            'id': entity_id,
            'capabilities': capabilities_result
        })

    return {'devices': devices}
async def async_devices_execute ( hass : HomeAssistant , data : RequestData , message : dict [ str , Any ] ) -> dict [ str , Any ] : devices = [ ] for device in message [ 'payload' ] [ 'devices' ] : entity_id = device [ 'id' ] state = hass . states . get ( entity_id ) if state is None or state . state == STATE_UNAVAILABLE : devices . append ( { 'id' : entity_id , 'error_code' : ERR_DEVICE_UNREACHABLE , } ) continue entity = YandexEntity ( hass , data . config , state ) capabilities_result = [ ] for capability in device [ 'capabilities' ] : capability_type = capability [ 'type' ] instance = capability [ 'state' ] [ 'instance' ] try : await entity . execute ( data , capability_type , instance , capability [ 'state' ] ) except SmartHomeError as e : _LOGGER . error ( f'{e.code}: {e.message}' ) capabilities_result . append ( { 'type' : capability_type , 'state' : { 'instance' : instance , 'action_result' : { 'status' : 'ERROR' , 'error_code' : e . code } } } ) continue capabilities_result . append ( { 'type' : capability_type , 'state' : { 'instance' : instance , 'action_result' : { 'status' : 'DONE' , } } } ) devices . append ( { 'id' : entity_id , 'capabilities' : capabilities_result } ) return { 'devices' : devices }