diff --git a/hass/script/cars/leaf.yaml b/hass/script/cars/leaf.yaml new file mode 100644 index 00000000..6f1984e5 --- /dev/null +++ b/hass/script/cars/leaf.yaml @@ -0,0 +1,50 @@ +--- +update_leaf: + description: >- + Fetch the leaf's current state. + Calling it directly with "service: script.update_leaf" + will ensure the calling script will wait for the update. + mode: queued + sequence: + - repeat: + while: + - > + {{ as_timestamp(now()) - + as_timestamp(states('sensor.leaf_last_update'), 0) + > 600 }} + - "{{ repeat.index <= 6 }}" + sequence: + - service: joaoapps_join.android_server_send_tasker + data: + command: "LeafRefresh" + - wait_for_trigger: + - platform: state + entity_id: sensor.Leaf_last_tentative + timeout: "00:03:00" + - delay: "00:00:02" + - choose: + - conditions: > + {{ as_timestamp(now()) - + as_timestamp(states('sensor.Leaf_last_tentative'), 0) + >= 240 }} + sequence: + - service: input_text.set_value + data_template: + entity_id: input_text.leaf_update_message + value: > + Impossible d'effectuer une tentative de mise à jour. + - conditions: > + {{ as_timestamp(now()) - + as_timestamp(states('sensor.leaf_last_update'), 0) + > 600 }} + sequence: + - service: input_text.set_value + data_template: + entity_id: input_text.leaf_update_message + value: > + Les dernières valeurs obtenues sont trop vieilles. + default: + - service: input_text.set_value + data_template: + entity_id: input_text.leaf_update_message + value: "Succès." diff --git a/hass/switch/template.yaml b/hass/switch/template.yaml new file mode 100644 index 00000000..0bc8a3e0 --- /dev/null +++ b/hass/switch/template.yaml @@ -0,0 +1,11 @@ +--- +- platform: template + switches: + update_leaf: + value_template: "{{ is_state('script.update_leaf', 'on') }}" + turn_on: + service: script.turn_on + entity_id: script.update_leaf + turn_off: + service: script.turn_off + entity_id: script.update_leaf diff --git a/hass/www/images/leaf.jpeg b/hass/www/images/leaf.jpeg new file mode 100644 index 00000000..2d02aa1a Binary files /dev/null and b/hass/www/images/leaf.jpeg differ