iklein99 / homebridge-smartthings

This is a plugin to Homebridge to connect your Smartthings network into Apple Home Kit.
Apache License 2.0
160 stars 55 forks source link

Crash loop reading heatingSetpoint from thermostats #267

Open aaronyeung opened 2 months ago

aaronyeung commented 2 months ago

Describe The Bug: Crashes child bridge every approximate 15 seconds with this error:

TypeError: Cannot read properties of undefined (reading 'heatingSetpoint')
    at ThermostatService.getTargetTemperature (/homebridge/node_modules/homebridge-smartthings-ik/src/services/thermostatService.ts:238:65)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

https://github.com/iklein99/homebridge-smartthings/blob/44894ec3063e723e757fb4e1608eb9d39c32bb20/src/services/thermostatService.ts#L238

To Reproduce:

Not sure when this broke, probably in the last 2 to 6 weeks? It's been working flawlessly for a long time (many months).

I tried updating to the latest homebridge and docker image also as they were out of date slightly, but it still occurs. Sorry, I forgot to note down the version I was upgrading from, I went into the UI and clicked update on Homebridge, Homebridge UI and selected the latest versions. For Docker image, I pulled the latest tag and restarted the container (looks like it was running for about 109 days)

Expected behavior:

Not crashing :)

Logs:

[8/26/2024, 11:08:55 PM] [Smartthings Plug (IK)] Garage Entry Thermostat polling...
[8/26/2024, 11:08:55 PM] [Smartthings Plug (IK)] Received getCurrentTemperature for Garage Entry Thermostat
[8/26/2024, 11:08:55 PM] [Smartthings Plug (IK)] Refreshing status for Garage Entry Thermostat - current timestamp is 0
[8/26/2024, 11:08:55 PM] [Smartthings Plug (IK)] Status query already in progress for Garage Entry Thermostat.  Waiting...
[8/26/2024, 11:08:55 PM] [Smartthings Plug (IK)] Garage Entry Thermostat command or request is waiting...
[8/26/2024, 11:08:55 PM] [Smartthings Plug (IK)] Received GetTargetTemperature for Garage Entry Thermostat
[8/26/2024, 11:08:55 PM] [Smartthings Plug (IK)] Received getTargetHeatingCoolingState for Garage Entry Thermostat
TypeError: Cannot read properties of undefined (reading 'heatingSetpoint')
    at ThermostatService.getTargetTemperature (/homebridge/node_modules/homebridge-smartthings-ik/src/services/thermostatService.ts:238:65)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
[8/26/2024, 11:08:56 PM] [Smartthings Plug (IK)] Child bridge process ended
[8/26/2024, 11:08:56 PM] [Smartthings Plug (IK)] Process Ended. Code: 1, Signal: null
[8/26/2024, 11:09:12 PM] [Smartthings Plug (IK)] Upstairs Bathroom Thermostat polling...
[8/26/2024, 11:09:13 PM] [Smartthings Plug (IK)] Received getCurrentHeatingCoolingState() event for Upstairs Bathroom Thermostat
[8/26/2024, 11:09:13 PM] [Smartthings Plug (IK)] Thermostat Upstairs Bathroom Thermostat does not support thermostatMode.  Returning OFF
[8/26/2024, 11:09:13 PM] [Smartthings Plug (IK)] Received getTargetHeatingCoolingState for Upstairs Bathroom Thermostat
[8/26/2024, 11:09:13 PM] [Smartthings Plug (IK)] Upstairs Bathroom Thermostat value updated.
[8/26/2024, 11:09:13 PM] [Smartthings Plug (IK)] Study Room Thermostat polling...
[8/26/2024, 11:09:13 PM] [Smartthings Plug (IK)] Received getCurrentTemperature for Study Room Thermostat
[8/26/2024, 11:09:13 PM] [Smartthings Plug (IK)] Refreshing status for Study Room Thermostat - current timestamp is 0
[8/26/2024, 11:09:13 PM] [Smartthings Plug (IK)] Status query already in progress for Study Room Thermostat.  Waiting...
[8/26/2024, 11:09:13 PM] [Smartthings Plug (IK)] Study Room Thermostat command or request is waiting...
[8/26/2024, 11:09:13 PM] [Smartthings Plug (IK)] Received GetTargetTemperature for Study Room Thermostat
[8/26/2024, 11:09:13 PM] [Smartthings Plug (IK)] Received getTargetHeatingCoolingState for Study Room Thermostat
TypeError: Cannot read properties of undefined (reading 'heatingSetpoint')
    at ThermostatService.getTargetTemperature (/homebridge/node_modules/homebridge-smartthings-ik/src/services/thermostatService.ts:238:65)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at runNextTicks (node:internal/process/task_queues:64:3)
    at processTimers (node:internal/timers:509:9)
[8/26/2024, 11:09:30 PM] [Smartthings Plug (IK)] Thermostat Living Room Thermostat does not support thermostatMode.  Returning OFF
[8/26/2024, 11:09:30 PM] [Smartthings Plug (IK)] Received getTargetHeatingCoolingState for Living Room Thermostat
[8/26/2024, 11:09:30 PM] [Smartthings Plug (IK)] Living Room Thermostat value updated.
[8/26/2024, 11:09:30 PM] [Smartthings Plug (IK)] Motion Sensor polling...
[8/26/2024, 11:09:30 PM] [Smartthings Plug (IK)] Received getSensorState() event for Motion Sensor
[8/26/2024, 11:09:30 PM] [Smartthings Plug (IK)] Refreshing status for Motion Sensor - current timestamp is 0
[8/26/2024, 11:09:30 PM] [Smartthings Plug (IK)] Status query already in progress for Motion Sensor.  Waiting...
[8/26/2024, 11:09:30 PM] [Smartthings Plug (IK)] Motion Sensor command or request is waiting...
[8/26/2024, 11:09:30 PM] [Smartthings Plug (IK)] Living Room Thermostat polling...
[8/26/2024, 11:09:30 PM] [Smartthings Plug (IK)] Received getCurrentTemperature for Living Room Thermostat
[8/26/2024, 11:09:30 PM] [Smartthings Plug (IK)] Refreshing status for Living Room Thermostat - current timestamp is 0
[8/26/2024, 11:09:30 PM] [Smartthings Plug (IK)] Status query already in progress for Living Room Thermostat.  Waiting...
[8/26/2024, 11:09:30 PM] [Smartthings Plug (IK)] Living Room Thermostat command or request is waiting...
[8/26/2024, 11:09:30 PM] [Smartthings Plug (IK)] Received GetTargetTemperature for Living Room Thermostat
[8/26/2024, 11:09:30 PM] [Smartthings Plug (IK)] Received getTargetHeatingCoolingState for Living Room Thermostat
TypeError: Cannot read properties of undefined (reading 'heatingSetpoint')
    at ThermostatService.getTargetTemperature (/homebridge/node_modules/homebridge-smartthings-ik/src/services/thermostatService.ts:238:65)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
[8/26/2024, 11:09:30 PM] [Smartthings Plug (IK)] Child bridge process ended
[8/26/2024, 11:09:30 PM] [Smartthings Plug (IK)] Process Ended. Code: 1, Signal: null

Plugin Config:

{
    "bridge": {
        "name": "Homebridge",
        "username": "redacted",
        "port": 51842,
        "pin": "redacted",
        "advertiser": "bonjour-hap"
    },
    "accessories": [],
    "platforms": [
        {
            "name": "Config",
            "port": 8080,
            "auth": "form",
            "theme": "auto",
            "tempUnits": "c",
            "lang": "auto",
            "platform": "config"
        },
        {
            "name": "Wemo",
            "debug": false,
            "disableDiscovery": false,
            "discoveryInterval": 30,
            "disableDeviceLogging": false,
            "disablePlugin": false,
            "noMotionTimer": 60,
            "doorOpenTimer": 20,
            "makerTypes": [
                {
                    "makerTimer": 20
                }
            ],
            "platform": "BelkinWeMo"
        },
        {
            "name": "Wemo",
            "mode": "auto",
            "platform": "Wemo"
        },
        {
            "name": "Smartthings Plug (IK)",
            "BaseURL": "https://api.smartthings.com/v1/",
            "AccessToken": "redacted",
            "GarageDoorMaxPoll": 40,
            "PollLocksSeconds": 10,
            "PollDoorsSeconds": 10,
            "PollSensorsSeconds": 5,
            "PollSwitchesAndLightsSeconds": 10,
            "PollWindowShadesSeconds": 10,
            "ExposeHumiditySensorForAirConditioners": false,
            "OptionalModeForAirConditioners": "None",
            "_bridge": {
                "username": "redacted",
                "port": 43573
            },
            "platform": "HomeBridgeSmartThings"
        }
    ],
    "disabledPlugins": [
        "homebridge-platform-wemo"
    ]
}

Screenshots:

Environment:

aaronyeung commented 2 months ago

For what it's worth, I reverted to v1.5.20 and it stopped crashing. I also noticed in the Apple Home app that all the thermostats were set to 10.0 deg C, and Auto mode (all the thermostats are baseboard electric, so are only off/on, or heat/eco, depending on the model)

iklein99 commented 2 months ago

I can fix this. Give me a few days and I'll have it addressed in a new version.