naofireblade / homebridge-weather-plus

A comprehensive weather plugin for homebridge.
MIT License
311 stars 61 forks source link

[Tempest Weatherflow] When station offline: 1) history repeats last measurement forever, 2) one warning per minute in log #275

Closed wimleers closed 4 months ago

wimleers commented 7 months ago

My Tempest Weatherflow local weather station has been down for a few weeks now. Root cause: dead battery due to gloomy Belgian winter skies, that are so densely gray you'd believe the sun has been replaced by a single shitty TL-light 🤣😭

The WiFi-connected base station is still live though, so this Homebridge plugin still continues to communicate with it just fine.

Two bugs occur:

  1. the Eve "fakegato" history views continue to show the last measurement in perpetuity. Whereas in reality, they should report "no data".
  2. a JS error occurs for the RainBool characteristic, despite no new data being available:
    [12/6/2023, 2:22:11 AM] [homebridge-weather-plus] This plugin generated a warning from the characteristic 'Rain': characteristic value expected boolean and received undefined. See https://homebridge.io/w/JtMGR for more info.
    [12/6/2023, 2:23:12 AM] [homebridge-weather-plus] This plugin generated a warning from the characteristic 'Rain': characteristic value expected boolean and received undefined. See https://homebridge.io/w/JtMGR for more info.
    [12/6/2023, 2:24:12 AM] [homebridge-weather-plus] This plugin generated a warning from the characteristic 'Rain': characteristic value expected boolean and received undefined. See https://homebridge.io/w/JtMGR for more info.
    [12/6/2023, 2:25:12 AM] [homebridge-weather-plus] This plugin generated a warning from the characteristic 'Rain': characteristic value expected boolean and received undefined. See https://homebridge.io/w/JtMGR for more info.
    [12/6/2023, 2:26:12 AM] [homebridge-weather-plus] This plugin generated a warning from the characteristic 'Rain': characteristic value expected boolean and received undefined. See https://homebridge.io/w/JtMGR for more info.

Seems like a trivial edge case to fix 😊

If I enable Homebridge's debug mode, I get this:

[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Updating weather from Weatherflow Tempest
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Current Conditions for station 'Now': {
  AirPressure: 1009.2,
  Condition: 'Unknown',
  ConditionCategory: 0,
  Humidity: 87.9,
  ObservationStation: 'ST-00109058',
  ObservationTime: '04:35:52',
  Rain1h: 0,
  RainDay: 0,
  SolarRadiation: 0,
  Temperature: 11.41,
  TemperatureApparent: 11.260000000000048,
  TemperatureMin: 11.41,
  DewPoint: 9.480000000000018,
  UVIndex: 0,
  WindDirection: 'N',
  WindSpeed: 0,
  WindSpeedMax: 0,
  BatteryLevel: 0.5797101449275033,
  BatteryIsCharging: false,
  WindSpeedLull: 0,
  LightningStrikes: 0,
  LightningAvgDistance: 0,
  LightLevel: 0,
  TemperatureWetBulb: 10.091900266983295,
  SkySensorBatteryLevel: 100,
  SkySerialNumber: 'SK-',
  SkyFirmware: '1.0',
  AirSensorBatteryLevel: 100,
  AirSerialNumber: 'AR-',
  AirFirmware: '1.0',
  LightLevelSensorFail: 0,
  HumiditySensorFail: 0,
  TemperatureSensorFail: 0
}
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Setting AirPressure to 1009.2
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Setting ConditionCategory to 0
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Setting Humidity to 87.9
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Setting ObservationStation to ST-00109058
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Setting ObservationTime to 04:35:52
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Setting Rain1h to 0
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Setting RainBool to undefined
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] This plugin generated a warning from the characteristic 'Rain': characteristic value expected boolean and received undefined. See https://homebridge.io/w/JtMGR for more info.
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Error: 
    at CustomCharacteristic.RainBool.Characteristic.characteristicWarning (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:3011:105)
    at CustomCharacteristic.RainBool.Characteristic.validateUserInput (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:2887:12)
    at CustomCharacteristic.RainBool.Characteristic.setValue (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:2229:20)
    at TemperatureSensor.Service.setCharacteristic (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Service.ts:758:35)
    at WeatherPlusPlatform.saveCharacteristic (/usr/local/lib/node_modules/homebridge-weather-plus/index.js:473:24)
    at /usr/local/lib/node_modules/homebridge-weather-plus/index.js:273:15
    at Array.forEach (<anonymous>)
    at /usr/local/lib/node_modules/homebridge-weather-plus/index.js:271:39
    at Array.forEach (<anonymous>)
    at /usr/local/lib/node_modules/homebridge-weather-plus/index.js:258:27
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Setting RainDay to 0
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Setting SolarRadiation to 0
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Setting Temperature to 11.41
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Setting TemperatureMin to 11.41
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Setting UVIndex to 0
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Setting WindDirection to N
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Setting WindSpeed to 0
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Setting WindSpeedMax to 0
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Setting WindSpeedLull to 0
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Setting LightningStrikes to 0
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Setting LightningAvgDistance to 0
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Setting LightLevel to 0
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Setting BatteryLevel to 0.5797101449275033
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Setting BatteryIsCharging to false
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Setting DewPoint to 9.480000000000018
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Setting TemperatureApparent to 11.260000000000048
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Setting TemperatureWetBulb to 10.091900266983295
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Saving history entry
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] **Fakegato-timer: addData  Now {
  time: 1701937604.17,
  temp: 11.400000000000006,
  pressure: 1009,
  humidity: 88
}  immediate:  false
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Persisting AirPressure: 1009.2
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Persisting ConditionCategory: 0
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Persisting Humidity: 87.9
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Persisting ObservationStation: ST-00109058
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Persisting ObservationTime: 04:35:52
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Persisting Rain1h: 0
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Persisting RainBool: undefined
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Persisting RainDay: 0
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Persisting SolarRadiation: 0
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Persisting Temperature: 11.41
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Persisting TemperatureMin: 11.41
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Persisting UVIndex: 0
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Persisting WindDirection: N
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Persisting WindSpeed: 0
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Persisting WindSpeedMax: 0
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Persisting WindSpeedLull: 0
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Persisting LightningStrikes: 0
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Persisting LightningAvgDistance: 0
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Persisting LightLevel: 0
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Persisting BatteryLevel: 0.5797101449275033
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Persisting BatteryIsCharging: false
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Persisting DewPoint: 9.480000000000018
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Persisting TemperatureApparent: 11.260000000000048
[12/7/2023, 9:26:44 AM] [homebridge-weather-plus] Persisting TemperatureWetBulb: 10.091900266983295

(Note that that ObservationTime: '04:35:52', corresponds to the very last observation it received, a few weeks ago. So that is sort of accurate.)

wimleers commented 7 months ago

Looking at https://github.com/naofireblade/homebridge-weather-plus/blob/master/apis/weatherflow.js, I don't understand how it could ever get set to undefined by the actual Weatherflow plugin though:

These are the only 3 lines modifying RainBool. So that suggests the bug lies in the overarching infrastructure? 🤔

wimleers commented 6 months ago

/cc @dacarson

dacarson commented 6 months ago

Looking at the debug information above, all the values are set to their defaults, so it seems that we have not received an initial set of data from the weather station. Which makes sense from your description - the battery is dead. Looking through the set of initialization data in Weaatherflow.js, I see that RainBool is never set to a default value. A value is only set when a set of data is received. There is an easy fix, to initialize it.

I have the simple fix on my branch, as well as a number of other fixes. Can you remind me how to get the changes onto the main branch? https://github.com/naofireblade/homebridge-weather-plus/compare/master...dacarson:homebridge-weather-plus:master

wimleers commented 6 months ago

I have the simple fix on my branch, as well as a number of other fixes. Can you remind me how to get the changes onto the main branch?

Sure thing!

Here you go: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork ← this is AFAICT the exact thing you need.

General docs are at https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request 😊

dacarson commented 6 months ago

Thanks! Pull request created

wimleers commented 6 months ago

Found 2 bugs in the changed code, fixes proposed at #276! 👍

dacarson commented 5 months ago

Fixed and landed in #276

wimleers commented 5 months ago

Now we just need a new release — could you tag one, @naofireblade? 🙏

naofireblade commented 5 months ago

Done

dacarson commented 4 months ago

Maybe we can close this one now?

wimleers commented 4 months ago

+1!