def get_brightness(self, entities): original_item_label = entities["BrightnessLabel"]["entity_original_value"] item_label = entities["BrightnessLabel"]["entity_value"] item_name = oh.get_item_name_by_label(original_item_label, "CurrentBrightness") item_state = oh.get_item_state(item_name) text = self._sentence("{} lux".format(item_state)) return Notification(text=text)
def get_humidity(self, entities): original_item_label = entities["HumidityLabel"]["entity_original_value"] item_label = entities["HumidityLabel"]["entity_value"] item_name = oh.get_item_name_by_label(original_item_label, "CurrentHumidity") item_state = oh.get_item_state(item_name) text = self._sentence("{} % ".format(item_state)) return Notification(text=text)
def get_temperature(self, entities): original_item_label = entities["TemperatureLabel"]["entity_original_value"] item_label = entities["TemperatureLabel"]["entity_value"] item_name = oh.get_item_name_by_label(original_item_label, "CurrentTemperature") item_state = oh.get_item_state(item_name) text = self._sentence("{} degrees ".format(item_state)) return Notification(text=text)
def set_device_state(self, entities): original_item_label = entities["SwitchableOnOffLabel"]["entity_original_value"] item_label = entities["SwitchableOnOffLabel"]["entity_value"] original_new_state = entities["OnOffAction"]["entity_original_value"] item_name = oh.get_item_name_by_label(original_item_label, "Switchable") oh.send_command(item_name, self.on_off_mapping[original_new_state]) text = self._sentence("{} turned {}".format(item_label, self.on_off_mapping[original_new_state])) return Notification(text=text)
def set_light_color(self, entities): original_item_label = entities["LightColorLabel"]["entity_original_value"] item_label = entities["LightColorLabel"]["entity_value"] original_new_color = entities["ColorValue"]["entity_original_value"] item_name = oh.get_item_name_by_label(original_item_label, "Lighting") oh.send_command(item_name, self.color_mapping.get(original_new_color)) text = self._sentence("{} light {}".format(item_label, original_new_color)) return Notification(text=text)
def set_shutter_level(self, entities): original_item_label = entities["ShutterLabel"]["entity_original_value"] item_label = entities["ShutterLabel"]["entity_value"] action = entities["PullUpDownAction"]["entity_original_value"] item_name = oh.get_item_name_by_label(original_item_label, "Rollershutter") if "PercentageValue" in entities: new_item_state = entities["PercentageValue"] if "%" in new_item_state: new_item_state = new_item_state.replace("%", "") oh.send_command(item_name, new_item_state) else: new_item_state = "ok" oh.send_command(item_name, self.pull_up_down_mapping[action]) text = self._sentence("{} blinds at {} percent".format(item_label, new_item_state)) return Notification(text=text)
def set_light_level(self, entities): original_item_label = entities["LightDimLabel"]["entity_original_value"] item_label = entities["LightDimLabel"]["entity_value"] action = entities["IncreaseDecreaseAction"]["entity_original_value"] item_name = oh.get_item_name_by_label(original_item_label, "Lighting") item_state_ = oh.get_item_state(item_name) item_state = float(item_state_.split(",")[1]) if "," in item_state_ else float(item_state_) if "PercentageValue" in entities: new_item_state = entities["PercentageValue"] if "%" in new_item_state: new_item_state = new_item_state.replace("%", "") else: new_item_state = item_state + 10 if action == "increase" else item_state - 10 new_item_state = sorted((0, new_item_state, 100))[1] oh.send_command(item_name, new_item_state) text = self._sentence("{} light at {} percent".format(item_label, new_item_state)) return Notification(text=text)