naofireblade / homebridge-weather-plus

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

[Tempest WeatherFlow] v3.3.2 ReferenceError: accumulation is not defined #278

Closed jmissig closed 5 months ago

jmissig commented 5 months ago

Hey all, just updated to v3.3.2 and now I get:

[1/12/2024, 4:25:25 PM] [homebridge-weather-plus] JSON Parse Exception: {"serial_number":"ST-000XXXXX","type":"obs_st","hub_sn":"HB-000XXXXX","obs":[[1705105524,0.00,0.32,1.96,338,3,null,10.63,77.86,4322,0.09,36,0.000000,0,0,0,2.705,1]],"firmware_revision":165} ReferenceError: accumulation is not defined

Node.js v20.9.0 Homebridge v1.7.0

jmissig commented 5 months ago

With debug mode

[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Updating weather from Weatherflow Tempest
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Current Conditions for station 'Weather': {
  AirPressure: null,
  Condition: 'Unknown',
  ConditionCategory: 0,
  Humidity: 78.17,
  ObservationStation: 'ST-000XXXXX',
  ObservationTime: '16:31:14',
  Rain1h: 0,
  RainBool: false,
  RainDay: 0,
  SolarRadiation: 40,
  Temperature: 10.56,
  TemperatureApparent: 9.32000000000005,
  TemperatureMin: 5.46,
  DewPoint: 6.920000000000016,
  UVIndex: 0.1,
  WindDirection: 'WSW',
  WindSpeed: 0.01,
  WindSpeedMax: 1.55,
  BatteryLevel: 85.79710144927535,
  BatteryIsCharging: false,
  WindSpeedLull: 0,
  LightningStrikes: 0,
  LightningAvgDistance: 0,
  LightLevel: 4793,
  TemperatureWetBulb: 8.285863945455644,
  SkySensorBatteryLevel: 100,
  SkySerialNumber: 'ST-000XXXXX',
  SkyFirmware: 165,
  AirSensorBatteryLevel: 100,
  AirSerialNumber: 'AR-',
  AirFirmware: '1.0',
  LightLevelSensorFail: 0,
  HumiditySensorFail: 0,
  TemperatureSensorFail: 0
}
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Setting AirPressure to null
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Setting ConditionCategory to 0
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Setting Humidity to 78.17
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Setting ObservationStation to ST-000XXXXX
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Setting ObservationTime to 16:31:14
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Setting Rain1h to 0
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Setting RainBool to false
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Setting RainDay to 0
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Setting SolarRadiation to 40
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Setting Temperature to 10.56
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Setting TemperatureMin to 5.46
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Setting UVIndex to 0.1
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Setting WindDirection to WSW
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Setting WindSpeed to 0.01
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Setting WindSpeedMax to 1.55
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Setting WindSpeedLull to 0
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Setting LightningStrikes to 0
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Setting LightningAvgDistance to 0
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Setting LightLevel to 4793
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Setting BatteryLevel to 85.79710144927535
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Setting BatteryIsCharging to false
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Setting DewPoint to 6.920000000000016
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Setting TemperatureApparent to 9.32000000000005
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Setting TemperatureWetBulb to 8.285863945455644
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Saving history entry
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] **Fakegato-timer: addData  Weather {
  time: 1705105877.401,
  temp: 10.600000000000001,
  pressure: null,
  humidity: 78
}  immediate:  false
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Persisting AirPressure: null
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Persisting ConditionCategory: 0
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Persisting Humidity: 78.17
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Persisting ObservationStation: ST-000XXXXX
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Persisting ObservationTime: 16:31:14
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Persisting Rain1h: 0
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Persisting RainBool: false
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Persisting RainDay: 0
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Persisting SolarRadiation: 40
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Persisting Temperature: 10.56
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Persisting TemperatureMin: 5.46
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Persisting UVIndex: 0.1
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Persisting WindDirection: WSW
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Persisting WindSpeed: 0.01
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Persisting WindSpeedMax: 1.55
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Persisting WindSpeedLull: 0
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Persisting LightningStrikes: 0
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Persisting LightningAvgDistance: 0
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Persisting LightLevel: 4793
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Persisting BatteryLevel: 85.79710144927535
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Persisting BatteryIsCharging: false
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Persisting DewPoint: 6.920000000000016
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Persisting TemperatureApparent: 9.32000000000005
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Persisting TemperatureWetBulb: 8.285863945455644
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Server got: hub_status
[1/12/2024, 4:31:17 PM] [homebridge-weather-plus] Server got: hub_status
[1/12/2024, 4:31:18 PM] [homebridge-weather-plus] Server got: rapid_wind
[1/12/2024, 4:31:18 PM] [homebridge-weather-plus] Server got: rapid_wind
[1/12/2024, 4:31:21 PM] [homebridge-weather-plus] Server got: rapid_wind
[1/12/2024, 4:31:21 PM] [homebridge-weather-plus] Server got: rapid_wind
[1/12/2024, 4:31:24 PM] [homebridge-weather-plus] Server got: rapid_wind
[1/12/2024, 4:31:24 PM] [homebridge-weather-plus] Server got: rapid_wind
[1/12/2024, 4:31:25 PM] [homebridge-weather-plus] Server got: device_status
[1/12/2024, 4:31:25 PM] [homebridge-weather-plus] Temperature Sensor Fail: 0, Humidity Sensor Fail: 0, Light Level Sensor Fail: 0
[1/12/2024, 4:31:25 PM] [homebridge-weather-plus] Server got: obs_st
[1/12/2024, 4:31:25 PM] [homebridge-weather-plus] JSON Parse Exception: {"serial_number":"ST-000XXXXX","type":"obs_st","hub_sn":"HB-000XXXXX","obs":[[1705105884,0.00,0.18,1.00,236,3,null,10.55,78.20,4841,0.11,40,0.000000,0,0,0,2.703,1]],"firmware_revision":165} ReferenceError: accumulation is not defined
[1/12/2024, 4:31:25 PM] [homebridge-weather-plus] Server got: device_status

I'm aware the Air Pressure is null — my air pressure sensor has failed and I'll eventually get a replacement. But I believe accumulation is a rain readings thing.

jmissig commented 5 months ago

It does look to me, since rain has accumulated today, that the practical result of this bug is failure for rain accumulation to come through to HomeKit.

IMG_0718 IMG_0719

jmissig commented 5 months ago

I'm by no means well-informed about this style of JavaScript, but is it perhaps that line 27 of weatherflow.js should be let accumulation = instead of just accumulation =?

dacarson commented 5 months ago

đŸ‘€ into it

dacarson commented 5 months ago

I suspect changing it to: var accumulation = (not let as it is a variable, not a constant). Though I don't know why it is an issue now.

dacarson commented 5 months ago

Can you file a separate bug to track reporting failed sensors. Currently all I have is: [1/12/2024, 4:31:25 PM] [homebridge-weather-plus] Temperature Sensor Fail: 0, Humidity Sensor Fail: 0, Light Level Sensor Fail: 0 As I am only decoding those first 3, but the rest of the data for failure is there. I just don't decode it.

jmissig commented 5 months ago

I suspect changing it to: var accumulation = (not let as it is a variable, not a constant). Though I don't know why it is an issue now.

Sure, whichever makes sense for y'all. I didn't see it being modified, only set as a result of function call. I just meant it reads to me like the complaint is that the variable/constant is never explicitly defined.

Can you file a separate bug to track reporting failed sensors. Currently all I have is: [1/12/2024, 4:31:25 PM] [homebridge-weather-plus] Temperature Sensor Fail: 0, Humidity Sensor Fail: 0, Light Level Sensor Fail: 0 As I am only decoding those first 3, but the rest of the data for failure is there. I just don't decode it.

Will do. Unfortunately (?) I've already set up my replacement Tempest so I have functioning pressure readings again.

jmissig commented 5 months ago

I suspect changing it to: var accumulation = (not let as it is a variable, not a constant). Though I don't know why it is an issue now.

Looking through old versions of the code, it was previously defined as var accumulation = 0.0; and then incremented in a loop. v3.3.2 changed its first appearance to accumulation = converter.getRainAccumulated… without a var or let.

dacarson commented 5 months ago

Found an additional error now that it has been raining for a while. There is code to handle the case that if several minutes pass between observations, then clear out the old data in the skipped minutes. This was also clearing the last minute, so each time it clicked over a minute, it would erase the last one. This is fixed by clearing just the minutes that are actually skipped, one passed the last recorded to the current minute. I have pushed this change also to the same branch.