def call_switch(*args, **kwargs):
 out = dict()
 devices = _get_lights()
 for dev_id in ((('id' not in kwargs) and sorted(devices.keys())) or _get_devices(kwargs)):
  if ('on' in kwargs):
   state = ((kwargs['on'] and Const.LAMP_ON) or Const.LAMP_OFF)
  else:
   state = ((devices[str(dev_id)]['state']['on'] and Const.LAMP_OFF) or Const.LAMP_ON)
  out[dev_id] = _set(dev_id, state)
 return out

def call_switch ( * args , ** kwargs ) : out = dict ( ) devices = _get_lights ( ) for dev_id in ( ( ( 'id' not in kwargs ) and sorted ( devices . keys ( ) ) ) or _get_devices ( kwargs ) ) : if ( 'on' in kwargs ) : state = ( ( kwargs [ 'on' ] and Const . LAMP_ON ) or Const . LAMP_OFF ) else : state = ( ( devices [ str ( dev_id ) ] [ 'state' ] [ 'on' ] and Const . LAMP_OFF ) or Const . LAMP_ON ) out [ dev_id ] = _set ( dev_id , state ) return out
switch lamp on/off .