Solar water heating

I have the following yaml scripts for configuration.yaml and automation. If I go to Server Control, Check Configuration I get the error from the logs Invalid config for [automation]: required key not provided @ data [‘action’] Got None (See /config/configuration.yaml line 8) Line 8 = group: ! include groups.yaml.
If I put the value_template in Developer Tools, Template it returns the temperature difference in degrees C to 16 decimal places. What is wrong with the config or automation yaml to produce this error? The switch and ds18b20 temperatures are on a esp32 via esphome. The switch works manually, the switch and temperatures show in the dashboard.


configuration.yaml
sensor:
  - platform: template
    sensors:
      temperature_difference:
      entity_id:
        - sensor.panel_temperature 
        - sensor.tank_temperature   
      friendly_name: "Temperature Difference"
      value_template: "{{ (states('sensor.panel_temperature') | float  - states('sensor.tank_temperature') | float )  }}"
       
automation

alias: pump_on
trigger:
  platform: numeric_state
  entity_id: sensor.temperature_diffenence
  above: 4
action:
  service: switch.turn_on
  entity_id: switch.pump 

  alias: pump_off
  trigger:
    platform: numeric_state
    entity_id: sensor.temperature_difference
    below: 2
  action:
    service: switch.turn_off
    entity_id: switch.pump
1 Like

You are missing the colon after automation:

And your second automation (pump off) is indented too far. It should be the same as the pump on automation.

Also this is no longer a valid option for the template sensor, remove it:

      entity_id:
        - sensor.panel_temperature 
        - sensor.tank_temperature   

Also, also, your automation configurations should go in the file automations.yaml if you have this in your configuration.yaml:

automation: !include automations.yaml

Finally, if you want to see a history graph of your temperature difference, add a unit_of_measurement to the sensor config.

Hi tom_i
Thank you for your reply. The automation part of the script is in the automations.yaml file. If I indent the same as pump on I get an error message. Configurations.yaml has automation: ! include automations,yaml

What message?

The message was duplicated mapping key at line 11, column1:
alias: pump_off. When I reloaded HA this message had disappeared and I had the green tick. I still get the logs Invalid config for [automation]: required key not provided @ data [‘action’] Got None (See /config/configuration.yaml line 8) Line 8 = group: ! include groups.yaml.

Hi Adhoc77
Did you get it to work?
I’m trying to do it also
cheers