Turn off a switch if Rain is forecast for the day

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

That, or use any of the other weather integrations like AccuWeather.

Would I have to find a weather plugin that supports multiple forecasts?

The AW API supports hourly forecasts. Haven’t used it myself, so just register for an account, install and try. Good luck!

1 Like

The Met.no integration also supports (24) hourly forecasts and is way easier to setup. Add it through the integrations UI, then enable hourly forecasts (if disabled) and go!

use this value template:

value_template: >
  {{ (states.weather.home_hourly.attributes.forecast[0].precipitation|float +
      states.weather.home_hourly.attributes.forecast[1].precipitation|float +
      states.weather.home_hourly.attributes.forecast[2].precipitation|float +
      states.weather.home_hourly.attributes.forecast[3].precipitation|float +
      states.weather.home_hourly.attributes.forecast[4].precipitation|float +
      states.weather.home_hourly.attributes.forecast[5].precipitation|float +
      states.weather.home_hourly.attributes.forecast[6].precipitation|float +
      states.weather.home_hourly.attributes.forecast[7].precipitation|float)|round(1) }}
3 Likes

I managed to get HACS installed, and it works with that integration I linked!
I’ll probably move to that, since that’s a lot cleaner and has less dependancies.

I’'ve also found the magic of HACS. It’s so wonderful!!! I might have to ditch Homebridge and install HA for proper!

you should use the weather service that has the best forecast for your location. The quality, update frequency and accuracy can vary, so try multiple.

For the Netherlands I used to use the forecast of Buienradar (core integration) but have recently moved to the way more accurate Buienalarm (custom integration).

1 Like

Will do.

How can I tell if the service supports forecast numbers? I’m looking at the Met Office, and I don’t see a forecast entity in the table.