Skip to content

Commit

Permalink
Support Tempest Weatherflow weather station (#262)
Browse files Browse the repository at this point in the history
* Add Tempest WeatherFlow as a weather source

Changes per file.
api/smartweather.js:
1. WeatherFlow broadcasts UDP packets on the local network. This adds a UDP listener for events, parses them and stores them in the relative parameters.
2. This file requires UDP support so it requires (dgram)
3. Also make use of standard weather formulas for some calculations (weather-formulas)

Index.api:
1. There is no geo location for the weather station is it is assumed to be in the Home
2. UDP packets are broadcast on the local network and picked up by the plugin. WeatherFlow broadcasts new data every minute, so the update interval is fixed to 1 minute.
3. As a local wether station, there are a couple of new characteristics that it has:
    1. Light level (Illuminance) is available. As light level is a standard HomeKit characteristic, I coded it in the same style as humidity.
    2. Weatherflow devices are battery powered, some with solar to charge. I added a battery characteristic for this data source too, similar to light level.
4.

util/compatibility.js:
1. The default min/max for light level are too restricted for outdoor light levels (lux), increase the range to support outside light levels
2. Add another temperature object to support WetBulb temperature

util/characteristics.js
1. There are four additional characteristics that I believe are interesting to show.
    1. Data reported by the WeatherFlow hardware. LightningStrikes (count of lightning strikes in the area), LightningAvgDistance (the average distance of the strikes) and WindLull (Idle wind speed).
    2. TemperatureWetBulb. Calculated characteristic from humidity and temperature. Found it to be useful when viewing the current weather status.

accessories/currentConditions.js
1. Added support for the HomeKit characteristics LightLevel and Battery

config.schema.json
1. Add Tempest WeatherFlow as an option.

README.md
1. Add information about Tempest WeatherFlow option

* Correct WeatherFlow links

Add the correct links to the ReadMe

* Properly support condition detail

Support the condition detail setting.

* Add support for RainBool characteristic

RainBool reports if it is raining right now.

* Update Tempest battery percent

Use the details published about Tempest battery levels to better calculate the current battery percentage

* Update compatibility.js

LightLevel is not a compatible type, it is actually a native type. Remove it from the list of compatible types.

Issue was reported here:
#262 (comment)

* Update package.json

Add the dependency on weather-formulas that support for Tempest weather station requires. As reported here:
#262 (comment)

* Update package.json

Fix typo when adding new dependency.

* Persist current values

Persist the current values so that when HomeBridge is restarted it doesn't take up to a minute to get the values. Also this will ensure that the current Daily Rainfall total is close to being correct. Rain over the last hour is lost still during a restart.
Also adding Tempest/Weather Flow support  is a significant update to the plugin bump the version to 3.3

* Update apis/smartweather.js

Co-authored-by: Wim Leers <[email protected]>

* Rename to tempest

Change internal weather station type token from smartweather to tempest.

* Add comment for wet-bulb

Add a link for more information on what wet-bulb temperature is.

* Incorporate feedback

Add a header block with a general description of the API

Change attribution to Weatherflow Tempest.

Separate calculated Characteristics from measured Characteristics.

Update some comments

Add a TODO for forecasts

* Save and restore rainfall over last minute

Don't assume that the function getHourlyAccumulatedRain is called every minute. Rather pass in the observation time and store the rainfall reported for that observation time. Clear any skipped minutes.

Save the rainfall array with a time to live of an hour.

* Remove unused code

Wet bulb temperature is not listed as a compatibility Service in the compatibility array, therefore it won't appear when Apple Home or Apple Home (plus Eve) is selected in Settings. This is ok as it is just a calculated value.

* Adjust max value for wet-bulb temp

The maximum observed wet bulb temperature is in the high 30s according to Wikipedia, therefore override the Temperature Service maximum value from 100 to 40.

* Update Changelog to include changes in new version

New version of plugin now supports Weatherflow's tempest weather station

* Update apis/smartweather.js

Co-authored-by: Wim Leers <[email protected]>

* Update README.md

Co-authored-by: Wim Leers <[email protected]>

* Update index.js

Co-authored-by: Wim Leers <[email protected]>

* Update apis/smartweather.js

This is only an issue with the old/depricated 'AIR' weather station module. The current Tempest weather station does not include this field.

Co-authored-by: Wim Leers <[email protected]>

* Update apis/smartweather.js

I'll also change the corresponding 'getItemSync()'

Co-authored-by: Wim Leers <[email protected]>

* Rename class to TempestAPI

Rename to TempestAPI
Revert to persisting array via loop

* Update weatherflow.js

* Update README.md

Update readme and add table.

* Update README.md

Fix numbered list below weather service so that 7 and 8 appear on their own lines.

---------

Co-authored-by: Wim Leers <[email protected]>
  • Loading branch information
dacarson and wimleers authored Jul 25, 2023
1 parent de9214d commit 33ba5cc
Show file tree
Hide file tree
Showing 9 changed files with 659 additions and 22 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,7 @@
* Fixed logging

## 3.2.11
* Fixed crash when weather report is empty
* Fixed crash when weather report is empty

## 3.3
* Add support for WeatherFlow's Tempest weather station, that reports real time weather data over local network.
45 changes: 32 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Feel free to leave any feedback [here](https://github.com/naofireblade/homebridg

## Features
- Get [27 observation and forecast](#observations-and-forecasts) values for up to 7 days
- Choose from 3 different weather [services](#choose-your-weather-service)
- Choose from 4 different weather [services](#choose-your-weather-service)
- Add [multiple](#multiple-stations-configuration) locations/services
- See the weather [history](#screenshots) in the Eve App
- See all values, translations and [icons](#screenshots) in the Eve App
Expand All @@ -29,22 +29,23 @@ Feel free to leave any feedback [here](https://github.com/naofireblade/homebridg

This plugin supports multiple weather services. Each has its own advantages. The following table shows a comparison to help you to choose one.

| | Dark Sky <sup>[1](#a1)</sup> | OpenWeatherMap (recommended) | Weather Underground <sup>[2](#a2)</sup> |
|----------------------------|:----------------------------------------:|:-----------------------------------------------------:|:----------------------------------------------------:|
| Current observation values | 19 | 15 | 12 |
| Forecast values | 22 | 18<sup>[6](#a6)</sup> | 0 |
| Forecast days | today + 7 | today + 7<sup>[6](#a6)</sup> | 0 |
| Location | geo-coordinates | city name, geo-coordinates | station id |
| Personal weather stations | :x: | :heavy_check_mark: | :heavy_check_mark: |
| Free | :heavy_check_mark: (only existing users) | :heavy_check_mark: | :heavy_check_mark: (only if you own a station) |
| Register | closed | [here](https://home.openweathermap.org/users/sign_up) | [here](https://www.wunderground.com/member/api-keys) |
| | Dark Sky <sup>[1](#a1)</sup> | OpenWeatherMap (recommended) | Weather Underground <sup>[2](#a2)</sup> | Tempest weather station <sup>[7](#a7)</sup> |
|----------------------------|:----------------------------------------:|:-----------------------------------------------------:|:----------------------------------------------------:|:----------------------------------------------------:|
| Current observation values | 19 | 15 | 12 | 20 |
| Forecast values | 22 | 18<sup>[6](#a6)</sup> | 0 | 0 |
| Forecast days | today + 7 | today + 7<sup>[6](#a6)</sup> | 0 | 0<sup>[8](#a8)</sup> |
| Location | geo-coordinates | city name, geo-coordinates | station id | local |
| Personal weather stations | :x: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| Free | :heavy_check_mark: (only existing users) | :heavy_check_mark: | :heavy_check_mark: (only if you own a station) | :heavy_check_mark: (you need the station) |
| Register | closed | [here](https://home.openweathermap.org/users/sign_up) | [here](https://www.wunderground.com/member/api-keys) | - |

*You can add more services easily by forking the project and submitting a pull request for a new api file.*

> <b name="a1">1</b> [It is no longer possible](https://blog.darksky.net/dark-sky-has-a-new-home/) to register as a new user for Dark Sky. Existing users can use the service [until 31 Dec 2022](https://blog.darksky.net).
> <b name="a2">2</b> You can use the weather underground service only if you can provide weather data from your own station in exchange.
> <b name="a6">6</b> uv-index, dew point, sunrise, sunset are only available after registering for the new OpenWeatherMap One Call API 3.0, which is free as well. The old API also has 4 instead of 7 forecast days.
> <b name="a6">6</b> uv-index, dew point, sunrise, sunset are only available after registering for the new OpenWeatherMap One Call API 3.0, which is free as well. The old API also has 4 instead of 7 forecast days.
> <b name="a7">7</b> [Weatherflow's Tempest](https://weatherflow.com) is a physical weather station that can be installed in your home. Current weather conditions are published on home network.
> <b name="a8">8</b> Weatherflow does provide an API to retrieve forecast. That capability has not been added to this plugin.
## Installation

Expand All @@ -55,7 +56,7 @@ This plugin supports multiple weather services. Each has its own advantages. The

## Observations and Forecasts

The following observation and forecast values can be displayed and used in HomeKit rules.
The following observation and forecast values can be displayed and used in HomeKit rules, though not all weather sources provide all values below.
I recommend using the Eve app to see all the values. However, if you don't want to use a 3rd party app, use the [compatibility mode](#compatibility) `home` for displaying most values in the Apple home app.

- Air Pressure
Expand All @@ -77,11 +78,16 @@ I recommend using the Eve app to see all the values. However, if you don't want
- Temperature Min
- Temperature Max
- Temperature Apparent
- Wet Bulb Temperature
- UV-Index
- Visibility
- Light level
- Wind Direction
- Wind Speed
- Wind Speed Maximum
- Wind Speed Lull
- Lightning Avg Distance
- Lightning Strikes
- *Observation Time*
- *Observation Station*
- *Day of the forecast*
Expand Down Expand Up @@ -183,6 +189,18 @@ Used to indicate Weewx version. The homekit plugin requires an location field t
```


### Tempest Weatherflow

The [Tempest Weatherflow](https://weatherflow.com/tempest-home-weather-system/) is a local weather reporting device that publishes the current weather on the local network via [UDP packets](https://weatherflow.github.io/Tempest/api/). Data is broadcast once per minute, so the Interval setting is ignored. The physical station can only provide the current weather. Future forecasts are available with this weather source, though has not been implemented yet. This uses data published on your local network for the current weather, and therefore runs fine without an internet connection.

```json
"platforms": [
{
"platform": "WeatherPlus",
"service": "tempest"
}
]
```

## Advanced Configuration

Expand Down Expand Up @@ -330,6 +348,7 @@ Many thanks to the awesome contributors who support the project with pull reques
- [Zerosignal84](https://github.com/Zerosignal84) for fixing the uv index range
- [Vincent Niehues](https://github.com/vniehues) for adding rain chance characteristic to the OpenWeatherMap api
- [Hendrik-Cv](https://github.com/Hendrik-Cv) for updating the OpenWeatherMap api to v3.0
- [David Carson](https://github.com/dacarson) for integration with Tempest WeatherFlow

Also thanks to numerous people helping with the docs.

Expand Down
41 changes: 40 additions & 1 deletion accessories/currentConditions.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ function CurrentConditionsWeatherAccessory(platform, stationIndex)
this.log.debug("Separating humidity into an extra service");
this.HumidityService = new Service.HumiditySensor("Humidity")
}

// Separate light level into a single service if configurated
if (this.config.extraLightLevel)
{
this.log.debug("Separating light level into an extra service");
this.LightLevelService = new Service.LightSensor("Light Level");
this.LightLevelService.getCharacteristic(Characteristic.CurrentAmbientLightLevel)
.setProps({
minValue: 0,
maxValue: 200000
});
}
}


Expand Down Expand Up @@ -89,6 +101,33 @@ function CurrentConditionsWeatherAccessory(platform, stationIndex)
{
this.CurrentConditionsService.addCharacteristic(Characteristic.CurrentRelativeHumidity);
}
// Use separate service for light level if configured
else if (this.config.compatibility === "eve" && name === "LightLevel" && this.config.extraLightLevel)
{
//
}
// illuminance is a general apple home kit characteristic
else if (name === "LightLevel")
{
this.CurrentConditionsService.addCharacteristic(Characteristic.CurrentAmbientLightLevel);
// Override the defaults for light level as default is too low for daylight
this.CurrentConditionsService.getCharacteristic(Characteristic.CurrentAmbientLightLevel)
.setProps({
minValue: 0,
maxValue: 200000,
minStep: 1
});
}
// Battery level is a general apple home kit characteristic
else if (name === "BatteryLevel")
{
this.CurrentConditionsService.addCharacteristic(Characteristic.BatteryLevel);
}
// Battery level is a general apple home kit characteristic
else if (name === "BatteryIsCharging")
{
this.CurrentConditionsService.addCharacteristic(Characteristic.ChargingState);
}
// Add everything else as a custom characteristic to the temperature service
else
{
Expand Down Expand Up @@ -133,4 +172,4 @@ CurrentConditionsWeatherAccessory.prototype = {
{
return [this.informationService, this.CurrentConditionsService, this.historyService].concat(compatibility.getServices(this));
}
};
};
Loading

0 comments on commit 33ba5cc

Please sign in to comment.