Compare commits

..

3 Commits

Author SHA1 Message Date
Paweł Zubrycki
acdba468b3 Add weather service call functionality and fix weather forecast assignment (#1349) 2025-06-12 18:40:55 +02:00
patricknitsch
54c8d302a8 Add Entity Type "Valve" (#1347)
* Update pages.py

* Update controller.py

* Update pages.py

* Update pages.py
2025-06-06 19:24:56 +02:00
mikosoft83
8059905579 Update icons.py (#1343)
Climate icons improvement
2025-06-02 23:15:30 +02:00
3 changed files with 65 additions and 45 deletions

View File

@@ -334,6 +334,11 @@ class LuiController(object):
apis.ha_api.get_entity(entity_id).call_service("return_to_base")
elif entity_id.startswith('service'):
apis.ha_api.call_service(entity_id.replace('service.', '', 1).replace('.','/', 1), **entity_config.data)
elif entity_id.startswith('valve'):
if apis.ha_api.get_entity(entity_id).state == "open":
apis.ha_api.get_entity(entity_id).call_service("close_valve")
else:
apis.ha_api.get_entity(entity_id).call_service("open_valve")
# for media page
if button_type == "media-next":

View File

@@ -159,8 +159,8 @@ alarm_control_panel_mapping = {
}
climate_mapping = {
'auto': 'calendar-sync',
'heat_cool': 'calendar-sync',
'auto': 'fan-auto',
'heat_cool': 'sun-snowflake-variant',
'heat': 'fire',
'off': 'power',
'cool': 'snowflake',

View File

@@ -382,8 +382,14 @@ class LuiPagesGen(object):
elif entityType == "weather":
entityTypePanel = "text"
unit = get_attr_safe(entity, "temperature_unit", "")
if type(item.stype) == int and len(entity.attributes['forecast']) >= item.stype:
fdate = dp.parse(entity.attributes['forecast'][item.stype]['datetime'])
if type(item.stype) == int:
results = apis.ha_api.call_service(
"weather/get_forecasts", target={"entity_id": entityId}, service_data={"type": "daily"}
)
forecast = results.get("result", {}).get("response", {}).get(entityId, {}).get('forecast') or entity.attributes.get('forecast', [])
if len(forecast) >= item.stype:
day_forecast = forecast[item.stype]
fdate = dp.parse(day_forecast['datetime'])
global babel_spec
if babel_spec is not None:
dateformat = "E" if item.nameOverride is None else item.nameOverride
@@ -391,11 +397,20 @@ class LuiPagesGen(object):
else:
dateformat = "%a" if item.nameOverride is None else item.nameOverride
name = fdate.astimezone().strftime(dateformat)
icon_id = get_icon_ha(entityId, stateOverwrite=entity.attributes['forecast'][item.stype]['condition'])
value = f'{entity.attributes['forecast'][item.stype].get("temperature", "")}{unit}'
color = self.get_entity_color(entity, ha_type=entityType, stateOverwrite=entity.attributes['forecast'][item.stype]['condition'], overwrite=colorOverride)
icon_id = get_icon_ha(entityId, stateOverwrite=day_forecast['condition'])
value = f'{day_forecast.get("temperature", "")}{unit}'
color = self.get_entity_color(entity, ha_type=entityType, stateOverwrite=day_forecast['condition'], overwrite=colorOverride)
else:
value = f'{get_attr_safe(entity, "temperature", "")}{unit}'
else:
value = f'{get_attr_safe(entity, "temperature", "")}{unit}'
elif entityType == "valve":
entityTypePanel = "valve"
value = get_translation(self._locale, f"backend.component.binary_sensor.state.door.{entity.state}")
if entity.state == "open":
icon_id = get_icon_id("valve-open")
else:
icon_id = get_icon_id("valve-closed")
else:
name = "unsupported"
# Overwrite for value