Ejemplo n.º 1
0
 def deserialize(api_data):  # type: (Dict) -> OutputDTO
     output_dto = OutputDTO(api_data['id'])
     SerializerToolbox.deserialize(
         dto=output_dto,  # Referenced
         api_data=api_data,
         mapping={
             'module_type': ('module_type', None),
             'name': ('name', None),
             'type': ('output_type', None),
             'lock_bit_id': ('lock_bit_id', OutputSerializer.BYTE_MAX),
             'timer': ('timer', OutputSerializer.WORD_MAX),
             'floor': ('floor', OutputSerializer.BYTE_MAX),
             'room': ('room', OutputSerializer.BYTE_MAX)
         })
     for i in range(4):
         base_field = 'can_led_{0}'.format(i + 1)
         id_field = '{0}_id'.format(base_field)
         function_field = '{0}_function'.format(base_field)
         if id_field in api_data and function_field in api_data:
             setattr(
                 output_dto, base_field,
                 FeedbackLedDTO(id=Toolbox.nonify(
                     api_data[id_field], OutputSerializer.BYTE_MAX),
                                function=api_data[function_field]))
     return output_dto
Ejemplo n.º 2
0
 def deserialize(api_data):  # type: (Dict) -> ThermostatGroupDTO
     thermostat_group_dto = ThermostatGroupDTO(id=0)
     SerializerToolbox.deserialize(
         dto=thermostat_group_dto,  # Referenced
         api_data=api_data,
         mapping={
             'outside_sensor':
             ('outside_sensor_id', ThermostatGroupSerializer.BYTE_MAX),
             'threshold_temp':
             ('threshold_temperature', ThermostatGroupSerializer.BYTE_MAX),
             'pump_delay':
             ('pump_delay', ThermostatGroupSerializer.BYTE_MAX)
         })
     for mode in ['heating', 'cooling']:
         for i in range(4):
             output_field = 'switch_to_{0}_output_{1}'.format(mode, i)
             value_field = 'switch_to_{0}_value_{1}'.format(mode, i)
             dto_field = 'switch_to_{0}_{1}'.format(mode, i)
             if output_field in api_data and value_field in api_data:
                 output = Toolbox.nonify(api_data[output_field],
                                         ThermostatGroupSerializer.BYTE_MAX)
                 value = api_data[value_field]
                 if output is None:
                     setattr(thermostat_group_dto, dto_field, None)
                 else:
                     setattr(thermostat_group_dto, dto_field,
                             [output, value])
     return thermostat_group_dto
Ejemplo n.º 3
0
 def deserialize(api_data):  # type: (Dict) -> GroupActionDTO
     group_action_dto = GroupActionDTO(api_data['id'])
     SerializerToolbox.deserialize(
         dto=group_action_dto,  # Referenced
         api_data=api_data,
         mapping={
             'name': ('name', None),
             'actions': ('actions', lambda s: []
                         if s == '' else [int(a) for a in s.split(',')])
         })
     return group_action_dto
Ejemplo n.º 4
0
 def deserialize(api_data):  # type: (Dict) -> ShutterGroupDTO
     shutter_group_dto = ShutterGroupDTO(api_data['id'])
     SerializerToolbox.deserialize(
         dto=shutter_group_dto,  # Referenced
         api_data=api_data,
         mapping={
             'timer_up': ('timer_up', ShutterGroupSerializer.BYTE_MAX),
             'timer_down': ('timer_down', ShutterGroupSerializer.BYTE_MAX),
             'room': ('room', ShutterGroupSerializer.BYTE_MAX)
         })
     return shutter_group_dto
Ejemplo n.º 5
0
 def deserialize(api_data):  # type: (Dict) -> PulseCounterDTO
     pulse_counter_dto = PulseCounterDTO(api_data['id'])
     SerializerToolbox.deserialize(
         dto=pulse_counter_dto,  # Referenced
         api_data=api_data,
         mapping={
             'name': ('name', None),
             'persistent': ('persistent', None),
             'input': ('input_id', PulseCounterSerializer.BYTE_MAX),
             'room': ('room', PulseCounterSerializer.BYTE_MAX)
         })
     return pulse_counter_dto
Ejemplo n.º 6
0
 def deserialize(api_data):  # type: (Dict) -> SensorDTO
     sensor_dto = SensorDTO(api_data['id'])
     SerializerToolbox.deserialize(
         dto=sensor_dto,  # Referenced
         api_data=api_data,
         mapping={
             'name': ('name', None),
             'offset': ('offset', 0),
             'room': ('room', SensorSerializer.BYTE_MAX),
             'virtual': ('virtual', None)
         })
     return sensor_dto
Ejemplo n.º 7
0
 def deserialize(api_data):
     # type: (Dict) -> OutputStateDTO
     output_state_dto = OutputStateDTO(api_data['id'])
     SerializerToolbox.deserialize(
         dto=output_state_dto,  # Referenced
         api_data=api_data,
         mapping={
             'status': ('status', bool),
             'ctimer': ('ctimer', lambda x: x or 0),
             'dimmer': ('dimmer', lambda x: x or 0),
             'locked': ('locked', lambda x: x or False)
         })
     return output_state_dto
Ejemplo n.º 8
0
 def deserialize(api_data):  # type: (Dict) -> PumpGroupDTO
     pump_group_dto = PumpGroupDTO(id=0)
     SerializerToolbox.deserialize(
         dto=pump_group_dto,  # Referenced
         api_data=api_data,
         mapping={
             'output': ('pump_output_id', PumpGroupSerializer.BYTE_MAX),
             'rooom': ('room_id', PumpGroupSerializer.BYTE_MAX)
         })
     if 'outputs' in api_data:
         pump_group_dto.valve_output_ids = [
             int(output_id) for output_id in api_data['outputs'].split(',')
         ]
     return pump_group_dto
Ejemplo n.º 9
0
 def deserialize(api_data):  # type: (Dict) -> RTD10DTO
     shutter_dto = RTD10DTO(api_data['id'])
     SerializerToolbox.deserialize(
         dto=shutter_dto,  # Referenced
         api_data=api_data,
         mapping={
             field: (field, RTD10Serializer.BYTE_MAX)
             for field in [
                 'temp_setpoint_output', 'ventilation_speed_output',
                 'ventilation_speed_value', 'mode_output', 'mode_value',
                 'on_off_output', 'poke_angle_output', 'poke_angle_value',
                 'room'
             ]
         })
     return shutter_dto
Ejemplo n.º 10
0
 def deserialize(api_data):  # type: (Dict) -> ShutterDTO
     shutter_dto = ShutterDTO(api_data['id'])
     SerializerToolbox.deserialize(
         dto=shutter_dto,  # Referenced
         api_data=api_data,
         mapping={
             'name': ('name', None),
             'timer_up': ('timer_up', ShutterSerializer.BYTE_MAX),
             'timer_down': ('timer_down', ShutterSerializer.BYTE_MAX),
             'up_down_config':
             ('up_down_config', ShutterSerializer.BYTE_MAX),
             'group_1': ('group_1', ShutterSerializer.BYTE_MAX),
             'group_2': ('group_2', ShutterSerializer.BYTE_MAX),
             'room': ('room', ShutterSerializer.BYTE_MAX),
             'steps': ('steps', ShutterSerializer.WORD_MAX)
         })
     return shutter_dto
Ejemplo n.º 11
0
 def deserialize(api_data):  # type: (Dict) -> InputDTO
     input_dto = InputDTO(api_data['id'])
     SerializerToolbox.deserialize(
         dto=input_dto,  # Referenced
         api_data=api_data,
         mapping={
             'module_type': ('module_type', None),
             'name': ('name', None),
             'action': ('action', InputSerializer.BYTE_MAX),
             'basic_actions':
             ('basic_actions', lambda s: []
              if s == '' else [int(a) for a in s.split(',')]),
             'invert': ('invert', lambda i: i != 255),
             'can': ('can', lambda s: s == 'C'),
             'event_enabled': ('event_enabled', None),
             'room': ('room', InputSerializer.BYTE_MAX)
         })
     return input_dto
Ejemplo n.º 12
0
 def deserialize(api_data):  # type: (Dict) -> Tuple[ShutterGroupDTO, List[str]]
     loaded_fields = ['id']
     shutter_group_dto = ShutterGroupDTO(api_data['id'])
     loaded_fields += SerializerToolbox.deserialize(
         dto=shutter_group_dto,  # Referenced
         api_data=api_data,
         mapping={'timer_up': ('timer_up', ShutterGroupSerializer.BYTE_MAX),
                  'timer_down': ('timer_down', ShutterGroupSerializer.BYTE_MAX),
                  'room': ('room', ShutterGroupSerializer.BYTE_MAX)}
     )
     return shutter_group_dto, loaded_fields
Ejemplo n.º 13
0
 def deserialize(api_data):  # type: (Dict) -> Tuple[SensorDTO, List[str]]
     loaded_fields = ['id']
     sensor_dto = SensorDTO(api_data['id'])
     loaded_fields += SerializerToolbox.deserialize(
         dto=sensor_dto,  # Referenced
         api_data=api_data,
         mapping={
             'name': ('name', None),
             'offset': ('offset', 0),
             'room': ('room', SensorSerializer.BYTE_MAX),
             'virtual': ('virtual', None)
         })
     return sensor_dto, loaded_fields
Ejemplo n.º 14
0
 def deserialize(
         api_data):  # type: (Dict) -> Tuple[GroupActionDTO, List[str]]
     loaded_fields = ['id']
     group_action_dto = GroupActionDTO(api_data['id'])
     loaded_fields += SerializerToolbox.deserialize(
         dto=group_action_dto,  # Referenced
         api_data=api_data,
         mapping={
             'name': ('name', None),
             'actions': ('actions', lambda s: []
                         if s == '' else [int(a) for a in s.split(',')])
         })
     return group_action_dto, loaded_fields
Ejemplo n.º 15
0
 def deserialize(api_data):
     # type: (Dict) -> Tuple[OutputStateDTO, List[str]]
     loaded_fields = ['id']
     output_state_dto = OutputStateDTO(api_data['id'])
     loaded_fields += SerializerToolbox.deserialize(
         dto=output_state_dto,  # Referenced
         api_data=api_data,
         mapping={
             'status': ('status', bool),
             'ctimer': ('ctimer', lambda x: x or 0),
             'dimmer': ('dimmer', lambda x: x or 0),
             'locked': ('locked', lambda x: x or False)
         })
     return output_state_dto, loaded_fields
Ejemplo n.º 16
0
 def deserialize(
         api_data):  # type: (Dict) -> Tuple[PulseCounterDTO, List[str]]
     loaded_fields = ['id']
     pulse_counter_dto = PulseCounterDTO(api_data['id'])
     loaded_fields += SerializerToolbox.deserialize(
         dto=pulse_counter_dto,  # Referenced
         api_data=api_data,
         mapping={
             'name': ('name', None),
             'persistent': ('persistent', None),
             'input': ('input_id', PulseCounterSerializer.BYTE_MAX),
             'room': ('room', PulseCounterSerializer.BYTE_MAX)
         })
     return pulse_counter_dto, loaded_fields
Ejemplo n.º 17
0
 def deserialize(api_data):  # type: (Dict) -> ThermostatDTO
     thermostat_dto = ThermostatDTO(api_data['id'])
     SerializerToolbox.deserialize(
         dto=thermostat_dto,  # Referenced
         api_data=api_data,
         mapping={
             'name': ('name', None),
             'permanent_manual': ('permanent_manual', None),
             'setp0': ('setp0', None),
             'setp1': ('setp1', None),
             'setp2': ('setp2', None),
             'setp3': ('setp3', None),
             'setp4': ('setp4', None),
             'setp5': ('setp5', None),
             'room': ('room', ThermostatSerializer.BYTE_MAX),
             'sensor': ('sensor', ThermostatSerializer.BYTE_MAX),
             'output0': ('output0', ThermostatSerializer.BYTE_MAX),
             'output1': ('output1', ThermostatSerializer.BYTE_MAX),
             'pid_p': ('pid_p', ThermostatSerializer.BYTE_MAX),
             'pid_i': ('pid_i', ThermostatSerializer.BYTE_MAX),
             'pid_d': ('pid_d', ThermostatSerializer.BYTE_MAX),
             'pid_int': ('pid_int', ThermostatSerializer.BYTE_MAX)
         })
     for day in ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun']:
         field = 'auto_{0}'.format(day)
         if field not in api_data:
             continue
         field_dto = ThermostatScheduleDTO(temp_night=api_data[field][0],
                                           start_day_1=api_data[field][1],
                                           end_day_1=api_data[field][2],
                                           temp_day_1=api_data[field][3],
                                           start_day_2=api_data[field][4],
                                           end_day_2=api_data[field][5],
                                           temp_day_2=api_data[field][6])
         setattr(thermostat_dto, field, field_dto)
     return thermostat_dto
Ejemplo n.º 18
0
 def deserialize(
         api_data):  # type: (Dict) -> Tuple[PumpGroupDTO, List[str]]
     loaded_fields = []
     pump_group_dto = PumpGroupDTO(id=0)
     loaded_fields += SerializerToolbox.deserialize(
         dto=pump_group_dto,  # Referenced
         api_data=api_data,
         mapping={
             'output': ('pump_output_id', PumpGroupSerializer.BYTE_MAX),
             'rooom': ('room_id', PumpGroupSerializer.BYTE_MAX)
         })
     if 'outputs' in api_data:
         loaded_fields.append('valve_output_ids')
         pump_group_dto.valve_output_ids = [
             int(output_id) for output_id in api_data['outputs'].split(',')
         ]
     return pump_group_dto, loaded_fields