Help for automation charging ebike when solar is above x Watt and turn off smartplug when no power

Hi,

I created a automation for charging the ebike by smartplug is solar is above 1000 Watt.
I want to turnoff the smartplug if the power is below 1 (the ebike is fully charged).

However the automation is only running for the first trigger…if the solar is producing enought power the smartplug goes on but it will never turn off.

alias: Van Moof opladen
description: van moof opladen zodra zonnepanelen energie opwekken boven de 1000 watt

alias: Van Moof opladen
description: van moof opladen zodra zonnepanelen energie opwekken boven de 1000 watt
trigger:
  - platform: numeric_state
    entity_id: sensor.soliscloud_simpelzon_ac_output_total_power
    alias: When solis (current power) is above 1000
    above: 1000
    id: charging
  - platform: numeric_state
    entity_id: sensor.van_moof_bw_2_power
    id: stop charging
    below: 1
    enabled: true
    for:
      hours: 0
      minutes: 1
      seconds: 0
condition: []
action:
  - if:
      - condition: trigger
        id: charging
    then:
      - service: switch.turn_on
        data: {}
        target:
          entity_id: switch.van_moof
  - if:
      - condition: trigger
        id: stop charging
    then:
      - service: switch.turn_off
        data: {}
        target:
          entity_id: switch.van_moof
mode: single

Please format your code using the </> button in the editor

1 Like

sorry done

  - platform: numeric_state
    entity_id: sensor.van_moof_bw_2_power
    id: stop charging
    below: 1
    enabled: true
    for:
      hours: 0
      minutes: 1
      seconds: 0

First, below 1 for 1 minute is extreme, because it means 0, it is not less or equal in HA.
Second, can you click Open your Home Assistant instance and show your template developer tools.

And put on the left part of the screen.

{{ sensor.van_moof_bw_2_power }}

And look at the value on the right, is it a number? What is the current value like?

Result type: number

1 Like

First : below 1 for 1 minute is extreme, because it means 0, it is not less or equal in HA.
I had 5 (watt)

I got an error

my bad, {{ states('sensor.van_moof_bw_2_power') }}

1 Like

I do something similar to turn off solar charging for my ev.

I use 10w as the threshold - determined by looking at the actual consumption when the car was fully charged - and there’s no time period. If the consumption falls to that level then the car is full - there’s no other reason so in my mind no need to wait.

Use it every day this time of year and it works really well. (I have a battery so second automation tracks home battery storage level and turns off once battery discharges to user set level - means I don’t have to worry about actual solar power which can go up and down quite a bit).

1 Like

the thing is that the second trigger is not running. I can only see the consumption of my smartplug not the ebike.

Ok, it is a number, good.
I agree with @steve_jo that there’s probably no need to wait (or not “that long”)
In your history can you see one full minute where the sensor is 0?

Yes understand - same for me. @Olivier1974 suggestion is a good one. Look at the smart plug power consumption sensor when charging your bike. Pick a suitable threshold value - it’s probably above zero even when bike is fully charged.

smart plugs are always taking small energy to operate power metering and wifi/zigbee

the thing is that the second trigger never start to check if the power of the smartplug is below a certain number


I checked when the bike was 100% in the app and the smartplug doesn’t go off.

The trigger is triggered (weird sentence) only if the sensor is 0 for 1 minute.
It is not starting the automation and do the 1 minute wait.
So, yes, if the sensor is not 0 for a full minute, it will never even trigger.

To be honest I’ve never really understood the automation trace display.

The trigger is only ‘triggered’ when the condition is met so there’s nothing to show in the trace display.

Yuo need to investigate what the actual smart plug consumption is when the bike is fully charged - look at the sensor history as described above. Then set your threshold value (and time if needed) to something that will detect fully charged. Even when the bike is fully charged you are still powering the charger so the value is likely to be above zero.

oke i need to put the treshold on below 10 watt and put the time on 0?

Nobody can tell for you :slight_smile:
Really have a look at your graph of the sensor (in the history) and look what seems to be a normal value when in charge and a normal value for “not in charge”. Take a number a bit above the “not in charge” and a time if you want to avoid false positive.

i will test that coming days…for now the sun is not shining :frowning:

In the history i see that the power of the smartplug is 0. Still don’t understand why the smartplug is not going off.

drag along that zero line with the cursor to see the actual value