def apply_received_command(event):
 device_id = slugify(event.device.id_string.lower())
 if (device_id not in RFX_DEVICES):
  return
 _LOGGER.debug('Device_id: %s device_update. Command: %s', device_id, event.values['Command'])
 if ((event.values['Command'] == 'On') or (event.values['Command'] == 'Off')):
  is_on = (event.values['Command'] == 'On')
  RFX_DEVICES[device_id].update_state(is_on)
 elif (hasattr(RFX_DEVICES[device_id], 'brightness') and (event.values['Command'] == 'Set level')):
  _brightness = ((event.values['Dim level'] * 255) // 100)
  is_on = (_brightness > 0)
  RFX_DEVICES[device_id].update_state(is_on, _brightness)
 if RFX_DEVICES[device_id].should_fire_event:
  RFX_DEVICES[device_id].hass.bus.fire(EVENT_BUTTON_PRESSED, {ATTR_ENTITY_ID: RFX_DEVICES[device_id].entity_id, ATTR_STATE: event.values['Command'].lower()})
  _LOGGER.info('Rfxtrx fired event: (event_type: %s, %s: %s, %s: %s)', EVENT_BUTTON_PRESSED, ATTR_ENTITY_ID, RFX_DEVICES[device_id].entity_id, ATTR_STATE, event.values['Command'].lower())

def apply_received_command ( event ) : device_id = slugify ( event . device . id_string . lower ( ) ) if ( device_id not in RFX_DEVICES ) : return _LOGGER . debug ( 'Device_id: %s device_update. Command: %s' , device_id , event . values [ 'Command' ] ) if ( ( event . values [ 'Command' ] == 'On' ) or ( event . values [ 'Command' ] == 'Off' ) ) : is_on = ( event . values [ 'Command' ] == 'On' ) RFX_DEVICES [ device_id ] . update_state ( is_on ) elif ( hasattr ( RFX_DEVICES [ device_id ] , 'brightness' ) and ( event . values [ 'Command' ] == 'Set level' ) ) : _brightness = ( ( event . values [ 'Dim level' ] * 255 ) // 100 ) is_on = ( _brightness > 0 ) RFX_DEVICES [ device_id ] . update_state ( is_on , _brightness ) if RFX_DEVICES [ device_id ] . should_fire_event : RFX_DEVICES [ device_id ] . hass . bus . fire ( EVENT_BUTTON_PRESSED , { ATTR_ENTITY_ID : RFX_DEVICES [ device_id ] . entity_id , ATTR_STATE : event . values [ 'Command' ] . lower ( ) } ) _LOGGER . info ( 'Rfxtrx fired event: (event_type: %s, %s: %s, %s: %s)' , EVENT_BUTTON_PRESSED , ATTR_ENTITY_ID , RFX_DEVICES [ device_id ] . entity_id , ATTR_STATE , event . values [ 'Command' ] . lower ( ) )
apply command from rfxtrx .