ebaauw / homebridge-ws

Homebridege plugin for virtual weather station
Apache License 2.0
108 stars 4 forks source link

Retrieve PWS data from OpenWeatherMap #8

Closed mwkchan closed 5 years ago

mwkchan commented 5 years ago

Would you be able to support Personal Weather Station with API3.0 in OpenWeatherMap?

Check this out: https://openweathermap.org/stations#get_measurements

ebaauw commented 5 years ago

Technically this seems straightforward: a different URL and a different JSON schema. I would need to borrow an account ID and station ID to develop and test this (it seems the station can only be queried from the account that created it).

Functionally, there seems to be a mismatch: the Weather Stations API deals with historic data (upload of multiple measurements over time in one call, and download of aggregated data for multiple periods), where homebridge-ws only retrieves and uses the current (latest) data, building its own history. I'm not sure the Weather Stations API will support (commercially) a measurement upload and data download every 10 minutes.

It would make more sense to me to get the data straight from the PWS, rather than using a U-turn construct through OpenWeatherMap. I'm assuming here the PWS (or associated server application) has a local API to show the current weather in its associated mobile app. If the PWS only supports pushing the data to OpenWeatherMap periodically (and is asleep most of the time, to preserve its battery), it would make more sense to create a homebridge plugin with a built-in web server where the data can be pushed to additionally.

mwkchan commented 5 years ago

First, regarding station ID and account, you actually can simply create a test station using your AppID and post data to test it, a really PWS is not required and any one with an AppID can create multiple stations.

What I want to achieve is to retrieve current data from my PWS to HomeKit. So you are actually quite right with your analysis. I have a PWS (WH2600) installed which would publish data to Wunderground and OpenWeatherMap, and there is no plugin for my PWS nor any plugin which can retrieve PWS data from Wunderground nor OpenWeatherMap.

After some extra research, I am currently using WEEWX to collect data from my PWS and publish them to an MQTT broker and use a Homebridge-MQTT plugin to retrieve the data. But the Homebridge-MQTT plugin's support is limited. For e.g., I cannot retrieve WindGust but only WindSpeed. And unfortunately, my serious coding experience was back in the 90s and it would be too deep of a learning curve for my coding skills to catch up with modern programming paradigms in order to write a plugin for my PWS.