mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2025-12-19 22:24:15 +01:00
add fan detail page
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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
|
||||
|
||||
BIN
HMI/nspanel.HMI
BIN
HMI/nspanel.HMI
Binary file not shown.
BIN
HMI/nspanel.tft
BIN
HMI/nspanel.tft
Binary file not shown.
@@ -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)
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user