From 0c0b48b5da2dcfa6d98d27050c623cd6aa860c5e Mon Sep 17 00:00:00 2001 From: Joe Mou Date: Mon, 6 Jul 2026 03:31:01 -0400 Subject: HA: Check for rain --- hostnix/elmo/home-assistant.nix | 46 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'hostnix/elmo') diff --git a/hostnix/elmo/home-assistant.nix b/hostnix/elmo/home-assistant.nix index d17c41b..5648a0f 100644 --- a/hostnix/elmo/home-assistant.nix +++ b/hostnix/elmo/home-assistant.nix @@ -80,6 +80,7 @@ in use_x_forwarded_for = true; }; recorder.db_url = "postgresql://@/hass"; + auth_oidc = { client_id = "9332ad56-1917-4f12-a0ef-f6ff69994cf4"; discovery_url = "https://pi.mou.fo/.well-known/openid-configuration"; @@ -102,6 +103,13 @@ in brightness_mode_time_light = 3 * 60 * 60; }; + input_boolean = { + rain_today = { + name = "Rain today"; + icon = "mdi:weather-rainy"; + }; + }; + template = [ { switch = [ @@ -369,6 +377,44 @@ in ]; } + { + id = "check_rain_forecast"; + alias = "Check rain forecast"; + trigger = [ (ha.trigger.at "05:00") ]; + action = [ + { + action = "weather.get_forecasts"; + target.entity_id = "weather.forecast_home"; + data.type = "daily"; + response_variable = "forecast"; + } + { + "if" = [ + { + condition = "template"; + value_template = "{{ forecast['weather.forecast_home'].forecast[0].precipitation > 0 }}"; + } + ]; + "then" = [ + { + action = "input_boolean.turn_on"; + target.entity_id = "input_boolean.rain_today"; + } + { + action = "notify.notify"; + data.message = "Rain expected today ({{ forecast['weather.forecast_home'].forecast[0].precipitation }} inches)"; + } + ]; + "else" = [ + { + action = "input_boolean.turn_off"; + target.entity_id = "input_boolean.rain_today"; + } + ]; + } + ]; + } + # The panel light can become unresponsive and need to be reboot. { id = "panel_light_reinitialize"; -- cgit v1.3.1