mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2025-12-21 06:54:24 +01:00
implement some more actions
This commit is contained in:
@@ -65,7 +65,6 @@ def handle_buttons(entity_id, btype, value):
|
|||||||
"value": int(value)
|
"value": int(value)
|
||||||
}
|
}
|
||||||
call_ha_service(entity_id, "set_value", service_data=service_data)
|
call_ha_service(entity_id, "set_value", service_data=service_data)
|
||||||
|
|
||||||
case 'up' | 'stop' | 'down' | 'tiltOpen' | 'tiltStop' | 'tiltClose' | 'media-next' | 'media-back' | 'media-pause' | 'timer-cancel' | 'timer-pause' | 'timer-finish':
|
case 'up' | 'stop' | 'down' | 'tiltOpen' | 'tiltStop' | 'tiltClose' | 'media-next' | 'media-back' | 'media-pause' | 'timer-cancel' | 'timer-pause' | 'timer-finish':
|
||||||
action_service_mapping = {
|
action_service_mapping = {
|
||||||
'up': 'open_cover',
|
'up': 'open_cover',
|
||||||
@@ -171,37 +170,53 @@ def handle_buttons(entity_id, btype, value):
|
|||||||
}
|
}
|
||||||
call_ha_service(entity_id, f"set_{mapping[btype]}", service_data=service_data)
|
call_ha_service(entity_id, f"set_{mapping[btype]}", service_data=service_data)
|
||||||
case 'mode-input_select' | 'mode-select':
|
case 'mode-input_select' | 'mode-select':
|
||||||
if btype in mapping:
|
options = libs.home_assistant.get_entity_data(entity_id).get('attributes', []).get("options", [])
|
||||||
modes = libs.home_assistant.get_entity_data(entity_id).get('attributes', []).get(options, [])
|
|
||||||
if options:
|
if options:
|
||||||
option = options[int(value)]
|
option = options[int(value)]
|
||||||
service_data = {
|
service_data = {
|
||||||
"option": option
|
"option": option
|
||||||
}
|
}
|
||||||
call_ha_service(entity_id, "select_option", service_data=service_data)
|
call_ha_service(entity_id, "select_option", service_data=service_data)
|
||||||
|
case 'mode-media_player':
|
||||||
|
options = libs.home_assistant.get_entity_data(entity_id).get('attributes', []).get("source_list", [])
|
||||||
|
if options:
|
||||||
|
option = options[int(value)]
|
||||||
|
service_data = {
|
||||||
|
"source": option
|
||||||
|
}
|
||||||
|
call_ha_service(entity_id, "select_source", service_data=service_data)
|
||||||
|
case 'mode-light':
|
||||||
|
options = libs.home_assistant.get_entity_data(entity_id).get('attributes', []).get("effect_list", [])
|
||||||
|
if options:
|
||||||
|
option = options[int(value)]
|
||||||
|
service_data = {
|
||||||
|
"effect": option
|
||||||
|
}
|
||||||
|
call_ha_service(entity_id, "turn_on", service_data=service_data)
|
||||||
|
case 'tempUpd':
|
||||||
|
temp = int(value)/10
|
||||||
|
service_data = {
|
||||||
|
"temperature": temp
|
||||||
|
}
|
||||||
|
call_ha_service(entity_id, "set_temperature", service_data=service_data)
|
||||||
|
case 'tempUpdHighLow':
|
||||||
|
value = value.split("|")
|
||||||
|
temp_high = int(value[0])/10
|
||||||
|
temp_low = int(value[1])/10
|
||||||
|
service_data = {
|
||||||
|
"target_temp_high": temp_high,
|
||||||
|
"target_temp_low": temp_low,
|
||||||
|
}
|
||||||
|
call_ha_service(entity_id, "set_temperature", service_data=service_data)
|
||||||
|
case 'hvac_action':
|
||||||
|
service_data = {
|
||||||
|
"hvac_mode": value
|
||||||
|
}
|
||||||
|
call_ha_service(entity_id, "set_hvac_mode", service_data=service_data)
|
||||||
case _:
|
case _:
|
||||||
logging.error("Not implemented: %s", btype)
|
logging.error("Not implemented: %s", btype)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# # for climate page
|
|
||||||
# if button_type == "tempUpd":
|
|
||||||
# temp = int(value)/10
|
|
||||||
# apis.ha_api.get_entity(entity_id).call_service(
|
|
||||||
# "set_temperature", temperature=temp)
|
|
||||||
# if button_type == "tempUpdHighLow":
|
|
||||||
# value = value.split("|")
|
|
||||||
# temp_high = int(value[0])/10
|
|
||||||
# temp_low = int(value[1])/10
|
|
||||||
# apis.ha_api.get_entity(entity_id).call_service(
|
|
||||||
# "set_temperature", target_temp_high=temp_high, target_temp_low=temp_low)
|
|
||||||
# if button_type == "hvac_action":
|
|
||||||
# apis.ha_api.get_entity(entity_id).call_service(
|
|
||||||
# "set_hvac_mode", hvac_mode=value)
|
|
||||||
#
|
|
||||||
# # for cardUnlock
|
# # for cardUnlock
|
||||||
# if button_type == "cardUnlock-unlock":
|
# if button_type == "cardUnlock-unlock":
|
||||||
# curCard = self._config.get_card_by_uuid(
|
# curCard = self._config.get_card_by_uuid(
|
||||||
@@ -215,25 +230,6 @@ def handle_buttons(entity_id, btype, value):
|
|||||||
# self._previous_cards.append(self._current_card)
|
# self._previous_cards.append(self._current_card)
|
||||||
# self._current_card = dstCard
|
# self._current_card = dstCard
|
||||||
# self._pages_gen.render_card(self._current_card)
|
# self._pages_gen.render_card(self._current_card)
|
||||||
#
|
|
||||||
#
|
|
||||||
# if button_type == "mode-light":
|
|
||||||
# if entity_id.startswith('uuid'):
|
|
||||||
# entity_config = self._config._config_entites_table.get(
|
|
||||||
# entity_id)
|
|
||||||
# entity_id = entity_config.entityId
|
|
||||||
# entity = apis.ha_api.get_entity(entity_id)
|
|
||||||
# options_list = entity_config.entity_input_config.get("effectList")
|
|
||||||
# if options_list is not None:
|
|
||||||
# option = options_list[int(value)]
|
|
||||||
# else:
|
|
||||||
# option = entity.attributes.effect_list[int(value)]
|
|
||||||
# entity.call_service("turn_on", effect=option)
|
|
||||||
#
|
|
||||||
# if button_type == "mode-media_player":
|
|
||||||
# entity = apis.ha_api.get_entity(entity_id)
|
|
||||||
# option = entity.attributes.source_list[int(value)]
|
|
||||||
# entity.call_service("select_source", source=option)
|
|
||||||
|
|
||||||
# if button_type == "opnSensorNotify":
|
# if button_type == "opnSensorNotify":
|
||||||
# msg = ""
|
# msg = ""
|
||||||
|
|||||||
Reference in New Issue
Block a user