OpenWonderLabs / homebridge-switchbot

The Homebridge SwitchBot plugin allows you to access your SwitchBot Device(s) from HomeKit. Homebridge.
https://openwonderlabs.github.io/homebridge-switchbot/
ISC License
241 stars 51 forks source link

Bug: Warning "expected valid finite number and received "NaN" (number)" #1007

Open ukiews opened 1 month ago

ukiews commented 1 month ago

Describe the Bug

I'm happy to report that BLE curtain 3 control is now working with the latest version of plugin and homebridge on my Pi4. However, there is a warning that keeps getting generated:

[7/15/2024, 12:02:11 PM] [SwitchBot] Curtain3: Right-Curtain 3 TargetPostion: 89 sent over SwitchBot BLE,  sent successfully
[7/15/2024, 12:02:14 PM] [SwitchBot] Curtain3: Right-Curtain 3 TargetPostion: 89 sent over SwitchBot BLE,  sent successfully
[7/15/2024, 12:02:14 PM] [SwitchBot] Curtain3: Right-Curtain 3 Checking Status ...
[7/15/2024, 12:02:19 PM] [@switchbot/homebridge-switchbot] This plugin generated a warning from the characteristic 'Current Position': characteristic value expected valid finite number and received "NaN" (number). See https://homebridge.io/w/JtMGR for more info.
[7/15/2024, 12:02:19 PM] [@switchbot/homebridge-switchbot] This plugin generated a warning from the characteristic 'Target Position': characteristic value expected valid finite number and received "NaN" (number). See https://homebridge.io/w/JtMGR for more info.
[7/15/2024, 12:02:24 PM] [SwitchBot] Curtain3: Right-Curtain 3 ad: {
  "id": "eb8c4803381a",
  "address": "eb:8c:48:03:38:1a",
  "rssi": -79,
  "serviceData": {
    "model": "{",
    "modelName": "WoCurtain3",
    "modelFriendlyName": "Curtain 3",
    "calibration": true,
    "battery": 45,
    "inMotion": true,
    "position": 39,
    "lightLevel": 1,
    "deviceChain": 1
  }
}

This seems to be related to the curtain controller no responding immediately to the plugin status request. It seems there needs to be a bit more delay added before the status is requested... Or "TargetPosition" is not being properly reported.

Device and Model

Raspberry Pi 4

Node.js Version

20.11.0

NPM Version

10.2.4

Homebridge Version

1.8.3

Homebridge Switchbot Plugin Version

3.6.0

Homebridge Config UI X Plugin Version

4.56.4

Operating System

Raspbian

donavanbecker commented 1 month ago

Can you try the latest beta:

npm version

Click here to find out how to install Beta

ukiews commented 1 month ago

Still getting the same error. I also needed to update the 1.8.4 beta version of HB per plugin warning.

[7/16/2024, 10:36:23 AM] [SwitchBot] Curtain3: RightCurtain TargetPostion: 40 sent over SwitchBot BLE,  sent successfully
[7/16/2024, 10:36:26 AM] [@switchbot/homebridge-switchbot] This plugin generated a warning from the characteristic 'Current Position': characteristic value expected valid finite number and received "NaN" (number). See https://homebridge.io/w/JtMGR for more info.

Another issue I'm seeing is sending a command to two devices at the same time. I have a left and right curtain on the same window in "Room 1." If I instruct siri to "close Room 1" only one curtain will close. Only after saying it the second time will the other curtain close. The same goes for automations to open and close "Room 1" curtains for sunrise and sunset. Only one will initially respond. Sometimes left, sometimes right. However, individual control works just fine. I'm wondering if this is an issue with the BLE signal and if there needs to be a slight delay when the signal is sent out to control multiple devices at the same time. Otherwise, it might flood the BLE receiver on the curtain 3 (?)

Example:

[7/16/2024, 10:38:38 AM] [SwitchBot] Curtain3: RightCurtain TargetPostion: 100 sent over SwitchBot BLE,  sent successfully
[7/16/2024, 10:38:40 AM] [SwitchBot] Curtain3: LeftCurtain TypeError: Cannot read properties of undefined (reading 'runToPos')
[7/16/2024, 10:38:40 AM] [SwitchBot] Curtain3: LeftCurtain Retrying
[7/16/2024, 10:38:41 AM] [SwitchBot] Curtain3: LeftCurtain TypeError: Cannot read properties of undefined (reading 'runToPos')
[7/16/2024, 10:38:41 AM] [SwitchBot] Curtain3: LeftCurtain Retrying
[7/16/2024, 10:38:42 AM] [SwitchBot] Curtain3: LeftCurtain TypeError: Cannot read properties of undefined (reading 'runToPos')
[7/16/2024, 10:38:42 AM] [SwitchBot] Curtain3: LeftCurtain Retrying
[7/16/2024, 10:38:43 AM] [SwitchBot] Curtain3: LeftCurtain TypeError: Cannot read properties of undefined (reading 'runToPos')
[7/16/2024, 10:38:43 AM] [SwitchBot] Curtain3: LeftCurtain Retrying
[7/16/2024, 10:38:44 AM] [SwitchBot] Curtain3: LeftCurtain TypeError: Cannot read properties of undefined (reading 'runToPos')
[7/16/2024, 10:38:44 AM] [SwitchBot] Curtain3: LeftCurtain Retrying
[7/16/2024, 10:38:45 AM] [SwitchBot] Curtain3: LeftCurtain TypeError: Cannot read properties of undefined (reading 'runToPos')
[7/16/2024, 10:38:45 AM] [SwitchBot] Curtain3: LeftCurtain Retrying
[7/16/2024, 10:38:46 AM] [SwitchBot] Curtain3: LeftCurtain TypeError: Cannot read properties of undefined (reading 'runToPos')
[7/16/2024, 10:38:46 AM] [SwitchBot] Curtain3: LeftCurtain Retrying
[7/16/2024, 10:38:47 AM] [SwitchBot] Curtain3: LeftCurtain TypeError: Cannot read properties of undefined (reading 'runToPos')
[7/16/2024, 10:38:47 AM] [SwitchBot] Curtain3: LeftCurtain Retrying
[7/16/2024, 10:38:48 AM] [SwitchBot] Curtain3: LeftCurtain TypeError: Cannot read properties of undefined (reading 'runToPos')
[7/16/2024, 10:38:48 AM] [SwitchBot] Curtain3: LeftCurtain Retrying
[7/16/2024, 10:38:49 AM] [SwitchBot] Curtain3: LeftCurtain TypeError: Cannot read properties of undefined (reading 'runToPos')
[7/16/2024, 10:38:49 AM] [SwitchBot] Curtain3: LeftCurtain Retrying
[7/16/2024, 10:38:50 AM] [SwitchBot] Curtain3: LeftCurtain failed BLEpushChanges with BLE Connection, Error Message: "Cannot read properties of undefined (reading 'runToPos')"
dnicolson commented 1 month ago

I'm also seeing these warnings still on v3.7.0:

[23/07/2024, 20:11:41] [SwitchBot] Curtain: Curtain TargetPostion: 0 sent over SwitchBot BLE,  sent successfully
[23/07/2024, 20:11:51] [@switchbot/homebridge-switchbot] This plugin generated a warning from the characteristic 'Current Position': characteristic value expected valid finite number and received "NaN" (number). See https://homebridge.io/w/JtMGR for more info.
[23/07/2024, 20:11:51] [@switchbot/homebridge-switchbot] This plugin generated a warning from the characteristic 'Target Position': characteristic value expected valid finite number and received "NaN" (number). See https://homebridge.io/w/JtMGR for more info.
donavanbecker commented 1 month ago

Can you try the latest beta:

npm version

Click here to find out how to install Beta

ukiews commented 1 month ago

Still having the same issues where only one curtain will open/close if the command is sent to open both at once.

In this case below, I first open each one independently, then issue a command to close both. First scenario is successful, second only Left curtain closes.

[7/24/2024, 1:33:44 PM] [SwitchBot] Curtain3: LeftCurtain TargetPostion: 100 sent over SwitchBot BLE,  sent successfully
[7/24/2024, 1:34:28 PM] [SwitchBot] Curtain3: RightCurtain TargetPostion: 100 sent over SwitchBot BLE,  sent successfully
[7/24/2024, 1:34:44 PM] [SwitchBot] Curtain3: LeftCurtain TargetPostion: 0 sent over SwitchBot BLE,  sent successfully
[7/24/2024, 1:34:45 PM] [SwitchBot] Curtain3: RightCurtain Checking Status ...
[7/24/2024, 1:34:47 PM] [SwitchBot] Curtain3: RightCurtain TypeError: Cannot read properties of undefined (reading 'runToPos')
[7/24/2024, 1:34:47 PM] [SwitchBot] Curtain3: RightCurtain Retrying
[7/24/2024, 1:34:48 PM] [SwitchBot] Curtain3: RightCurtain TypeError: Cannot read properties of undefined (reading 'runToPos')
[7/24/2024, 1:34:48 PM] [SwitchBot] Curtain3: RightCurtain Retrying
[7/24/2024, 1:34:49 PM] [SwitchBot] Curtain3: RightCurtain TypeError: Cannot read properties of undefined (reading 'runToPos')
[7/24/2024, 1:34:49 PM] [SwitchBot] Curtain3: RightCurtain Retrying
[7/24/2024, 1:34:50 PM] [SwitchBot] Curtain3: RightCurtain TypeError: Cannot read properties of undefined (reading 'runToPos')
[7/24/2024, 1:34:50 PM] [SwitchBot] Curtain3: RightCurtain Retrying
[7/24/2024, 1:34:51 PM] [SwitchBot] Curtain3: RightCurtain TypeError: Cannot read properties of undefined (reading 'runToPos')
[7/24/2024, 1:34:51 PM] [SwitchBot] Curtain3: RightCurtain Retrying
[7/24/2024, 1:34:52 PM] [SwitchBot] Curtain3: RightCurtain TypeError: Cannot read properties of undefined (reading 'runToPos')
[7/24/2024, 1:34:52 PM] [SwitchBot] Curtain3: RightCurtain Retrying
[7/24/2024, 1:34:53 PM] [SwitchBot] Curtain3: RightCurtain TypeError: Cannot read properties of undefined (reading 'runToPos')
[7/24/2024, 1:34:53 PM] [SwitchBot] Curtain3: RightCurtain Retrying
[7/24/2024, 1:34:54 PM] [SwitchBot] Curtain3: RightCurtain TypeError: Cannot read properties of undefined (reading 'runToPos')
[7/24/2024, 1:34:54 PM] [SwitchBot] Curtain3: RightCurtain Retrying
[7/24/2024, 1:34:55 PM] [SwitchBot] Curtain3: RightCurtain TypeError: Cannot read properties of undefined (reading 'runToPos')
[7/24/2024, 1:34:55 PM] [SwitchBot] Curtain3: RightCurtain Retrying
[7/24/2024, 1:34:56 PM] [SwitchBot] Curtain3: RightCurtain TypeError: Cannot read properties of undefined (reading 'runToPos')
[7/24/2024, 1:34:56 PM] [SwitchBot] Curtain3: RightCurtain Retrying
[7/24/2024, 1:34:57 PM] [SwitchBot] Curtain3: RightCurtain TypeError: Cannot read properties of undefined (reading 'runToPos')
[7/24/2024, 1:34:57 PM] [SwitchBot] Curtain3: RightCurtain Retrying
[7/24/2024, 1:34:57 PM] [@switchbot/homebridge-switchbot] This plugin generated a warning from the characteristic 'Current Position': characteristic value expected valid finite number and received "NaN" (number). See https://homebridge.io/w/JtMGR for more info.
[7/24/2024, 1:34:57 PM] [@switchbot/homebridge-switchbot] This plugin generated a warning from the characteristic 'Target Position': characteristic value expected valid finite number and received "NaN" (number). See https://homebridge.io/w/JtMGR for more info.
[7/24/2024, 1:34:58 PM] [SwitchBot] Curtain3: RightCurtain TypeError: Cannot read properties of undefined (reading 'runToPos')
[7/24/2024, 1:34:58 PM] [SwitchBot] Curtain3: RightCurtain Retrying
[7/24/2024, 1:34:59 PM] [SwitchBot] Curtain3: RightCurtain TypeError: Cannot read properties of undefined (reading 'runToPos')
[7/24/2024, 1:34:59 PM] [SwitchBot] Curtain3: RightCurtain Retrying
[7/24/2024, 1:35:00 PM] [SwitchBot] Curtain3: RightCurtain TypeError: Cannot read properties of undefined (reading 'runToPos')
[7/24/2024, 1:35:00 PM] [SwitchBot] Curtain3: RightCurtain Retrying
[7/24/2024, 1:35:01 PM] [SwitchBot] Curtain3: RightCurtain TypeError: Cannot read properties of undefined (reading 'runToPos')
[7/24/2024, 1:35:01 PM] [SwitchBot] Curtain3: RightCurtain Retrying
[7/24/2024, 1:35:02 PM] [@switchbot/homebridge-switchbot] This plugin generated a warning from the characteristic 'Current Position': characteristic value expected valid finite number and received "NaN" (number). See https://homebridge.io/w/JtMGR for more info.
[7/24/2024, 1:35:02 PM] [@switchbot/homebridge-switchbot] This plugin generated a warning from the characteristic 'Target Position': characteristic value expected valid finite number and received "NaN" (number). See https://homebridge.io/w/JtMGR for more info.
[7/24/2024, 1:35:02 PM] [SwitchBot] Curtain3: RightCurtain failed BLEpushChanges with BLE Connection, Error Message: "Cannot read properties of undefined (reading 'runToPos')"
dnicolson commented 1 month ago

The original issue appears to be fixed in v3.7.1-beta.3.

ukiews commented 1 month ago

The original issue appears to be fixed in v3.7.1-beta.3.

The same "Nan" and 'runToPos' errors are still appearing.

ukiews commented 1 month ago

Same issues with latest beta7

ukiews commented 2 weeks ago

@donavanbecker any update on this? It's so close to working smoothly!

donavanbecker commented 2 weeks ago

Sorry not yet.