briis / hass-weatherflow2mqtt

WeatherFlow to MQTT for Home Assistant. Use UDP to get local weather data in to Home Assistant using MQTT Discovery
MIT License
129 stars 29 forks source link

Anyway to include sunrise/sunset in forecasts? #213

Closed ronnyek closed 1 year ago

ronnyek commented 1 year ago

New Feature

Everything with this is working great. I just had a couple questions....

1) I see the API documents that daily forecasts include sunrise/sunset. I don't see that in the listed sensors I believe I have them all enabled anyway). Is there any way to get this?

2) It seems like all the messages published to mqtt are setup as persistent so if I reconnect my app to mqtt server, I dont have to wait for the new readings etc... with the exception of the latest observation. I'm not super familiar with whether this is somethign I need to setup on my MQTT broker, or if its because messages are pushed with no persistent flag.

Additional context

No response

ronnyek commented 1 year ago

I got source running and made this change to forecast.py

 ATTR_FORECAST_PRECIPITATION_PROBABILITY: row["precip_probability"],
          "sunrise": self.conversions.utc_from_timestamp(
              row["sunrise"]
          ),
          "sunset": self.conversions.utc_from_timestamp(
              row["sunset"]
          ),
          "precip_icon": row.get("precip_icon", ""),

And now I get this: image

I can add sunrise/sunset as constant attributes like a lot of the other fields, and even submit a PR if anyone is interested

briis commented 1 year ago

As this is written for Home Assistant, there is already a default sensor in HA called sun.sun where you can get all sun related info, so no need to recreate this in this Integration.

The persistent parameter is set by the publisher to MQTT so you don't need to change anything in your MQTT setup.