Hey Guys,
I already made a post concerning this problem of mine but after I implemented the solutions the code still didn’t work. In a nutshell, I need a code, that says how often a device has been turned on. If it reaches more than 5.5 Watts, it is considered to be on and every time it goes below 5.5 it is considered to be off. Every time this cycle repeats, the counter has to be incremented by one but unfortunately it does not work. I use File Folder and have printed the code inside config.automations yaml, should it be located somewehere else? Should the paragraph with the binary sensor be inside another folder like sensors.yaml? My code might stil be wrong so I would really appreciate any sort of feedback, I genuienly am not sure where I could have potentially made a mistake.
counter:
'counter.zahler_wasserspender':
initial: 0
step: 1
template:
- binary_sensor:
- entity_id: input_boolean.binary_sensor
value_state: >
{% if states('sensor.shellyplug_s_c8c9a3b8d590_power') | float(default=0) >= 5.5 %}
to: 'on'
{% elif states('sensor.shellyplug_s_c8c9a3b8d590_power') | float(default=0) < 5.5 %}
to: 'off'
automation:
alias: 'Increment if over measurement'
trigger:
platform: state
entity_id: input_boolean.binary_sensor
from: 'off'
to: 'on'
action:
service: 'counter.increment'
entity_id: 'counter.zahler_wasserspender'
Thanks for your time in advance,
Cheers