Regulate smartplug between minimum and maximum wattages

I am trying to regulate the li-ion battery charger of my bicycle using an athom smart plug (tasmota version).

If the battery no longer charges, the charger uses 10 Watts.
If I connect the empty battery, the charger uses a maximum of 100 watts.
I have a variable called input_number.wattage_min with a value of 10 and a variable input_number.wattage_max with a value of 100.
I also measure the current wattage in the variable sensor.athom_plug_energy.current.

I’m trying to come up with a node red flow that turns off the smart plug when the measured wattage falls below 10W or above 100W.
I can’t figure it out. Can someone help me on my way?

An additional problem is that when I turn on the smart plug, it is immediately turned off again because the flow I am trying says that the wattage is immediately below 10 at the start.

Instead of spawning the logic over tasmota, mqtt, node-red and HA the maybe smater and more resilient way would just to makes use espHome. :gear:

Can be simple as something like: :point_down:

sensor:
  - platform: ... 
    power: 
      name: "Charger Load" 
      on_value_range:
        - above: 100.0
          then:
            - switch.turn_off: relay
        - below: 10.0
          then:
            - switch.turn_off: relay

With probably only one more condition to add so the value needs to be in the range for time x. Fire and forget :rocket:

You can use the custom outputs from a trigger node.

[{"id":"4e1a1b79135cecc2","type":"trigger-state","z":"0a325c35fc29f44e","name":"","server":"","version":5,"inputs":0,"outputs":4,"exposeAsEntityConfig":"","entities":{"entity":[],"substring":[],"regex":[]},"debugEnabled":false,"constraints":[],"customOutputs":[{"messageType":"default","messageValue":"","messageValueType":"json","comparatorPropertyType":"current_state","comparatorPropertyValue":"new_state.state","comparatorType":"<","comparatorValue":"10","comparatorValueDataType":"num"},{"messageType":"default","messageValue":"","messageValueType":"json","comparatorPropertyType":"current_state","comparatorPropertyValue":"new_state.state","comparatorType":">=","comparatorValue":"100","comparatorValueDataType":"num"}],"outputInitially":false,"stateType":"str","enableInput":false,"x":910,"y":920,"wires":[[],[],["c2dc9e700f40143f"],["09798359e6f409b4"]]},{"id":"c2dc9e700f40143f","type":"debug","z":"0a325c35fc29f44e","name":"< 10","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1090,"y":900,"wires":[]},{"id":"09798359e6f409b4","type":"debug","z":"0a325c35fc29f44e","name":">= 100","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1100,"y":940,"wires":[]}]

Thank you all. problem solved, except the additional problem.
When I turn on the smart plug, it is immediately turned off again because the flow I am trying says that the wattage is immediately below 10 at the start.

If that is the case separate the triggers and use an event state node instead. This way the < 10 trigger you can add a time requirement in the for section.

image

YSK this will trigger every time the sensor updates and the value is below 10 or over 100. You should use a current state after the trigger to check if the charger is off.

image