Turn off a switch if Rain is forecast for the day

Duh!

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml


- platform: template
  sensors:
     8_hour_rain_forecast_total:
      friendly_name: "Regenvorhersage heute"
      value_template: "{{( states('sensor.yr_precipitation') |float + states('sensor.yr_forecast_1_precipitation') |float + states('sensor.yr_forecast_2_precipitation') |float + states('sensor.yr_forecast_3_precipitation') |float + states('sensor.yr_forecast_4_precipitation') |float + states('sensor.yr_forecast_5_precipitation') |float + states('sensor.yr_forecast_6_precipitation') |float + states('sensor.yr_forecast_7_precipitation') |float + states('sensor.yr_forecast_8_precipitation') |float) |round(1)}}"
      unit_of_measurement: "mm"

- platform: weather_data
  name: YR-Forecast-1
  forecast: 1
  monitored_conditions:
    - symbol
    - temperature
    - precipitation
    - windSpeed
 
- platform: weather_data
  name: YR-Forecast-2
  forecast: 2
  monitored_conditions:
    - symbol
    - temperature
    - precipitation
    - windSpeed

- platform: weather_data
  name: YR-Forecast-3
  forecast: 3
  monitored_conditions:
    - symbol
    - temperature
    - precipitation
    - windSpeed

- platform: weather_data
  name: YR-Forecast-4
  forecast: 4
  monitored_conditions:
    - symbol
    - temperature
    - precipitation
    - windSpeed

- platform: weather_data
  name: YR-Forecast-5
  forecast: 5
  monitored_conditions:
    - symbol
    - temperature
    - precipitation
    - windSpeed

- platform: weather_data
  name: YR-Forecast-6
  forecast: 6
  monitored_conditions:
    - symbol
    - temperature
    - precipitation
    - windSpeed 

- platform: weather_data
  name: YR-Forecast-7
  forecast: 7
  monitored_conditions:
    - symbol
    - temperature
    - precipitation
    - windSpeed

- platform: weather_data
  name: YR-Forecast-8
  forecast: 8
  monitored_conditions:
    - symbol
    - temperature
    - precipitation
    - windSpeed

You need to check indentation.

- platform: template
  sensors:
    8_hour_rain_forecast_total:
      friendly_name: "Regenvorhersage heute"
      value_template: "{{( states('sensor.yr_precipitation') |float + states('sensor.yr_forecast_1_precipitation') |float + states('sensor.yr_forecast_2_precipitation') |float + states('sensor.yr_forecast_3_precipitation') |float + states('sensor.yr_forecast_4_precipitation') |float + states('sensor.yr_forecast_5_precipitation') |float + states('sensor.yr_forecast_6_precipitation') |float + states('sensor.yr_forecast_7_precipitation') |float + states('sensor.yr_forecast_8_precipitation') |float) |round(1)}}"
      unit_of_measurement: "mm"

As soon as I add your code snippet it causes similar errors.
If I try myself it errors too.

I’ve ran it through YAML Validators - it say it’s okay, but HA seems to disagree.

This 8_hour_… line in your config is indented with 3 spaces but should be 2 (so remove 1).

And another error: all blocks starting with - platform should be indented completely with 2 spaces and all those blocks should be preceded with sensor: like this:

sensor:
  - platform: template
    sensors:
      8_hour...:
  - platform: weather_data
    name: etc...
    forecast: ...
    monitored_conditions:
      - ...
      - ...
  - platform: weather_data
    name: etc...
sensor:
  - platform: template
    sensors:
      8_hour_rain_forecast_total:
      friendly_name: "8 Hour Rain"
      value_template: "{{( states('sensor.yr_precipitation') |float + states('sensor.yr_forecast_1_precipitation') |float + states('sensor.yr_forecast_2_precipitation') |float + states('sensor.yr_forecast_3_precipitation') |float + states('sensor.yr_forecast_4_precipitation') |float + states('sensor.yr_forecast_5_precipitation') |float + states('sensor.yr_forecast_6_precipitation') |float + states('sensor.yr_forecast_7_precipitation') |float + states('sensor.yr_forecast_8_precipitation') |float) |round(1)}}"
      unit_of_measurement: "mm"

I’ve got this now.
I can’t validate it though, the wheel just keeps spinning :sweat_smile:
cc @metbril

for how long?

It’s been spinning for a few minutes now.

Are you still able to use HA through the browser?

Yeah.

I managed to make it not spin by trying to add this.

  - platform: weather_data
      name: YR-Forecast-1
      forecast: 1
      monitored_conditions:
        - symbol
        - temperature
        - precipitation
        - windSpeed
Error loading /config/configuration.yaml: mapping values are not allowed here
in "/config/configuration.yaml", line 22, column 11

post your full config again, i’ll have a look

# Configure a default setup of Home Assistant (frontend, api, etc)
#default_config:

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

sensor:
  - platform: template
    sensors:
      8_hour_rain_forecast_total:
      friendly_name: "8 Hour Rain"
      value_template: "{{( states('sensor.yr_precipitation') |float + states('sensor.yr_forecast_1_precipitation') |float + states('sensor.yr_forecast_2_precipitation') |float + states('sensor.yr_forecast_3_precipitation') |float + states('sensor.yr_forecast_4_precipitation') |float + states('sensor.yr_forecast_5_precipitation') |float + states('sensor.yr_forecast_6_precipitation') |float + states('sensor.yr_forecast_7_precipitation') |float + states('sensor.yr_forecast_8_precipitation') |float) |round(1)}}"
      unit_of_measurement: "mm"
      
  - platform: weather_data
      name: YR-Forecast-1
      forecast: 1
      monitored_conditions:
        - symbol
        - temperature
        - precipitation
        - windSpeed

You didn’t follow my example. The name item is indented from the platform item. Those should be exactly the same indent level.

Have a look again at my sample and follow closely. Indentation is important with yaml.

Is that the full config? The other one is longer?

I did copy and paste it, but must of accidentally indented it when trying to get it to work.

That was the full config, just trying to get one sensor to work before adding the other 7.
I’ve got this now, definitely copied from your posts.

# Configure a default setup of Home Assistant (frontend, api, etc)
#default_config:

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml


sensor:
  - platform: template
      sensors:
        8_hour_rain_forecast_total:
        friendly_name: "8 Hour Rain"
        value_template: "{{( states('sensor.yr_precipitation') |float + states('sensor.yr_forecast_1_precipitation') |float + states('sensor.yr_forecast_2_precipitation') |float + states('sensor.yr_forecast_3_precipitation') |float + states('sensor.yr_forecast_4_precipitation') |float + states('sensor.yr_forecast_5_precipitation') |float + states('sensor.yr_forecast_6_precipitation') |float + states('sensor.yr_forecast_7_precipitation') |float + states('sensor.yr_forecast_8_precipitation') |float) |round(1)}}"
        unit_of_measurement: "mm"
        
  - platform: weather_data
    name: YR-Forecast-1
    forecast: 1
    monitored_conditions:
      - symbol
      - temperature
      - precipitation
      - windSpeed
Error loading /config/configuration.yaml: mapping values are not allowed here
in "/config/configuration.yaml", line 16, column 14

The error is in line 16. My bad… I accidently indented too much myself.

  - platform: template
      sensors:
        8_hourxxx:

That should have been:

  - platform: template
    sensors:
      8_hourxxx:

(with sensors: aligned exactly below platform:

See?

I’ve updated my example to fix this.

Great. No worries.

I’ve put that in, and it just spins again!

EDIT: It is still spinning. I left it for a while. I can access the web interface fine
EDIT: Clarification: The validator.
EDIT: Neither the YR-Forecast-1 or the 8 Hour Rain appear in states or elsewhere that i can see

Just one more attempt. I’ve checked your full config and this one should be valid (yaml wise).
There’s 1 fix: the missing indents below 8_hour. I’ve also reformatted the value template to make the config a little more readable.

One final thing I noticed is, that you’ve disabled default_config:. Not sure what that’ll do when you restart.

# Configure a default setup of Home Assistant (frontend, api, etc)
#default_config:

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

sensor:
  - platform: template
    sensors:
      8_hour_rain_forecast_total:
        friendly_name: "8 Hour Rain"
        value_template: >
          {{ (states('sensor.yr_precipitation') |float +
              states('sensor.yr_forecast_1_precipitation') |float +
              states('sensor.yr_forecast_2_precipitation') |float +
              states('sensor.yr_forecast_3_precipitation') |float +
              states('sensor.yr_forecast_4_precipitation') |float +
              states('sensor.yr_forecast_5_precipitation') |float +
              states('sensor.yr_forecast_6_precipitation') |float +
              states('sensor.yr_forecast_7_precipitation') |float +
              states('sensor.yr_forecast_8_precipitation') |float) | round(1) }}
        unit_of_measurement: "mm"
        
  - platform: weather_data
    name: YR-Forecast-1
    forecast: 1
    monitored_conditions:
      - symbol
      - temperature
      - precipitation
      - windSpeed

I’ve restarted seemingly fine.
I thought it was giving me errors, so i disabled it. I’ll renable it.

I see what I did with the indentation. I wasn’t sure if It needed to be or not.

With a new error!

Platform error sensor.weather_data - Integration 'weather_data' not found.

Looks like i need to learn how to install
Danielhiversen/home_assistant_weather_data: Weather sensor (Replaces the old yr.no sensor) (github.com)
and HACS