diff --git a/README.md b/README.md index 642d6b7..c4c3297 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,9 @@ Adds support for WeatherFlow's Smart Weather Station -First version, with quite limited functionality. -Upcoming versions will support more measurement values and flow triggers. - # Changelog +* 0.3.0 Flow triggers added for brightness above/below specified threshold. * 0.2.1 Fixed bug in rain sensor reading. For some reason, the daily rain still reports no value using the WeatherFlow's UDP API. * 0.2.0 Added more sensor readings on both Air and Sky devices. Air and Sky devices must be removed and added again in order for the new sensor readings to show up. Flow triggers and conditions added for rain started and wind above/below specified threshold. * 0.1.1 Increased the time searching for Air and Sky devices when pairing. diff --git a/app.json b/app.json index f60763a..e43e631 100644 --- a/app.json +++ b/app.json @@ -1,6 +1,6 @@ { "id": "com.weatherflow.smartweatherstation", - "version": "0.2.1", + "version": "0.3.0", "compatibility": ">=1.5.0", "sdk": 2, "brandColor": "#3077BF", @@ -11,7 +11,9 @@ "en": "Adds support for WeatherFlow's Smart Weather Station" }, "tags": { - "en": [ "weatherflow smart weather temperature rain wind sensor" ] + "en": [ + "weatherflow smart weather temperature rain wind sensor" + ] }, "category": [ "climate" @@ -26,29 +28,14 @@ "email": "joel@fjorden.se" }, "contributing": { - "donate": { - "paypal": { - "username": "willoowisp" - } - } - }, + "donate": { + "paypal": { + "username": "willoowisp" + } + } + }, "homeyCommunityTopicId": 9816, "capabilities": { - "measure_rain_day": { - "type": "number", - "title": { - "en": "Rain 24h" - }, - "getable": true, - "setable": false, - "decimals": 0, - "units": { - "en": "mm" - }, - "uiComponent": "sensor", - "uiQuickAction": false, - "icon": "/assets/measure_rain_day_capability.svg" - }, "measure_uv": { "type": "number", "title": { @@ -131,18 +118,18 @@ }, "pair": [ { - "id": "list_devices", - "template": "list_devices", - "navigation": { - "next": "add_devices" - }, - "options": { - "singular": false - } + "id": "list_devices", + "template": "list_devices", + "navigation": { + "next": "add_devices" + }, + "options": { + "singular": false + } }, { - "id": "add_devices", - "template": "add_devices" + "id": "add_devices", + "template": "add_devices" } ] }, @@ -154,11 +141,10 @@ "class": "sensor", "capabilities": [ "measure_rain", - "measure_rain_day", + "measure_luminance", "measure_wind_strength", - "measure_wind_angle", + "measure_wind_angle", "measure_gust_strength", - "measure_luminance", "measure_uv", "measure_solarradiation", "measure_voltage" @@ -169,18 +155,18 @@ }, "pair": [ { - "id": "list_devices", - "template": "list_devices", - "navigation": { - "next": "add_devices" - }, - "options": { - "singular": false - } + "id": "list_devices", + "template": "list_devices", + "navigation": { + "next": "add_devices" + }, + "options": { + "singular": false + } }, { - "id": "add_devices", - "template": "add_devices" + "id": "add_devices", + "template": "add_devices" } ] } @@ -210,7 +196,7 @@ "type": "device", "name": "sky", "filter": "driver_id=sky" - }, + }, { "type": "range", "name": "wind_speed", @@ -232,7 +218,7 @@ "type": "device", "name": "sky", "filter": "driver_id=sky" - }, + }, { "type": "range", "name": "wind_speed", @@ -262,14 +248,14 @@ { "id": "is_windy", "title": { - "en": "It !{{is|isn't}} blowing heavy" + "en": "It !{{is|isn't}} windy" }, "args": [ { "type": "device", "name": "sky", "filter": "driver_id=sky" - }, + }, { "type": "range", "name": "wind_speed", diff --git a/drivers/sky/driver.js b/drivers/sky/driver.js index b1e51d3..f5ae73a 100644 --- a/drivers/sky/driver.js +++ b/drivers/sky/driver.js @@ -13,7 +13,7 @@ class SkyDriver extends Homey.Driver { async onPairListDevices(data, callback) { await this._sleep(20000); - const airDevices = Homey.app.devices.filter(device => device.name.startsWith("SK")); + const skyDevices = Homey.app.devices.filter(device => device.name.startsWith("SK")); // Required properties: // "data": { "id": "abcd" }, @@ -28,7 +28,7 @@ class SkyDriver extends Homey.Driver { // "store": { "foo": "bar" }, // "settings": { "my_setting": "my_value" }, - callback(null, airDevices); + callback(null, skyDevices); } updateObservations(message) { @@ -58,12 +58,6 @@ class SkyDriver extends Homey.Driver { // Rain accumulated (mm) const rain = values[3]; device.setCapabilityValue('measure_rain', rain).catch(this.error); - // Local Day Rain Accumulation (mm) - let dayRain = values[11]; - if (!dayRain) { - dayRain = 0; - } - device.setCapabilityValue('measure_rain_day', dayRain).catch(this.error); // Solar radiation: (W/m^2) device.setCapabilityValue('measure_solarradiation', values[10]).catch(this.error); // Battery: (V) @@ -71,14 +65,15 @@ class SkyDriver extends Homey.Driver { // Wind lull: {values[4]} m/s // Report interval: {values[9]} minutes + // Local Day Rain Accumulation: {values[11]} mm - always null with UDP API // Precipitation type: {values[12]} // Wind sample interval: {values[13]} seconds - this._isRaining = rain > 0; + this._updateRainFlow(rain); } rainStartEvent(message) { - console.log(`Sky rain start: ${JSON.stringify(message)}`); + // console.log(`Sky rain start: ${JSON.stringify(message)}`); const device = this._getDevice(message.serial_number); if (!device) @@ -90,10 +85,10 @@ class SkyDriver extends Homey.Driver { const timestamp = values[0]; - this._isRaining = true; - let tokens = {} - let state = { 'serial_number': message.serialNumber } + let state = {} + + this._isRaining = true; this._rainStartTrigger.trigger(device, tokens, state) .then() @@ -116,7 +111,7 @@ class SkyDriver extends Homey.Driver { const windDirection = values[2]; let tokens = {} - let state = { 'serial_number': message.serialNumber, 'wind_speed': windSpeed, 'last_triggered_wind_speed': this._lastRapidWindSpeed } + let state = { 'wind_speed': windSpeed } this._windAboveTrigger.trigger(device, tokens, state) .then() @@ -126,34 +121,21 @@ class SkyDriver extends Homey.Driver { .then() .catch(this.error) - this._lastRapidWindSpeed = windSpeed; + this._lastWindSpeed = windSpeed; } _initFlows() { - this._rainStartTrigger = new Homey.FlowCardTriggerDevice('rain_start').register(); + this._rainStartTrigger = new Homey.FlowCardTriggerDevice('rain_start') + .register(); this._windAboveTrigger = new Homey.FlowCardTriggerDevice('wind_above') .registerRunListener((args, state) => { - // console.log(`Evaluate wind trigger condition ${state.last_triggered_wind_speed} <= ${args.wind_speed} && ${state.wind_speed} > ${args.wind_speed}...`); - - // args parameter, this is the user input - // state parameter, as passed in trigger() - - // console.log(args.sky); - // console.log(args.sky.data); - - // TODO: Only resolve true for correct serial number. - - // If true, this flow should run - return Promise.resolve(state.last_triggered_wind_speed <= args.wind_speed && state.wind_speed > args.wind_speed); + return Promise.resolve(state.wind_speed > args.wind_speed); }).register(); this._windBelowTrigger = new Homey.FlowCardTriggerDevice('wind_below') .registerRunListener((args, state) => { - // TODO: Only resolve true for correct serial number. - - // If true, this flow should run - return Promise.resolve(state.last_triggered_wind_speed > args.wind_speed && state.wind_speed <= args.wind_speed); + return Promise.resolve(state.wind_speed <= args.wind_speed); }).register(); this._rainCondition = new Homey.FlowCardCondition('is_raining') @@ -165,12 +147,14 @@ class SkyDriver extends Homey.Driver { this._windCondition = new Homey.FlowCardCondition('is_windy') .register() .registerRunListener((args, state) => { - - // console.log(`Wind condition run: ${args}, ${state} for ${args.my_device}`); - return Promise.resolve(this._lastRapidWindSpeed > args.wind_speed); + return Promise.resolve(this._lastWindSpeed > args.wind_speed); }); } + _updateRainFlow(rain) { + this._isRaining = rain > 0; + } + _getDevice(deviceSerialNumber) { const device = this.getDevice({ "serialNumber": deviceSerialNumber }); if (device instanceof Error) {