Created
January 19, 2024 23:06
-
-
Save tronikos/735351cfd7821dcebac44fdd701705b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blueprint: | |
name: Energy Disaggregation | |
description: Approximate power usage of an appliance | |
domain: automation | |
input: | |
power_helper: | |
name: Input helper to store the approximate power usage | |
description: in W | |
selector: | |
entity: | |
filter: | |
- domain: input_number | |
timer_helper: | |
name: Timer to reset power to 0W | |
description: Needed in case we miss the current decrease when appliance isn't under load | |
selector: | |
entity: | |
filter: | |
- domain: timer | |
l1_current_derivative: | |
name: L1 current derivative | |
description: (You first need to create a derivative sensor of your L1 current sensor) | |
selector: | |
entity: | |
filter: | |
- domain: sensor | |
integration: derivative | |
l1_voltage: | |
name: L1 voltage | |
description: in V | |
selector: | |
entity: | |
filter: | |
- domain: sensor | |
device_class: voltage | |
current_derivative_factor: | |
name: Current derivative factor | |
description: Factor to multiple the derivatives to get A. E.g. if derivatives are in A/s over 10s, multiply by 10 | |
default: 1 | |
selector: | |
number: | |
min: 0.1 | |
max: 100.0 | |
step: 0.1 | |
mode: box | |
l1_lower_bound: | |
name: Lower bound for L1 current derivative | |
description: Assume appliance started if L1 current increased by at least this | |
default: 19 | |
selector: | |
number: | |
min: -100 | |
max: 100.0 | |
step: 0.1 | |
unit_of_measurement: A | |
mode: box | |
l1_upper_bound: | |
name: Upper bound for L1 current derivative | |
description: Assume appliance started if L1 current increased by at most this | |
default: 24 | |
selector: | |
number: | |
min: -100 | |
max: 100.0 | |
step: 0.1 | |
unit_of_measurement: A | |
mode: box | |
delay: | |
name: Delay | |
description: Time duration the current increase/decrease has to stay within the above limits | |
default: | |
seconds: 5 | |
selector: | |
duration: {} | |
trigger_variables: | |
current_derivative_factor: !input current_derivative_factor | |
trigger: | |
- platform: numeric_state | |
entity_id: !input l1_current_derivative | |
value_template: "{{ state.state | float() * current_derivative_factor }}" | |
above: !input l1_lower_bound | |
below: !input l1_upper_bound | |
for: !input delay | |
- platform: numeric_state | |
entity_id: !input l1_current_derivative | |
value_template: "{{ state.state | float() * -1 * current_derivative_factor }}" | |
above: !input l1_lower_bound | |
below: !input l1_upper_bound | |
for: !input delay | |
- platform: event | |
event_type: timer.finished | |
event_data: | |
entity_id: !input timer_helper | |
id: timer-finished | |
variables: | |
l1_current_derivative: !input l1_current_derivative | |
current_derivative_factor: !input current_derivative_factor | |
l1_voltage: !input l1_voltage | |
condition: [] | |
action: | |
- choose: | |
- conditions: | |
- condition: trigger | |
id: | |
- timer-finished | |
sequence: | |
- service: input_number.set_value | |
data: | |
value: 0 | |
target: | |
entity_id: !input power_helper | |
- conditions: | |
- condition: numeric_state | |
entity_id: !input l1_current_derivative | |
value_template: "{{ state.state | float() * current_derivative_factor }}" | |
above: !input l1_lower_bound | |
below: !input l1_upper_bound | |
sequence: | |
- service: input_number.set_value | |
data: | |
value: >- | |
{{ states(l1_current_derivative) | float * current_derivative_factor * states(l1_voltage) | float }} | |
target: | |
entity_id: !input power_helper | |
- service: timer.start | |
data: {} | |
target: | |
entity_id: !input timer_helper | |
- conditions: | |
- condition: numeric_state | |
entity_id: !input l1_current_derivative | |
value_template: "{{ state.state | float() * current_derivative_factor * -1 }}" | |
above: !input l1_lower_bound | |
below: !input l1_upper_bound | |
sequence: | |
- service: input_number.set_value | |
data: | |
value: 0 | |
target: | |
entity_id: !input power_helper | |
mode: single | |
max_exceeded: silent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment