Conversation
HA_TEMP_ENTITY (added in #17) only overrides the current hour's temperature from a Home Assistant sensor. Most weather-station integrations (WeatherFlow/Tempest, Ecowitt, AccuWeather, etc.) expose a bundled weather.* entity with wind speed/bearing and a condition string, not just a raw temperature sensor - this adds an optional HA_WEATHER_ENTITY setting that overrides wind speed, wind direction, sky condition, and day/night from that entity, independently of and alongside HA_TEMP_ENTITY. - weather.py: fetch_ha_weather() reads wind_speed/wind_bearing attributes and maps the entity's condition string to the closest WMO code via a small lookup table; unmapped conditions (e.g. "windy") leave ConditionCode on the online value rather than guessing. fetch_ha_is_day() reads sun.sun for day/night, since weather.* entities don't expose that directly. Staleness is judged against last_updated rather than last_changed, since a weather entity's condition (state) can sit unchanged for hours while its attributes keep updating - last_changed would make the override look stale almost immediately. - config.php / install_config.sh: expose HA_WEATHER_ENTITY next to the existing HA_TEMP_ENTITY field, same optional/blank-to-disable UX. - tests: cover the new fetch functions (happy path, staleness fallback, unmapped-condition partial result, sun.sun mapping). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Thanks for putting this together and testing it with your WeatherFlow/Tempest setup! Expanding Home Assistant support beyond a dedicated temperature sensor was a useful suggestion. This functionality is now available in v2.7.0 — Local Weather Stations through a separate implementation. An optional The implementation includes unit conversion, reporting-timestamp freshness checks, and independent fallback to available online data for each field. Local observations are saved before requesting online weather and stored separately so subsequent online syncs don’t overwrite them. Station Doctor also provides diagnostics for the configured sources. There are two intentional differences from this proposal: day/night continues using the existing station-location-based source rather than Thanks again for the contribution! Please try the release with your station and let me know if you encounter any integration-specific issues. |
Summary
HA_TEMP_ENTITY(from #17) is great for overriding temperature from a local Home Assistant sensor, but most weather-station integrations (WeatherFlow/Tempest, Ecowitt, AccuWeather, etc.) actually expose a bundledweather.*entity with wind speed/bearing and a condition string, not just a raw temperature sensor. This adds an optionalHA_WEATHER_ENTITYsetting so wind speed, wind direction, sky condition, and day/night can also come from your own station, independently of and alongsideHA_TEMP_ENTITY.fetch_ha_weather()readswind_speed/wind_bearingattributes and maps the entity'sstate(condition string) to the closest WMO code via a small lookup table. Conditions with no clean WMO equivalent (e.g.windy) are left alone rather than guessed at, so you still get a partial override (wind, no condition) instead of a wrong one.fetch_ha_is_day()readssun.sunfor day/night, sinceweather.*entities don't expose that directly and it's a stock entity on every HA install.last_updatedrather thanlast_changed— a weather entity's condition can sit unchanged for hours on a clear day while its numeric attributes keep updating every few minutes, solast_changedwould make the override look stale almost immediately.Test plan
pytest tests/test_weather_switch.py— 10 passed, including new coverage for the happy path, staleness fallback, unmapped-condition partial result, and the sun.sun day/night mappingphp -l scripts/config.php— no syntax errorsbash -n scripts/install_config.sh— no syntax errorspython3 -m py_compile scripts/utils/weather.py— compiles cleanweather.*entity on a running BirdNET-Pi install: ranweather.pymanually withHA_WEATHER_ENTITYset, confirmed the log output and the resultingweathertable row for the current hour matched the station's live reading exactly (temp, wind speed/direction, condition code, day/night)🤖 Generated with Claude Code