Skip to content

Commit

Permalink
Merge pull request chasenicholl#28 from chasenicholl/release.4.1.1
Browse files Browse the repository at this point in the history
Release.4.1.1
  • Loading branch information
chasenicholl authored Oct 30, 2024
2 parents bf82880 + bd1ac5a commit b8aab6a
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/).

## v4.1.1
* Update README.md to correctly display "Tempest" logo.
* Update README.md to include `station_id` in "Local API Config Example".
* Added _optional_ multicast enablement with dgram socket reuseAddr. Will reuse the address, even if another process has already bound a socket on it, but only one socket can receive the data.
* Added new optional configuration `local_api_shared` to support turning on the above.

## v4.1.0
* Confirm plug-in operation with Homebridge 2.0.0. Updated package.json per homebridge instructions.
* Update `config.schema.json` to require `station_id` for both `http_api` and `local_api`. Update associated code in `platform.ts`.
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<table align="center">
<tr>
<td><img src="https://user-images.githubusercontent.com/3979615/78016493-9b89a800-7396-11ea-9442-414ad9ffcdf2.png" width="200"></td>
<td><img src="https://weatherflow.com/wp-content/uploads/2016/05/Tempest-powered-by-01.svg" width="250"></td>
<td><img src="https://t9s9z3m3.rocketcdn.me/wp-content/uploads/2016/05/Tempest-powered-by-01.svg" width="250"></td>
</tr>
</table>

Expand Down Expand Up @@ -40,6 +40,7 @@ Local API is now supported which requires no authentication. If you choose to us
- `token`: _(Required for HTTP API)_ Oauth2 Personal Use Token, create via your tempestwx account.
- `station_id`: _(Required for HTTP API)_ The station ID you are pulling weather data from.
- `interval`: _(Required for HTTP API)_ How often to poll the Tempest REST API. Default 10 seconds. Minimum every second.
- `local_api_shared`: _(Optional)_ enable multicast. Will reuse the address, even if another process has already bound a socket on it, but only one socket can receive the data. Default: False.
- `sensors`: _(Required)_ An array of sensors to create. This is dynamic incase you want to target different temperature or wind speed attributes.
- `sensors[].name`: _(Required)_ Display name of Sensor in Apple Home.
- `sensors[].sensor_type`: _(Required)_ The type of Home Sensor to create. There are 6 options ["Temperature Sensor", "Light Sensor", "Humidity Sensor", "Fan", "Motion Sensor", "Occupancy Sensor"].
Expand Down Expand Up @@ -70,15 +71,17 @@ sensor_type `{2}` | value_key | metric units | std units | additional_properties

`{3}` Reference Wiki for details on how to view Occupancy Sensor values with iOS 16.x and MacOS Ventura 13.x.

`{4}` <b><u>NOTE:</u></b> There is a current limitation with v3.0.0 of the plug-in in that HomeKit accessory names are set when the accessory is <u>initially</u> added and cannot be dynamically updated. The accessories are correctly displayed and updated in the Homebridge "Accessories" tab of the webpage interface. Occupancy sensors `trigger_value` status is correctly displayed in both HomeKit and Homebridge.
`{4}` <b><u>NOTE:</u></b> There is a current limitation with v3.0.0 and v4.0.0 of the plug-in in that HomeKit accessory names are set when the accessory is <u>initially</u> added and cannot be dynamically updated. The accessories are correctly displayed and updated in the Homebridge "Accessories" tab of the webpage interface. Occupancy sensors `trigger_value` status is correctly displayed in both HomeKit and Homebridge.

### Local API Config Example

```json
{
"name": "WeatherFlow Tempest Platform",
"local_api": true,
"station_id": 10000,
"units": "Standard",
"local_api_shared": false,
"sensors": [
{
"name": "Temperature",
Expand Down Expand Up @@ -179,6 +182,7 @@ sensor_type `{2}` | value_key | metric units | std units | additional_properties
"station_id": 10000,
"interval": 10,
"units": "Standard",
"local_api_shared": false,
"sensors": [
{
"name": "Temperature",
Expand Down
6 changes: 6 additions & 0 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
"required": true,
"default": true
},
"local_api_shared": {
"title": "Share the Local API UDP port with other processes",
"type": "boolean",
"required": false,
"default": false
},
"token": {
"title": "Token",
"type": "string",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"private": false,
"displayName": "Homebridge WeatherFlow Tempest",
"name": "homebridge-weatherflow-tempest",
"version": "4.1.0",
"version": "4.1.1",
"description": "Exposes WeatherFlow Tempest Station data as Temperature Sensors, Light Sensors, Humidity Sensors and Fan Sensors (for Wind Speed).",
"license": "Apache-2.0",
"repository": {
Expand Down
8 changes: 7 additions & 1 deletion src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ export class WeatherFlowTempestPlatform implements DynamicPlatformPlugin {
this.log.info('local_api config parameter not set defaulting to false.');
}

// Backwards compatible config check for new local_api_shared variable
if (!('local_api_shared' in this.config)) {
this.config['local_api_shared'] = false;
this.log.info('local_api_shared config parameter not set defaulting to false.');
}

// For new install with local_api === true (Local API), token and station_id will be undefined and are not required

// For local_api === false (HTTP API), make sure token is provided
Expand Down Expand Up @@ -112,7 +118,7 @@ export class WeatherFlowTempestPlatform implements DynamicPlatformPlugin {

try {
this.log.info('Using Tempest Local API.');
this.tempestSocket = new TempestSocket(this.log);
this.tempestSocket = new TempestSocket(this.log, this.config.local_api_shared);
this.tempestSocket.start();

// Hold thread for first message and set values
Expand Down
4 changes: 2 additions & 2 deletions src/tempest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ export class TempestSocket {
private data: object | undefined;
private tempest_battery_level: number;

constructor(log: Logger) {
constructor(log: Logger, reuse_address: boolean) {

this.log = log;
this.data = undefined;
this.tempest_battery_level = 0;
this.s = dgram.createSocket('udp4');
this.s = dgram.createSocket({ type: 'udp4', reuseAddr: reuse_address });

this.log.info('TempestSocket initialized.');

Expand Down

0 comments on commit b8aab6a

Please sign in to comment.