How Do I Set Up An Automation To Tell Me When My Weather Station Is Offline

I have a WiFi connected weather station mounted outside of my house. To deal with the loss of signal due to distance and exterior wall thickness I setup a WiFi extender as close to the exterior wall as possible. Every so often the WiFi extender goes down and the weather data stops being collected. Here’s an example of what that looks like using the temperature sensor, the long flat lines are when the WiFi went down

How do I create an automation to check if the temperature sensor value hasn’t changed in the last 30 minutes?

The name of the temperature sensor is:

sensor.ambient_weather_station_temp

Thanks in advance.

{{ states["sensor.ambient_weather_station_temp"].last_updated }}

will give you the last time the sensor was updated.

So

automation:
  trigger:
    - platform: time_pattern
      # You can also match on interval. This will match every 5 minutes
      minutes: "/5"
  condition:  '{{ as_timestamp(now()) - as_timestamp(states["sensor.ambient_weather_station_temp"].last_updated) > 30*60 }}'
  action:
    <whatever>

Not sure what you mean by “goes down”, but you could use ping on it as well if it looses connectivity to the router
Ping (ICMP) - Home Assistant (home-assistant.io)

You can do this a bit more directly:

automation:
  - trigger:
      - platform: template
        value_template: >
          {{ (now() - states.sensor.ambient_weather_station_temp.last_updated)
             .total_seconds() > 30 * 60 }}

How often will that trigger be evaluated?

The template will be evaluated whenever sensor.ambient_weather_station_temp changes, or every minute. The automation will trigger whenever the result changes from false to true.

The Weather Station and Home Assistant are on two different networks, one has a PiHole the other doesn’t, I didn’t want to complicate things by including that detail.

The other part helped me solve the problem thanks.

This put me on the right path, thanks.

Would you mind telling me what the model of weather station you are using and how you have it integrated into HA?

My old 433RF station jus died and i’m in the market for a new one and I’d like to get one that integrates to HA (local preferred vs cloud polling)

It’s an Ambient Weather WS-2902B, I believe the current version is WS-2902C, not sure exactly what the difference is. I’m generally happy with it, the only thing that I didn’t like was putting it on my WiFi network. It only works on 2.4ghz so you have to temporarily disable the 5ghz network while doing it. The App that connects the two is kinda old, and super buggy, it took 6-7 tries before it finally worked. You should only have to do it once.

Connecting it to Home Assistant was really easy, just use the Ambient Weather Integration

1 Like