Hello,
I have a Shelly 1 PM connected to a water heater, witch turn on if water temp is below 42ºC and turn off if wter temp is higer than 50ºC
I creat an automation that notifies me when Shelly turns on and save the total consumption to a input.number.
When it turns off I get a notification also and save the total consumption to another input.number.
What I want and I can’t figure it out is on the notification when it turns off get information about the subtration of the final input.number and the inicial input.number.
input_number:
consumption_start:
name: Consumo inicio
min: 0
max: 999999999
consumption_end:
name: Consumo fim
min: 0
max: 999999999
energy_used:
name: Energia Consumida
min: 0
max: 999999999
automation:
- alias: Cilindro On
initial_state: true
trigger:
- platform: state
entity_id: switch.shelly_shsw_pm_d8bfc019c514
from: 'off'
to: 'on'
action:
- service: input_number.set_value
data_template:
entity_id: input_number.consumption_start
value: "{{ states.sensor.shelly_shsw_pm_d8bfc019c514_total_consumption.state }}"
- service: telegram_bot.send_message
data_template:
target: !secret telegram_chatid1
message: >
Cilindro ligou, temperatura da água são {{states.sensor.shelly_shsw_pm_d8bfc019c514_2_temperature.state}}ºC, e consumo total atual são {{states.sensor.shelly_shsw_pm_d8bfc019c514_total_consumption.state}} KWh
disable_notification: true
- alias: Cilindro Off
initial_state: true
trigger:
- platform: state
entity_id: switch.shelly_shsw_pm_d8bfc019c514
from: 'on'
to: 'off'
action:
- service: input_number.set_value
data_template:
entity_id: input_number.consumption_end
value: "{{ states.sensor.shelly_shsw_pm_d8bfc019c514_total_consumption.state }}"
- service: input_number.set_value
data_template:
entity_id: input_number.energy_used
value: "{{ states('input_number.consumption_end') - states('input_number.consumption_start') }}"
- service: telegram_bot.send_message
data_template:
target: !secret telegram_chatid1
message: >
Cilindro desligou, temperatura da água são {{states.sensor.shelly_shsw_pm_d8bfc019c514_2_temperature.state}}ºC, e consumiu {{states.input_number.energy_used.state}} KWh
disable_notification: true