コード例 #1
0
ファイル: __init__.py プロジェクト: eae/pyenest
  def simple_status(self):
    user_id, user = self.status['user'].items()[0]
    account = Account(id=user_id, name=user['name'])

    for link in self.status['link'].values():
      structure_key = link['structure']
      structure_id = clean_id(structure_key)
      struct = self.status['structure'][structure_id]
      structure = Structure(id=structure_id, name=struct['name'], location=struct['location'],
                            away=struct['away'], num_thermostats=struct['num_thermostats'])
      account.structures[structure_id] = structure

      for device_key in struct['devices']:
        device_id = clean_id(device_key)
        dev = self.status['device'][device_id]
        shared = self.status['shared'][device_id]
        mode = dev['current_schedule_mode']
        if mode == 'HEAT':
          target_temperature_low, target_temperature_high = shared['target_temperature'], None
        elif mode == 'COOL':
          target_temperature_high, target_temperature_low = shared['target_temperature'], None
        else:
          target_temperature_high = shared['target_temperature_high']
          target_temperature_low = shared['target_temperature_low']
        device = Device(id=device_id, name=shared['name'], system_mode=dev['current_schedule_mode'],
                        scale=dev['temperature_scale'], temperature=shared['current_temperature'],
                        target_temperature_low=target_temperature_low, target_temperature_high=target_temperature_high,
                        heater_on=shared['hvac_heater_state'], ac_on=shared['hvac_ac_state'],
                        fan_mode=dev['fan_mode'], fan_on=shared['hvac_fan_state'])

        structure.devices[device_id] = device
    return account
コード例 #2
0
ファイル: __init__.py プロジェクト: apatt/pyenest
    def simple_status(self):
        user_id, user = self.status["user"].items()[0]
        account = Account(
            id=user_id,
            name=user["name"],
            device_keys=self.status["device"].keys(),
            structure_keys=self.status["structure"].keys(),
            shared_keys=self.status["shared"].keys(),
        )

        for link in self.status["link"].values():
            structure_key = link["structure"]
            structure_id = clean_id(structure_key)
            struct = self.status["structure"][structure_id]
            structure = Structure(
                id=structure_id,
                name=struct["name"],
                location=struct["location"],
                away=struct["away"],
                num_thermostats=struct["num_thermostats"],
            )
            account.structures.append(structure)

            for device_key in struct["devices"]:
                device_id = clean_id(device_key)
                dev = self.status["device"][device_id]
                shared = self.status["shared"][device_id]
                device = Device(
                    id=device_id,
                    name=shared["name"],
                    system_mode=dev["current_schedule_mode"],
                    scale=dev["temperature_scale"],
                    temperature=shared["current_temperature"],
                    target=shared["target_temperature"],
                    heater_on=shared["hvac_heater_state"],
                    ac_on=shared["hvac_ac_state"],
                    fan_mode=dev["fan_mode"],
                    fan_on=shared["hvac_fan_state"],
                )

                structure.devices.append(device)
        return account