mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2026-02-18 19:06:58 +01:00
inital support for binary_sensors closes #52
This commit is contained in:
@@ -488,13 +488,10 @@ class LovelaceUIPanel:
|
|||||||
icon_id = get_icon_id('flash') if icon is None else get_icon_id(icon)
|
icon_id = get_icon_id('flash') if icon is None else get_icon_id(icon)
|
||||||
icon_color = self.getEntityColor(entity)
|
icon_color = self.getEntityColor(entity)
|
||||||
if item_type == "input_boolean":
|
if item_type == "input_boolean":
|
||||||
if switch_val == 1:
|
icon_id = get_icon_id("check-circle-outline") if switch_val == 1 else get_icon_id("close-circle-outline")
|
||||||
icon_id = get_icon_id("check-circle-outline")
|
|
||||||
else:
|
|
||||||
icon_id = get_icon_id("close-circle-outline")
|
|
||||||
return f",switch,{item},{icon_id},{icon_color},{name},{switch_val}"
|
return f",switch,{item},{icon_id},{icon_color},{name},{switch_val}"
|
||||||
|
|
||||||
if item_type == "sensor":
|
if item_type in ["sensor", "binary_sensor"]:
|
||||||
# maps ha device classes to material design icons
|
# maps ha device classes to material design icons
|
||||||
icon_mapping = {
|
icon_mapping = {
|
||||||
"temperature": "thermometer",
|
"temperature": "thermometer",
|
||||||
@@ -508,13 +505,12 @@ class LovelaceUIPanel:
|
|||||||
icon_id = get_icon_id('alert-circle-outline')
|
icon_id = get_icon_id('alert-circle-outline')
|
||||||
else:
|
else:
|
||||||
icon_id = get_icon_id('alert-circle-outline')
|
icon_id = get_icon_id('alert-circle-outline')
|
||||||
unit_of_measurement = ""
|
|
||||||
if "unit_of_measurement" in entity.attributes:
|
unit_of_measurement = self.get_safe_ha_attribute(entity.attributes, "unit_of_measurement", "")
|
||||||
unit_of_measurement = entity.attributes.unit_of_measurement
|
|
||||||
value = entity.state + " " + unit_of_measurement
|
value = entity.state + " " + unit_of_measurement
|
||||||
return f",text,{item},{icon_id},17299,{name},{value}"
|
return f",text,{item},{icon_id},17299,{name},{value}"
|
||||||
|
|
||||||
if item_type == "button" or item_type == "input_button":
|
if item_type in ["button", "input_button"]:
|
||||||
icon_id = get_icon_id('gesture-tap-button') if icon is None else get_icon_id(icon)
|
icon_id = get_icon_id('gesture-tap-button') if icon is None else get_icon_id(icon)
|
||||||
return f",button,{item},{icon_id},17299,{name},PRESS"
|
return f",button,{item},{icon_id},17299,{name},PRESS"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user