diff options
author | root <root@smartpi.suren.me> | 2023-01-10 07:45:02 +0400 |
---|---|---|
committer | root <root@smartpi.suren.me> | 2023-01-10 07:45:02 +0400 |
commit | 2c0c331eb7b7a03152309bbbd4e0fee157e8d86c (patch) | |
tree | 03391160212b39c4597ecc26010f2ba1235a65e3 /custom/template.yaml | |
download | hass-2c0c331eb7b7a03152309bbbd4e0fee157e8d86c.tar.gz hass-2c0c331eb7b7a03152309bbbd4e0fee157e8d86c.tar.bz2 hass-2c0c331eb7b7a03152309bbbd4e0fee157e8d86c.tar.xz hass-2c0c331eb7b7a03152309bbbd4e0fee157e8d86c.zip |
Initial configuration
Diffstat (limited to 'custom/template.yaml')
-rw-r--r-- | custom/template.yaml | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/custom/template.yaml b/custom/template.yaml new file mode 100644 index 0000000..710b936 --- /dev/null +++ b/custom/template.yaml @@ -0,0 +1,54 @@ +# Manual lights + +- trigger: + - platform: state + entity_id: "switch.bedroom_bedsidelampsocket" + - platform: state + entity_id: "sensor.bedroom_bedsidelampsocket_power" + binary_sensor: + - name: "Bedroom/BedsideLamp" + device_class: light + state: > + {{ is_state("switch.bedroom_bedsidelampsocket", "on") and ((states("sensor.bedroom_bedsidelampsocket_power") | float) > 1) }} + +- sensor: + - name: "Power SmartPI" + unit_of_measurement: "W" + state: > + {% set readings = [ states('sensor.living_office_power'), + states('sensor.office_shelftop_power') | float(0), states('sensor.office_shelfbottom_power') | float(0), + states('sensor.office_table_power') | float(0), states('sensor.office_aircon_power') | float(0) ] %} + {{ 'unavailable' if readings[0] == 'unavailable' else readings[0] | float - readings[1] - readings[2] - readings[3] - readings[4] }} + + - name: "Power Office" + unit_of_measurement: "W" + state: > + {{ expand(states.switch.power_office) | selectattr('state') | map(attribute='entity_id') + | map('regex_replace','^switch(.*)$','sensor\\1_power') | map('expand') | map(attribute=0) | select("defined") + | selectattr('state','is_number') | map(attribute='state') | map('float') | list | sum }} + + - name: "Power Infrastructure" + unit_of_measurement: "W" + state: > + {{ states('sensor.power_smartpi') | float + expand(states.switch.power_infrastructure) | selectattr('state') | map(attribute='entity_id') + | map('regex_replace','^switch(.*)$','sensor\\1_power') | map('expand') | map(attribute=0) | select("defined") + | selectattr('state','is_number') | map(attribute='state') | map('float') | list | sum }} + - name: "Power Kitchen" + unit_of_measurement: "W" + state: > + {{ expand(states.switch.power_kitchen) | selectattr('state') | map(attribute='entity_id') + | map('regex_replace','^switch(.*)$','sensor\\1_power') | map('expand') | map(attribute=0) | select("defined") + | selectattr('state','is_number') | map(attribute='state') | map('float') | list | sum }} + - name: "Power Climate" + unit_of_measurement: "W" + state: > + {{ expand(states.switch.power_climate) | selectattr('state') | map(attribute='entity_id') + | map('regex_replace','^switch(.*)$','sensor\\1_power') | map('expand') | map(attribute=0) | select("defined") + | selectattr('state','is_number') | map(attribute='state') | map('float') | list | sum }} + - name: "Power Lights" + unit_of_measurement: "W" + state: > + {{ expand(states.switch.power_lights) | selectattr('state') | map(attribute='entity_id') + | map('regex_replace','^switch(.*)$','sensor\\1_power') | map('expand') | map(attribute=0) | select("defined") + | selectattr('state','is_number') | map(attribute='state') | map('float') | list | sum }} + |