diff --git a/HMI/US/landscape/nspanel_US_L.HMI b/HMI/US/landscape/nspanel_US_L.HMI index bef91bd9..db1970e5 100644 Binary files a/HMI/US/landscape/nspanel_US_L.HMI and b/HMI/US/landscape/nspanel_US_L.HMI differ diff --git a/HMI/US/landscape/nspanel_US_L.tft b/HMI/US/landscape/nspanel_US_L.tft index 030ab375..ef043ed4 100644 Binary files a/HMI/US/landscape/nspanel_US_L.tft and b/HMI/US/landscape/nspanel_US_L.tft differ diff --git a/HMI/US/portrait/nspanel_US_P.HMI b/HMI/US/portrait/nspanel_US_P.HMI index 88a6e1c5..40906a45 100644 Binary files a/HMI/US/portrait/nspanel_US_P.HMI and b/HMI/US/portrait/nspanel_US_P.HMI differ diff --git a/HMI/US/portrait/nspanel_US_P.tft b/HMI/US/portrait/nspanel_US_P.tft index d7b501b3..525a8a70 100644 Binary files a/HMI/US/portrait/nspanel_US_P.tft and b/HMI/US/portrait/nspanel_US_P.tft differ diff --git a/HMI/code_gen/pages/cardEntitiesSerial.py b/HMI/code_gen/pages/cardEntitiesSerial.py index d0537d4a..9efc0e0b 100644 --- a/HMI/code_gen/pages/cardEntitiesSerial.py +++ b/HMI/code_gen/pages/cardEntitiesSerial.py @@ -96,21 +96,7 @@ for i in range(1,5): tsw bDown{i},1 }} }} - if(type{i}.txt=="light") - {{ - vis bUp{i},0 - vis bStop{i},0 - vis bDown{i},0 - vis btOnOff{i},1 - vis bText{i},0 - vis hSlider{i},0 - vis nNum{i},0 - // get Button State (optional Value) - spstr strCommand.txt,tTmp.txt,"~",{idxstart+5} - covx tTmp.txt,sys0,0,0 - btOnOff{i}.val=sys0 - }} - if(type{i}.txt=="switch") + if(type{i}.txt=="light"||type{i}.txt=="switch"||type{i}.txt=="fan") {{ vis bUp{i},0 vis bStop{i},0 diff --git a/HMI/nspanel.HMI b/HMI/nspanel.HMI index 9860314e..30e8dd00 100644 Binary files a/HMI/nspanel.HMI and b/HMI/nspanel.HMI differ diff --git a/HMI/nspanel.tft b/HMI/nspanel.tft index 2e87d0dd..9850f391 100644 Binary files a/HMI/nspanel.tft and b/HMI/nspanel.tft differ diff --git a/apps/nspanel-lovelace-ui/luibackend/controller.py b/apps/nspanel-lovelace-ui/luibackend/controller.py index c5b5c316..27927740 100644 --- a/apps/nspanel-lovelace-ui/luibackend/controller.py +++ b/apps/nspanel-lovelace-ui/luibackend/controller.py @@ -168,6 +168,8 @@ class LuiController(object): self._pages_gen.generate_light_detail_page(entity) if entity.startswith("cover"): self._pages_gen.generate_shutter_detail_page(entity) + if entity.startswith("fan"): + self._pages_gen.generate_fan_detail_page(entity) def detail_open(self, detail_type, entity_id): @@ -175,6 +177,8 @@ class LuiController(object): self._pages_gen.generate_shutter_detail_page(entity_id) if detail_type == "popupLight": self._pages_gen.generate_light_detail_page(entity_id) + if detail_type == "popupFan": + self._pages_gen.generate_fan_detail_page(entity_id) def button_press(self, entity_id, button_type, value): self._ha_api.log(f"Button Press Event; entity_id: {entity_id}; button_type: {button_type}; value: {value} ") @@ -235,7 +239,9 @@ class LuiController(object): if button_type == "number-set": if entity_id.startswith('fan'): - self._ha_api.get_entity(entity_id).call_service("set_percentage", percentage=value) + entity = self._ha_api.get_entity(entity_id) + value = float(value)*float(entity.attributes.get("percentage_step", 0)) + entity.call_service("set_percentage", percentage=value) else: self._ha_api.get_entity(entity_id).call_service("set_value", value=value) diff --git a/apps/nspanel-lovelace-ui/luibackend/pages.py b/apps/nspanel-lovelace-ui/luibackend/pages.py index ef682bb5..e62d7b4f 100644 --- a/apps/nspanel-lovelace-ui/luibackend/pages.py +++ b/apps/nspanel-lovelace-ui/luibackend/pages.py @@ -235,11 +235,16 @@ class LuiPagesGen(object): icon_color = self.get_entity_color(entity, overwrite=colorOverride) icon_id = get_icon_id_ha("light", state=entity.state, overwrite=icon) return f"~{entityType}~{entityId}~{icon_id}~{icon_color}~{name}~{switch_val}" - if entityType in ["switch", "input_boolean", "automation", "fan"]: + if entityType in ["switch", "input_boolean", "automation"]: switch_val = 1 if entity.state == "on" else 0 icon_color = self.get_entity_color(entity, overwrite=colorOverride) icon_id = get_icon_id_ha(entityType, state=entity.state, overwrite=icon) return f"~switch~{entityId}~{icon_id}~{icon_color}~{name}~{switch_val}" + if entityType in "fan": + switch_val = 1 if entity.state == "on" else 0 + icon_color = self.get_entity_color(entity, overwrite=colorOverride) + icon_id = get_icon_id_ha(entityType, state=entity.state, overwrite=icon) + return f"~fan~{entityId}~{icon_id}~{icon_color}~{name}~{switch_val}" if entityType in ["sensor", "binary_sensor"]: device_class = entity.attributes.get("device_class", "") unit_of_measurement = entity.attributes.get("unit_of_measurement", "") @@ -615,6 +620,21 @@ class LuiPagesGen(object): self._send_mqtt_msg(f"entityUpdateDetail~{entity_id}~{pos}~{pos_translation}: {pos_status}~{pos_translation}~{icon_id}~{icon_up}~{icon_stop}~{icon_down}~{icon_up_status}~{icon_stop_status}~{icon_down_status}~{textTilt}~{iconTiltLeft}~{iconTiltStop}~{iconTiltRight}~{iconTiltLeftStatus}~{iconTiltStopStatus}~{iconTiltRightStatus}~{tilt_pos}") + def generate_fan_detail_page(self, entity_id): + entity = self._ha_api.get_entity(entity_id) + switch_val = 1 if entity.state == "on" else 0 + icon_color = self.get_entity_color(entity) + speed = entity.attributes.get("percentage") + speedMax = 100 + if(speed == None): + speed = "disable" + else: + speed = round(entity.attributes.get("percentage")/entity.attributes.get("percentage_step")) + speedMax = int(100/entity.attributes.get("percentage_step")) + + speed_translation = get_translation(self._locale, "frontend.ui.card.fan.speed") + self._send_mqtt_msg(f"entityUpdateDetail~{entity_id}~{get_icon_id('lightbulb')}~{icon_color}~{switch_val}~{speed}~{speedMax}~{speed_translation}") + def send_message_page(self, ident, heading, msg, b1, b2): self._send_mqtt_msg(f"pageType~popupNotify") self._send_mqtt_msg(f"entityUpdateDetail~{ident}~{heading}~65535~{b1}~65535~{b2}~65535~{msg}~65535~0")