Skip to content

Commit

Permalink
Helper size reduction (#378)
Browse files Browse the repository at this point in the history
* Add helper reduction to e2001/e2002

* Update all controllers with new helper

* helper size reduction for sonoff_snzb01

* fix blueprint comments

* bump versions to 2022.08.08, update changelogs

Co-authored-by: Matteo Agnoletto <[email protected]>
  • Loading branch information
Azrael-Kun and EPMatt authored Aug 7, 2022
1 parent 015b063 commit 9ee5920
Show file tree
Hide file tree
Showing 32 changed files with 98 additions and 82 deletions.
20 changes: 10 additions & 10 deletions blueprints/controllers/ikea_e1524_e1810/ikea_e1524_e1810.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ blueprint:
🚀 This blueprint is part of the **[Awesome HA Blueprints](https://epmatt.github.io/awesome-ha-blueprints) project**.
ℹ️ Version 2021.10.26
ℹ️ Version 2022.08.08
source_url: https://github.com/EPMatt/awesome-ha-blueprints/blob/main/blueprints/controllers/ikea_e1524_e1810/ikea_e1524_e1810.yaml
domain: automation
input:
Expand Down Expand Up @@ -380,7 +380,7 @@ variables:
button_down_release: '{{ actions_mapping[integration_id]["button_down_release"] }}'
button_center_short: '{{ actions_mapping[integration_id]["button_center_short"] }}'
button_center_long: '{{ actions_mapping[integration_id]["button_center_long"] }}'
# integrations which need to store the previous long press event to determine which button was released
# integrations which need to store the previous press event to determine which button was released
integrations_with_prev_event_storage: [zha]
# build data to send within a controller event
controller_entity: !input controller_entity
Expand Down Expand Up @@ -436,13 +436,13 @@ action:
{%- elif integration_id == "zha" -%}
{{ trigger.event.data.command }}{{"_" if trigger.event.data.args|length > 0}}{{ trigger.event.data.args|join("_") }}
{%- endif -%}
trigger_delta: '{{ (as_timestamp(now()) - as_timestamp((states(helper_last_controller_event) | from_json).last_triggered if helper_last_controller_event is not none and (states(helper_last_controller_event) | regex_match("^\{(\".*\": \".*\"(, )?)*\}$")) else "1970-01-01 00:00:00")) * 1000 }}'
last_controller_event: '{{ (states(helper_last_controller_event) | from_json).trigger_action if helper_last_controller_event is not none and (states(helper_last_controller_event) | regex_match("^\{(\".*\": \".*\"(, )?)*\}$")) else "" }}'
trigger_delta: '{{ (as_timestamp(now()) - ((states(helper_last_controller_event) | from_json).t if helper_last_controller_event is not none and (states(helper_last_controller_event) | regex_match("^\{((\"a\": \".*\"|\"t\": \d+\.\d+)(, )?){2}\}$")) else as_timestamp("1970-01-01 00:00:00"))) * 1000 }}'
last_controller_event: '{{ (states(helper_last_controller_event) | from_json).a if helper_last_controller_event is not none and (states(helper_last_controller_event) | regex_match("^\{((\"a\": \".*\"|\"t\": \d+\.\d+)(, )?){2}\}$")) else "" }}'
# update helper
- service: input_text.set_value
data:
entity_id: !input helper_last_controller_event
value: '{{ {"trigger_action":trigger_action,"last_triggered":now()|string} | to_json }}'
value: '{{ {"a":trigger_action,"t":as_timestamp(now())} | to_json }}'
# choose the sequence to run based on the received button event
- choose:
- conditions: '{{ trigger_action | string in button_left_short }}'
Expand All @@ -459,7 +459,7 @@ action:
- service: input_text.set_value
data:
entity_id: !input helper_last_controller_event
value: '{{ {"trigger_action":"double_press","last_triggered":now() | string} | to_json }}'
value: '{{ {"a":"double_press","t":as_timestamp(now())} | to_json }}'
# run the double press action
# fire the event
- event: ahb_controller_event
Expand Down Expand Up @@ -542,7 +542,7 @@ action:
- service: input_text.set_value
data:
entity_id: !input helper_last_controller_event
value: '{{ {"trigger_action":"double_press","last_triggered":now() | string} | to_json }}'
value: '{{ {"a":"double_press","t":as_timestamp(now())} | to_json }}'
# run the double press action
# fire the event
- event: ahb_controller_event
Expand Down Expand Up @@ -625,7 +625,7 @@ action:
- service: input_text.set_value
data:
entity_id: !input helper_last_controller_event
value: '{{ {"trigger_action":"double_press","last_triggered":now() | string} | to_json }}'
value: '{{ {"a":"double_press","t":as_timestamp(now())} | to_json }}'
# run the double press action
# fire the event
- event: ahb_controller_event
Expand Down Expand Up @@ -708,7 +708,7 @@ action:
- service: input_text.set_value
data:
entity_id: !input helper_last_controller_event
value: '{{ {"trigger_action":"double_press","last_triggered":now() | string} | to_json }}'
value: '{{ {"a":"double_press","t":as_timestamp(now())} | to_json }}'
# run the double press action
# fire the event
- event: ahb_controller_event
Expand Down Expand Up @@ -791,7 +791,7 @@ action:
- service: input_text.set_value
data:
entity_id: !input helper_last_controller_event
value: '{{ {"trigger_action":"double_press","last_triggered":now() | string} | to_json }}'
value: '{{ {"a":"double_press","t":as_timestamp(now())} | to_json }}'
# run the double press action
# fire the event
- event: ahb_controller_event
Expand Down
14 changes: 7 additions & 7 deletions blueprints/controllers/ikea_e1743/ikea_e1743.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ blueprint:
🚀 This blueprint is part of the **[Awesome HA Blueprints](https://epmatt.github.io/awesome-ha-blueprints) project**.
ℹ️ Version 2021.10.26
ℹ️ Version 2022.08.08
source_url: https://github.com/EPMatt/awesome-ha-blueprints/blob/main/blueprints/controllers/ikea_e1743/ikea_e1743.yaml
domain: automation
input:
Expand Down Expand Up @@ -221,7 +221,7 @@ variables:
button_down_short: '{{ actions_mapping[integration_id]["button_down_short"] }}'
button_down_long: '{{ actions_mapping[integration_id]["button_down_long"] }}'
button_down_release: '{{ actions_mapping[integration_id]["button_down_release"] }}'
# integrations which need to store the previous long press event to determine which button was released
# integrations which need to store the previous press event to determine which button was released
integrations_with_prev_event_storage: [zha, zigbee2mqtt]
# build data to send within a controller event
controller_entity: !input controller_entity
Expand Down Expand Up @@ -277,13 +277,13 @@ action:
{%- elif integration_id == "zha" -%}
{{ trigger.event.data.command }}{{"_" if trigger.event.data.args|length > 0}}{{ trigger.event.data.args|join("_") }}
{%- endif -%}
trigger_delta: '{{ (as_timestamp(now()) - as_timestamp((states(helper_last_controller_event) | from_json).last_triggered if helper_last_controller_event is not none and (states(helper_last_controller_event) | regex_match("^\{(\".*\": \".*\"(, )?)*\}$")) else "1970-01-01 00:00:00")) * 1000 }}'
last_controller_event: '{{ (states(helper_last_controller_event) | from_json).trigger_action if helper_last_controller_event is not none and (states(helper_last_controller_event) | regex_match("^\{(\".*\": \".*\"(, )?)*\}$")) else "" }}'
trigger_delta: '{{ (as_timestamp(now()) - ((states(helper_last_controller_event) | from_json).t if helper_last_controller_event is not none and (states(helper_last_controller_event) | regex_match("^\{((\"a\": \".*\"|\"t\": \d+\.\d+)(, )?){2}\}$")) else as_timestamp("1970-01-01 00:00:00"))) * 1000 }}'
last_controller_event: '{{ (states(helper_last_controller_event) | from_json).a if helper_last_controller_event is not none and (states(helper_last_controller_event) | regex_match("^\{((\"a\": \".*\"|\"t\": \d+\.\d+)(, )?){2}\}$")) else "" }}'
# update helper
- service: input_text.set_value
data:
entity_id: !input helper_last_controller_event
value: '{{ {"trigger_action":trigger_action,"last_triggered":now()|string} | to_json }}'
value: '{{ {"a":trigger_action,"t":as_timestamp(now())} | to_json }}'
# choose the sequence to run based on the received button event
- choose:
- conditions: '{{ trigger_action | string in button_up_short }}'
Expand All @@ -300,7 +300,7 @@ action:
- service: input_text.set_value
data:
entity_id: !input helper_last_controller_event
value: '{{ {"trigger_action":"double_press","last_triggered":now() | string} | to_json }}'
value: '{{ {"a":"double_press","t":as_timestamp(now())} | to_json }}'
# run the double press action
# fire the event
- event: ahb_controller_event
Expand Down Expand Up @@ -383,7 +383,7 @@ action:
- service: input_text.set_value
data:
entity_id: !input helper_last_controller_event
value: '{{ {"trigger_action":"double_press","last_triggered":now() | string} | to_json }}'
value: '{{ {"a":"double_press","t":as_timestamp(now())} | to_json }}'
# run the double press action
# fire the event
- event: ahb_controller_event
Expand Down
8 changes: 4 additions & 4 deletions blueprints/controllers/ikea_e1744/ikea_e1744.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ blueprint:
🚀 This blueprint is part of the **[Awesome HA Blueprints](https://epmatt.github.io/awesome-ha-blueprints) project**.
ℹ️ Version 2021.10.26
ℹ️ Version 2022.08.08
source_url: https://github.com/EPMatt/awesome-ha-blueprints/blob/main/blueprints/controllers/ikea_e1744/ikea_e1744.yaml
domain: automation
input:
Expand Down Expand Up @@ -239,13 +239,13 @@ action:
{%- elif integration_id == "zha" -%}
{{ trigger.event.data.command }}{{"_" if trigger.event.data.args|length > 0}}{{ trigger.event.data.args|join("_") }}
{%- endif -%}
trigger_delta: '{{ (as_timestamp(now()) - as_timestamp((states(helper_last_controller_event) | from_json).last_triggered if helper_last_controller_event is not none and (states(helper_last_controller_event) | regex_match("^\{(\".*\": \".*\"(, )?)*\}$")) else "1970-01-01 00:00:00")) * 1000 }}'
last_controller_event: '{{ (states(helper_last_controller_event) | from_json).trigger_action if helper_last_controller_event is not none and (states(helper_last_controller_event) | regex_match("^\{(\".*\": \".*\"(, )?)*\}$")) else "" }}'
trigger_delta: '{{ (as_timestamp(now()) - ((states(helper_last_controller_event) | from_json).t if helper_last_controller_event is not none and (states(helper_last_controller_event) | regex_match("^\{((\"a\": \".*\"|\"t\": \d+\.\d+)(, )?){2}\}$")) else as_timestamp("1970-01-01 00:00:00"))) * 1000 }}'
last_controller_event: '{{ (states(helper_last_controller_event) | from_json).a if helper_last_controller_event is not none and (states(helper_last_controller_event) | regex_match("^\{((\"a\": \".*\"|\"t\": \d+\.\d+)(, )?){2}\}$")) else "" }}'
# update helper
- service: input_text.set_value
data:
entity_id: !input helper_last_controller_event
value: '{{ {"trigger_action":trigger_action,"last_triggered":now()|string} | to_json }}'
value: '{{ {"a":trigger_action,"t":as_timestamp(now())} | to_json }}'
# choose the sequence to run based on the received button event
- choose:
- conditions: '{{ trigger_action | string in rotate_left }}'
Expand Down
12 changes: 6 additions & 6 deletions blueprints/controllers/ikea_e1766/ikea_e1766.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ blueprint:
🚀 This blueprint is part of the **[Awesome HA Blueprints](https://epmatt.github.io/awesome-ha-blueprints) project**.
ℹ️ Version 2021.10.29
ℹ️ Version 2022.08.08
source_url: https://github.com/EPMatt/awesome-ha-blueprints/blob/main/blueprints/controllers/ikea_e1766/ikea_e1766.yaml
domain: automation
input:
Expand Down Expand Up @@ -216,13 +216,13 @@ action:
{%- elif integration_id == "zha" -%}
{{ trigger.event.data.command }}{{"_" if trigger.event.data.args|length > 0}}{{ trigger.event.data.args|join("_") }}
{%- endif -%}
trigger_delta: '{{ (as_timestamp(now()) - as_timestamp((states(helper_last_controller_event) | from_json).last_triggered if helper_last_controller_event is not none and (states(helper_last_controller_event) | regex_match("^\{(\".*\": \".*\"(, )?)*\}$")) else "1970-01-01 00:00:00")) * 1000 }}'
last_controller_event: '{{ (states(helper_last_controller_event) | from_json).trigger_action if helper_last_controller_event is not none and (states(helper_last_controller_event) | regex_match("^\{(\".*\": \".*\"(, )?)*\}$")) else "" }}'
trigger_delta: '{{ (as_timestamp(now()) - ((states(helper_last_controller_event) | from_json).t if helper_last_controller_event is not none and (states(helper_last_controller_event) | regex_match("^\{((\"a\": \".*\"|\"t\": \d+\.\d+)(, )?){2}\}$")) else as_timestamp("1970-01-01 00:00:00"))) * 1000 }}'
last_controller_event: '{{ (states(helper_last_controller_event) | from_json).a if helper_last_controller_event is not none and (states(helper_last_controller_event) | regex_match("^\{((\"a\": \".*\"|\"t\": \d+\.\d+)(, )?){2}\}$")) else "" }}'
# update helper
- service: input_text.set_value
data:
entity_id: !input helper_last_controller_event
value: '{{ {"trigger_action":trigger_action,"last_triggered":now()|string} | to_json }}'
value: '{{ {"a":trigger_action,"t":as_timestamp(now())} | to_json }}'
# choose the sequence to run based on the received button event
- choose:
- conditions: '{{ trigger_action | string in button_up_short }}'
Expand All @@ -239,7 +239,7 @@ action:
- service: input_text.set_value
data:
entity_id: !input helper_last_controller_event
value: '{{ {"trigger_action":"double_press","last_triggered":now() | string} | to_json }}'
value: '{{ {"a":"double_press","t":as_timestamp(now())} | to_json }}'
# run the double press action
# fire the event
- event: ahb_controller_event
Expand Down Expand Up @@ -306,7 +306,7 @@ action:
- service: input_text.set_value
data:
entity_id: !input helper_last_controller_event
value: '{{ {"trigger_action":"double_press","last_triggered":now() | string} | to_json }}'
value: '{{ {"a":"double_press","t":as_timestamp(now())} | to_json }}'
# run the double press action
# fire the event
- event: ahb_controller_event
Expand Down
8 changes: 4 additions & 4 deletions blueprints/controllers/ikea_e1812/ikea_e1812.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ blueprint:
🚀 This blueprint is part of the **[Awesome HA Blueprints](https://epmatt.github.io/awesome-ha-blueprints) project**.
ℹ️ Version 2021.10.26
ℹ️ Version 2022.08.08
source_url: https://github.com/EPMatt/awesome-ha-blueprints/blob/main/blueprints/controllers/ikea_e1812/ikea_e1812.yaml
domain: automation
input:
Expand Down Expand Up @@ -212,12 +212,12 @@ action:
{%- elif integration_id == "zha" -%}
{{ trigger.event.data.command }}{{"_" if trigger.event.data.args|length > 0}}{{ trigger.event.data.args|join("_") }}
{%- endif -%}
trigger_delta: '{{ (as_timestamp(now()) - as_timestamp((states(helper_last_controller_event) | from_json).last_triggered if helper_last_controller_event is not none and (states(helper_last_controller_event) | regex_match("^\{(\".*\": \".*\"(, )?)*\}$")) else "1970-01-01 00:00:00")) * 1000 }}'
trigger_delta: '{{ (as_timestamp(now()) - ((states(helper_last_controller_event) | from_json).t if helper_last_controller_event is not none and (states(helper_last_controller_event) | regex_match("^\{((\"a\": \".*\"|\"t\": \d+\.\d+)(, )?){2}\}$")) else as_timestamp("1970-01-01 00:00:00"))) * 1000 }}'
# update helper
- service: input_text.set_value
data:
entity_id: !input helper_last_controller_event
value: '{{ {"trigger_action":trigger_action,"last_triggered":now()|string} | to_json }}'
value: '{{ {"a":trigger_action,"t":as_timestamp(now())} | to_json }}'
# choose the sequence to run based on the received button event
- choose:
- conditions: '{{ trigger_action | string in button_short }}'
Expand All @@ -234,7 +234,7 @@ action:
- service: input_text.set_value
data:
entity_id: !input helper_last_controller_event
value: '{{ {"trigger_action":"double_press","last_triggered":now() | string} | to_json }}'
value: '{{ {"a":"double_press","t":as_timestamp(now())} | to_json }}'
# run the double press action
# fire the event
- event: ahb_controller_event
Expand Down
Loading

0 comments on commit 9ee5920

Please sign in to comment.