Hello guys,
I recently started using HA and have amateur skills, meaning that I have difficulties getting along with the technicalities and YAML. Nevertheless, I tried my best to create a code, which allows me to see how many times a device has been turned on. This has been based on many templates and community posts I saw on the internet. The code is as follows:
counter:
'counter.zahler_wasserspender':
initial: 0
step: 1
-automation:
-alias: 'Increment if over measurement'
trigger:
platform: time_pattern
seconds: '/30'
condition:
condition: state
value_state: "{{ states('sensor.shellyplug_s_c8c9a3b8d590_power') | int >= 5.5 }}"
action:
service: 'counter.increment'
entity_id: 'counter.zahler_wasserspender'
If the device has a higher power than 5.5 Watts, it is considered to be on (based on the measurements and experiments I performed). I also created the counter with the āHelpersā option, however for some reason the counter does not increment when the device is being used. I am not really sure if I have to use āstateā as a condition or ādeviceā and if ātime_patternā is fitable as a trigger in that situation.
Where did I make any mistakes or do you have any suggestions?
Everything is extremely appreciated, thank you in advance!
Cheers