Automation turn on my solar panel do heat water. Help

Hi. Could you help to my automation please.
I want to create automation when the temperature in the solar is 1 degree higher than the temperature in the Jacuzzi, then the pump in the solar should turn on. and when will be the same or lower turn Off.
My code no work :frowning:

alias: SOLAR HEAT
description: ""
trigger:
  - platform: template
    value_template: >-
      {{ states('sensor.sonoff_1001032177_temperature') | float >
      states('sensor.f0bba9a51e0f73eff2b53d25dfc82948') | float + 1 }}
condition: []
action:
  - service: switch.turn_on
    entity_id: switch.sonoff_1001032177
mode: single

switch.sonoff_1001032177 - this is SONOFF TH16 so can on and off power and have temperature sensor - sensor.sonoff_1001032177_temperature
climate.spa_thermostat - Bestway temperature spa sensor
device_id: f0bba9a51e0f73eff2b53d25dfc82948 - Bestway temperature spa sensor.

Thank You

alias: SOLAR HEAT
description: ""
trigger:
  - platform: state
    entity_id: sensor.sonoff_1001032177_temperature
    to: # null to triggers on every state change, ignores attribute changes.
  - platform: state
    entity_id: sensor.f0bba9a51e0f73eff2b53d25dfc82948
    to:
action:
  - service: >
      {% if  states('sensor.sonoff_1001032177_temperature') | float(0) >
      states('sensor.f0bba9a51e0f73eff2b53d25dfc82948') | float(0) + 1 %}
        switch.turn_on
      {% else %}
        switch.turn_off
      {% endif %}
    target:
      entity_id: switch.sonoff_1001032177
  - delay:
      minutes: 5
mode: single
max_exceeded: silent

The delay at the end prevents this automation running any more than once every 5 minutes to prevent rapid power switching of your pump. Adjust this time as you see fit. Be warned that this timer will reset if you reload the automation or restart home assistant.

1 Like

Thank you for your help.
I don’t know what the problem is, but now the solar pump turns on by itself, e.g. now when the temperature on sonoff is 28, and in the pool 31 :confused: which cools my pool :wink: :wink: Something is probably still wrong in this code

Do you have your sensors back to front?

It’s hard to tell because you have not given them meaningful entity ids.

1 Like

Are you sure you have a sensor.f0bba9a51e0f73eff2b53d25dfc82948 ? it looks like you have just used the device_id for the climate entity ?

Maybe use state_attr('climate.spa_thermostat', 'current_temperature') instead ?

1 Like


something like this ?

alias: SOLAR HEAT
description: ""
trigger:
  - platform: state
    entity_id: sensor.sonoff_1001032177_temperature
    to: null
  - platform: state
    entity_id: sensor.f0bba9a51e0f73eff2b53d25dfc82948
    to: null
action:
  - service: >
      {% if  states('sensor.sonoff_1001032177_temperature') | float(0) >
      state_attr('climate.spa_thermostat', 'current_temperature') | float(0) + 1
      %}
        switch.turn_on
      {% else %}
        switch.turn_off
      {% endif %}
    target:
      entity_id: switch.sonoff_1001032177
  - delay:
      hours: 0
      minutes: 1
      seconds: 0
      milliseconds: 0
mode: single
max_exceeded: silent

Thank you very much @tom_l @Holdestmade for your help. Now it is working.

You can remove this as you don’t have that sensor

Maybe replace with:

  - platform: state
    entity_id: climate.spa_thermostat
1 Like