nitaybz / homebridge-sensibo-ac

Homebridge plugin for Sensibo - Smart AC Control
GNU General Public License v3.0
71 stars 15 forks source link

TypeError: Cannot read properties of undefined (reading 'C') #133

Closed Pichiasister closed 5 months ago

Pichiasister commented 6 months ago

Hi I'm experiencing error msg on 2.5.0-alpha.2 which prevented Homebridge start normally:

TypeError: Cannot read properties of undefined (reading 'C')
    at AirConditioner.addHeaterCoolerService (/volume1/homebridge/node_modules/homebridge-sensibo-ac/homekit/AirConditioner.js:221:52)
    at new AirConditioner (/volume1/homebridge/node_modules/homebridge-sensibo-ac/homekit/AirConditioner.js:90:9)
    at /volume1/homebridge/node_modules/homebridge-sensibo-ac/sensibo/syncHomeKitCache.js:39:29
    at Array.forEach (<anonymous>)
    at SensiboACPlatform.syncHomeKitCache (/volume1/homebridge/node_modules/homebridge-sensibo-ac/sensibo/syncHomeKitCache.js:12:20)
    at HomebridgeAPI.<anonymous> (/volume1/homebridge/node_modules/homebridge-sensibo-ac/index.js:127:9)

Is there anyone can shed me some light on how to workaround with this?

FYI Using Synology DSM w/ node.js v20.13.0 running on Homebridge v1.8.1, and tried run on docker which didn't seems able to clear the issue.

benwebbbenwebb commented 6 months ago

Hi @Pichiasister

Thanks for raising, I'll take a look. I suspect your unit may not be returning temperatures in C (celsius) for one of the modes.

To assist with the investigation it would be great if you can provide your Sensibo API response, this will show what capabilities etc your unit has.

To gather this, please turn the debug log on, by adding "debug": true in your settings within Homebridge. See here for more details. And then share the large JSON payload that is returned to the Homebridge logs, it should appear just after a log line like the following:

[09/05/2024, 12:39:40 am] Creating GET request to Sensibo API -> [09/05/2024, 12:39:40 am] [SensiboAC] https://home.sensibo.com/api/v2/users/me/pods?fields=id,acState,measurements,location,occupancy,smartMode,motionSensors,filtersCleaning,serial,pureBoostConfig,homekitSupported,remoteCapabilities,room,temperatureUnit,productModel [09/05/2024, 12:39:41 am] [SensiboAC] Successful GET response: ... your JSON here ...

Pichiasister commented 6 months ago
[5/7/2024, 4:55:52 AM] [SensiboAC] Creating GET request to Sensibo API ->
[5/7/2024, 4:55:52 AM] [SensiboAC] https://home.sensibo.com/api/v2/users/me/pods?fields=id,acState,measurements,location,occupancy,smartMode,motionSensors,filtersCleaning,serial,pureBoostConfig,homekitSupported,remoteCapabilities,room,temperatureUnit,productModel
[5/7/2024, 4:55:54 AM] [SensiboAC] Successful GET response:
[5/7/2024, 4:55:54 AM] [SensiboAC] [
    {
        "id": "********",
        "temperatureUnit": "C",
        "room": {
            "uid": "********",
            "name": "Bedroom",
            "icon": "Bedroom",
            "pureBoostConfig": null
        },
        "acState": {
            "timestamp": {
                "time": "2024-05-06T20:55:54.230591Z",
                "secondsAgo": 0
            },
            "on": false,
            "mode": "cool",
            "targetTemperature": 25,
            "temperatureUnit": "C",
            "fanLevel": "auto",
            "swing": "stopped",
            "horizontalSwing": "stopped",
            "light": "on"
        },
        "location": {
            "occupancy": "me",
            "name": "Home",
            "id": "**********"
        },
        "productModel": "airq",
        "serial": "**********",
        "motionSensors": [],
        "filtersCleaning": {
            "acOnSecondsSinceLastFiltersClean": 2166,
            "filtersCleanSecondsThreshold": 1080000,
            "lastFiltersCleanTime": null,
            "shouldCleanFilters": false
        },
        "pureBoostConfig": null,
        "homekitSupported": true,
        "remoteCapabilities": {
            "modes": {
                "cool": {
                    "temperatures": {
                        "F": {
                            "isNative": false,
                            "values": [
                                61,
                                63,
                                64,
                                66,
                                68,
                                70,
                                72,
                                73,
                                75,
                                77,
                                79,
                                81,
                                82,
                                84,
                                86
                            ]
                        },
                        "C": {
                            "isNative": true,
                            "values": [
                                16,
                                17,
                                18,
                                19,
                                20,
                                21,
                                22,
                                23,
                                24,
                                25,
                                26,
                                27,
                                28,
                                29,
                                30
                            ]
                        }
                    },
                    "fanLevels": [
                        "low",
                        "medium",
                        "high",
                        "auto",
                        "strong"
                    ],
                    "swing": [
                        "stopped",
                        "fixedTop",
                        "fixedMiddleTop",
                        "fixedMiddle",
                        "fixedMiddleBottom",
                        "fixedBottom",
                        "rangeTop",
                        "rangeMiddle",
                        "rangeBottom",
                        "rangeFull"
                    ],
                    "horizontalSwing": [
                        "stopped",
                        "fixedLeft",
                        "fixedCenterLeft",
                        "fixedCenter",
                        "fixedCenterRight",
                        "fixedRight",
                        "fixedLeftRight",
                        "rangeFull",
                        "rangeCenter"
                    ],
                    "light": [
                        "on",
                        "off"
                    ]
                },
                "heat": {
                    "temperatures": {
                        "F": {
                            "isNative": false,
                            "values": [
                                46,
                                61,
                                63,
                                64,
                                66,
                                68,
                                70,
                                72,
                                73,
                                75,
                                77,
                                79,
                                81,
                                82,
                                84,
                                86
                            ]
                        },
                        "C": {
                            "isNative": true,
                            "values": [
                                8,
                                16,
                                17,
                                18,
                                19,
                                20,
                                21,
                                22,
                                23,
                                24,
                                25,
                                26,
                                27,
                                28,
                                29,
                                30
                            ]
                        }
                    },
                    "fanLevels": [
                        "low",
                        "medium",
                        "high",
                        "auto",
                        "strong"
                    ],
                    "swing": [
                        "stopped",
                        "fixedTop",
                        "fixedMiddleTop",
                        "fixedMiddle",
                        "fixedMiddleBottom",
                        "fixedBottom",
                        "rangeTop",
                        "rangeMiddle",
                        "rangeBottom",
                        "rangeFull"
                    ],
                    "horizontalSwing": [
                        "stopped",
                        "fixedLeft",
                        "fixedCenterLeft",
                        "fixedCenter",
                        "fixedCenterRight",
                        "fixedRight",
                        "fixedLeftRight",
                        "rangeFull",
                        "rangeCenter"
                    ],
                    "light": [
                        "on",
                        "off"
                    ]
                },
                "fan": {
                    "temperatures": {
                        "F": {
                            "isNative": false,
                            "values": [
                                61,
                                63,
                                64,
                                66,
                                68,
                                70,
                                72,
                                73,
                                75,
                                77,
                                79,
                                81,
                                82,
                                84,
                                86
                            ]
                        },
                        "C": {
                            "isNative": true,
                            "values": [
                                16,
                                17,
                                18,
                                19,
                                20,
                                21,
                                22,
                                23,
                                24,
                                25,
                                26,
                                27,
                                28,
                                29,
                                30
                            ]
                        }
                    },
                    "fanLevels": [
                        "low",
                        "medium",
                        "high",
                        "auto",
                        "strong"
                    ],
                    "swing": [
                        "stopped",
                        "fixedTop",
                        "fixedMiddleTop",
                        "fixedMiddle",
                        "fixedMiddleBottom",
                        "fixedBottom",
                        "rangeTop",
                        "rangeMiddle",
                        "rangeBottom",
                        "rangeFull"
                    ],
                    "horizontalSwing": [
                        "stopped",
                        "fixedLeft",
                        "fixedCenterLeft",
                        "fixedCenter",
                        "fixedCenterRight",
                        "fixedRight",
                        "fixedLeftRight",
                        "rangeFull",
                        "rangeCenter"
                    ],
                    "light": [
                        "on",
                        "off"
                    ]
                },
                "dry": {
                    "temperatures": {
                        "F": {
                            "isNative": false,
                            "values": [
                                61,
                                63,
                                64,
                                66,
                                68,
                                70,
                                72,
                                73,
                                75,
                                77,
                                79,
                                81,
                                82,
                                84,
                                86
                            ]
                        },
                        "C": {
                            "isNative": true,
                            "values": [
                                16,
                                17,
                                18,
                                19,
                                20,
                                21,
                                22,
                                23,
                                24,
                                25,
                                26,
                                27,
                                28,
                                29,
                                30
                            ]
                        }
                    },
                    "fanLevels": [
                        "low"
                    ],
                    "swing": [
                        "stopped",
                        "fixedTop",
                        "fixedMiddleTop",
                        "fixedMiddle",
                        "fixedMiddleBottom",
                        "fixedBottom",
                        "rangeTop",
                        "rangeMiddle",
                        "rangeBottom",
                        "rangeFull"
                    ],
                    "horizontalSwing": [
                        "stopped",
                        "fixedLeft",
                        "fixedCenterLeft",
                        "fixedCenter",
                        "fixedCenterRight",
                        "fixedRight",
                        "fixedLeftRight",
                        "rangeFull",
                        "rangeCenter"
                    ],
                    "light": [
                        "on",
                        "off"
                    ]
                },
                "auto": {
                    "temperatures": {},
                    "fanLevels": [
                        "low",
                        "medium",
                        "high",
                        "auto",
                        "strong"
                    ],
                    "swing": [
                        "stopped",
                        "fixedTop",
                        "fixedMiddleTop",
                        "fixedMiddle",
                        "fixedMiddleBottom",
                        "fixedBottom",
                        "rangeTop",
                        "rangeMiddle",
                        "rangeBottom",
                        "rangeFull"
                    ],
                    "horizontalSwing": [
                        "stopped",
                        "fixedLeft",
                        "fixedCenterLeft",
                        "fixedCenter",
                        "fixedCenterRight",
                        "fixedRight",
                        "fixedLeftRight",
                        "rangeFull",
                        "rangeCenter"
                    ],
                    "light": [
                        "on",
                        "off"
                    ]
                }
            }
        },
        "smartMode": {
            "enabled": false
        },
        "measurements": {
            "time": {
                "time": "2024-05-06T20:55:46.069139Z",
                "secondsAgo": 8
            },
            "temperature": 28.6,
            "humidity": 81.1,
            "feelsLike": 33.9,
            "rssi": -73,
            "motion": false,
            "roomIsOccupied": null,
            "tvoc": 76,
            "co2": 460,
            "iaq": 15
        }
    },
    {
        "id": "********",
        "temperatureUnit": "C",
        "room": {
            "uid": "********",
            "name": "Dining Room",
            "icon": "Diningroom",
            "pureBoostConfig": null
        },
        "acState": {
            "timestamp": {
                "time": "2024-05-06T20:55:54.234369Z",
                "secondsAgo": 0
            },
            "on": false,
            "mode": "cool",
            "targetTemperature": 27,
            "temperatureUnit": "C",
            "fanLevel": "auto",
            "swing": "stopped",
            "horizontalSwing": "stopped",
            "light": "on"
        },
        "location": {
            "occupancy": "me",
            "name": "Home",
            "id": "**********"
        },
        "productModel": "skyv2",
        "serial": "*********",
        "motionSensors": [],
        "filtersCleaning": {
            "acOnSecondsSinceLastFiltersClean": 24,
            "filtersCleanSecondsThreshold": 1080000,
            "lastFiltersCleanTime": {
                "time": "2024-05-06T10:56:23Z",
                "secondsAgo": 35971
            },
            "shouldCleanFilters": false
        },
        "pureBoostConfig": null,
        "homekitSupported": false,
        "remoteCapabilities": {
            "modes": {
                "cool": {
                    "temperatures": {
                        "F": {
                            "isNative": false,
                            "values": [
                                61,
                                63,
                                64,
                                66,
                                68,
                                70,
                                72,
                                73,
                                75,
                                77,
                                79,
                                81,
                                82,
                                84,
                                86
                            ]
                        },
                        "C": {
                            "isNative": true,
                            "values": [
                                16,
                                17,
                                18,
                                19,
                                20,
                                21,
                                22,
                                23,
                                24,
                                25,
                                26,
                                27,
                                28,
                                29,
                                30
                            ]
                        }
                    },
                    "fanLevels": [
                        "low",
                        "medium",
                        "high",
                        "auto",
                        "strong"
                    ],
                    "swing": [
                        "stopped",
                        "fixedTop",
                        "fixedMiddleTop",
                        "fixedMiddle",
                        "fixedMiddleBottom",
                        "fixedBottom",
                        "rangeTop",
                        "rangeMiddle",
                        "rangeBottom",
                        "rangeFull"
                    ],
                    "horizontalSwing": [
                        "stopped",
                        "fixedLeft",
                        "fixedCenterLeft",
                        "fixedCenter",
                        "fixedCenterRight",
                        "fixedRight",
                        "fixedLeftRight",
                        "rangeFull",
                        "rangeCenter"
                    ],
                    "light": [
                        "on",
                        "off"
                    ]
                },
                "heat": {
                    "temperatures": {
                        "F": {
                            "isNative": false,
                            "values": [
                                46,
                                61,
                                63,
                                64,
                                66,
                                68,
                                70,
                                72,
                                73,
                                75,
                                77,
                                79,
                                81,
                                82,
                                84,
                                86
                            ]
                        },
                        "C": {
                            "isNative": true,
                            "values": [
                                8,
                                16,
                                17,
                                18,
                                19,
                                20,
                                21,
                                22,
                                23,
                                24,
                                25,
                                26,
                                27,
                                28,
                                29,
                                30
                            ]
                        }
                    },
                    "fanLevels": [
                        "low",
                        "medium",
                        "high",
                        "auto",
                        "strong"
                    ],
                    "swing": [
                        "stopped",
                        "fixedTop",
                        "fixedMiddleTop",
                        "fixedMiddle",
                        "fixedMiddleBottom",
                        "fixedBottom",
                        "rangeTop",
                        "rangeMiddle",
                        "rangeBottom",
                        "rangeFull"
                    ],
                    "horizontalSwing": [
                        "stopped",
                        "fixedLeft",
                        "fixedCenterLeft",
                        "fixedCenter",
                        "fixedCenterRight",
                        "fixedRight",
                        "fixedLeftRight",
                        "rangeFull",
                        "rangeCenter"
                    ],
                    "light": [
                        "on",
                        "off"
                    ]
                },
                "fan": {
                    "temperatures": {
                        "F": {
                            "isNative": false,
                            "values": [
                                61,
                                63,
                                64,
                                66,
                                68,
                                70,
                                72,
                                73,
                                75,
                                77,
                                79,
                                81,
                                82,
                                84,
                                86
                            ]
                        },
                        "C": {
                            "isNative": true,
                            "values": [
                                16,
                                17,
                                18,
                                19,
                                20,
                                21,
                                22,
                                23,
                                24,
                                25,
                                26,
                                27,
                                28,
                                29,
                                30
                            ]
                        }
                    },
                    "fanLevels": [
                        "low",
                        "medium",
                        "high",
                        "auto",
                        "strong"
                    ],
                    "swing": [
                        "stopped",
                        "fixedTop",
                        "fixedMiddleTop",
                        "fixedMiddle",
                        "fixedMiddleBottom",
                        "fixedBottom",
                        "rangeTop",
                        "rangeMiddle",
                        "rangeBottom",
                        "rangeFull"
                    ],
                    "horizontalSwing": [
                        "stopped",
                        "fixedLeft",
                        "fixedCenterLeft",
                        "fixedCenter",
                        "fixedCenterRight",
                        "fixedRight",
                        "fixedLeftRight",
                        "rangeFull",
                        "rangeCenter"
                    ],
                    "light": [
                        "on",
                        "off"
                    ]
                },
                "dry": {
                    "temperatures": {
                        "F": {
                            "isNative": false,
                            "values": [
                                61,
                                63,
                                64,
                                66,
                                68,
                                70,
                                72,
                                73,
                                75,
                                77,
                                79,
                                81,
                                82,
                                84,
                                86
                            ]
                        },
                        "C": {
                            "isNative": true,
                            "values": [
                                16,
                                17,
                                18,
                                19,
                                20,
                                21,
                                22,
                                23,
                                24,
                                25,
                                26,
                                27,
                                28,
                                29,
                                30
                            ]
                        }
                    },
                    "fanLevels": [
                        "low"
                    ],
                    "swing": [
                        "stopped",
                        "fixedTop",
                        "fixedMiddleTop",
                        "fixedMiddle",
                        "fixedMiddleBottom",
                        "fixedBottom",
                        "rangeTop",
                        "rangeMiddle",
                        "rangeBottom",
                        "rangeFull"
                    ],
                    "horizontalSwing": [
                        "stopped",
                        "fixedLeft",
                        "fixedCenterLeft",
                        "fixedCenter",
                        "fixedCenterRight",
                        "fixedRight",
                        "fixedLeftRight",
                        "rangeFull",
                        "rangeCenter"
                    ],
                    "light": [
                        "on",
                        "off"
                    ]
                },
                "auto": {
                    "temperatures": {},
                    "fanLevels": [
                        "low",
                        "medium",
                        "high",
                        "auto",
                        "strong"
                    ],
                    "swing": [
                        "stopped",
                        "fixedTop",
                        "fixedMiddleTop",
                        "fixedMiddle",
                        "fixedMiddleBottom",
                        "fixedBottom",
                        "rangeTop",
                        "rangeMiddle",
                        "rangeBottom",
                        "rangeFull"
                    ],
                    "horizontalSwing": [
                        "stopped",
                        "fixedLeft",
                        "fixedCenterLeft",
                        "fixedCenter",
                        "fixedCenterRight",
                        "fixedRight",
                        "fixedLeftRight",
                        "rangeFull",
                        "rangeCenter"
                    ],
                    "light": [
                        "on",
                        "off"
                    ]
                }
            }
        },
        "smartMode": {
            "enabled": false
        },
        "measurements": {
            "time": {
                "time": "2024-05-06T20:55:20.147615Z",
                "secondsAgo": 34
            },
            "temperature": 25.8,
            "humidity": 98,
            "feelsLike": 25.8,
            "rssi": -62
        }
    }
]
[5/7/2024, 4:55:54 AM] [SensiboAC] Device: ********, Model: airq, airConditionerIsNew: true
[5/7/2024, 4:55:54 AM] [SensiboAC] Capabilities, temperature scales available, C: true F: true
[5/7/2024, 4:55:54 AM] [SensiboAC] Mode: COOL, Capabilities: 
[5/7/2024, 4:55:54 AM] [SensiboAC] {
  homeAppEnabled: true,
  temperatures: { C: { min: 16, max: 30 }, F: { min: 61, max: 86 } },
  fanSpeeds: [ 'low', 'medium', 'high', 'auto', 'strong' ],
  autoFanSpeed: true,
  verticalSwing: true,
  horizontalSwing: true,
  light: true
}
[5/7/2024, 4:55:54 AM] [SensiboAC] Capabilities, temperature scales available, C: true F: true
[5/7/2024, 4:55:54 AM] [SensiboAC] Mode: HEAT, Capabilities: 
[5/7/2024, 4:55:54 AM] [SensiboAC] {
  homeAppEnabled: true,
  temperatures: { C: { min: 8, max: 30 }, F: { min: 46, max: 86 } },
  fanSpeeds: [ 'low', 'medium', 'high', 'auto', 'strong' ],
  autoFanSpeed: true,
  verticalSwing: true,
  horizontalSwing: true,
  light: true
}
[5/7/2024, 4:55:54 AM] [SensiboAC] Capabilities, temperature scales available, C: true F: true
[5/7/2024, 4:55:54 AM] [SensiboAC] Mode: FAN, Capabilities: 
[5/7/2024, 4:55:54 AM] [SensiboAC] {
  temperatures: { C: { min: 16, max: 30 }, F: { min: 61, max: 86 } },
  fanSpeeds: [ 'low', 'medium', 'high', 'auto', 'strong' ],
  autoFanSpeed: true,
  verticalSwing: true,
  horizontalSwing: true,
  light: true
}
[5/7/2024, 4:55:54 AM] [SensiboAC] Capabilities, temperature scales available, C: true F: true
[5/7/2024, 4:55:54 AM] [SensiboAC] Mode: DRY, Capabilities: 
[5/7/2024, 4:55:54 AM] [SensiboAC] {
  temperatures: { C: { min: 16, max: 30 }, F: { min: 61, max: 86 } },
  fanSpeeds: [ 'low' ],
  autoFanSpeed: false,
  verticalSwing: true,
  horizontalSwing: true,
  light: true
}
[5/7/2024, 4:55:54 AM] [SensiboAC] Capabilities, temperature scales available, C: false F: false
[5/7/2024, 4:55:54 AM] [SensiboAC] Mode: AUTO, Capabilities: 
[5/7/2024, 4:55:54 AM] [SensiboAC] {
  homeAppEnabled: true,
  fanSpeeds: [ 'low', 'medium', 'high', 'auto', 'strong' ],
  autoFanSpeed: true,
  verticalSwing: true,
  horizontalSwing: true,
  light: true
}
[5/7/2024, 4:55:54 AM] [SensiboAC] Bedroom AC - Adding HeaterCoolerService
[5/7/2024, 4:55:54 AM] [SensiboAC] Bedroom AC - Adding CurrentTemperature to HeaterCooler
[5/7/2024, 4:55:54 AM] [SensiboAC] Bedroom AC - Adding TemperatureDisplayUnits to HeaterCooler
[5/7/2024, 4:55:54 AM] [SensiboAC] Bedroom AC - Props not set for TemperatureDisplayUnits, proceeding with defaults
[5/7/2024, 4:55:54 AM] [SensiboAC] Bedroom AC - Adding CurrentRelativeHumidity to HeaterCooler
[5/7/2024, 4:55:54 AM] [SensiboAC] Bedroom AC - Props not set for CurrentRelativeHumidity, proceeding with defaults
[5/7/2024, 4:55:54 AM] [SensiboAC] Bedroom AC - Adding CurrentHeaterCoolerState to HeaterCooler
[5/7/2024, 4:55:54 AM] [SensiboAC] Bedroom AC - Props not set for CurrentHeaterCoolerState, proceeding with defaults
[5/7/2024, 4:55:54 AM] TypeError: Cannot read properties of undefined (reading 'C')
    at AirConditioner.addHeaterCoolerService (/volume1/homebridge/node_modules/homebridge-sensibo-ac/homekit/AirConditioner.js:221:52)
    at new AirConditioner (/volume1/homebridge/node_modules/homebridge-sensibo-ac/homekit/AirConditioner.js:90:9)
    at /volume1/homebridge/node_modules/homebridge-sensibo-ac/sensibo/syncHomeKitCache.js:39:29
    at Array.forEach (<anonymous>)
    at SensiboACPlatform.syncHomeKitCache (/volume1/homebridge/node_modules/homebridge-sensibo-ac/sensibo/syncHomeKitCache.js:12:20)
    at HomebridgeAPI.<anonymous> (/volume1/homebridge/node_modules/homebridge-sensibo-ac/index.js:127:9)
benwebbbenwebb commented 6 months ago

Thanks @Pichiasister

As I thought, your Auto mode is returning no temperatures. I’ll look to add a fix and release a new alpha to prevent the crash.

Follow-up question, on the devices remote (not Sensibo), when you are in Auto mode, can you set a desired temperature? Heat, Cool, Dry and Fan all have them (in Sensibo), but not Auto.

If you can set a temperature in Auto on your remote, then you need to set an alternate remote code in Sensibo (Sensibo Support can assist). That should also prevent the crash.

Pichiasister commented 6 months ago

Hi @benwebbbenwebb sorry that I've checked and it seems no temperatures can be set in the AUTO mode. Btw I've exclude AUTO mode and has avoided crashes.

benwebbbenwebb commented 6 months ago

Hi @Pichiasister

Yes, I believe that should work, great idea!

modesToExclude is the setting name.

Add "modesToExclude": ["AUTO"] to the settings JSON config.

benwebbbenwebb commented 6 months ago

Hi @Pichiasister

I've released v2.5.0-alpha.3 to fix the issue you've mentioned here, when you have some time would you mind updating and re-enabling AUTO mode to confirm that the issue is resolved?

Pichiasister commented 5 months ago

Hi thanks @benwebbbenwebb, I've updated to v2.5.0-alpha.3 with AUTO mode on, and this has been fixed.