The value once charged is finished is between 2.4 and 0 Watts, placing | int has solved the problem of the guy who wrote that post.
I can’t figure out why I can’t have it working…
The template debugger if I write
Importantly, the numeric_state trigger only fires if the value crosses the threshold. In this case, the value must drop from above 5 to below 5 to trigger. If the switch is on and the value is already below 5, it won’t trigger.
Also, does the automation work if you manually run it (from Configuration / Automations)? That bypasses the trigger and condition, and tests the action.
Ah, you have to specify the attribute in your trigger:
attribute: current_consumption
The trigger is only, by default, evaluated when the state of the entity changes, i.e. on/off.
adding the attribute will make it monitor the attribute in question.
Thank you @Troon !
Finally I have understood why the automation didn’t worked before… It was simply because when I was turning on the charger, its power consumption was already below 10 Watts since the battery wasn’t still connected (or it seems to be the reason).
I’ve changed the threshold to a lower value (2.5 W) and now the automation works.
Thank you for your support!
P.S. In the topic that I’ve previously linked is advised to add a value template to convert the float value of the sensor in an integer value for the correct functioning of the automation, that’s the reason why in my code appears
value_template: >-
{{ states.switch.caricabatterie_switch.attributes.current_consumption |
int }}
The automation works seamlessly if that line of code is present or not.
Thank you again!