mitch7391 / homebridge-cmd4-AdvantageAir

Catered shell script to integrate air conditioner control units by Advantage Air into HomeKit using the plug-in homebridge-cmd4.
MIT License
38 stars 5 forks source link

[Bug] v3.10.0 - Config with new options failure #88

Closed bigevtaylor closed 11 months ago

bigevtaylor commented 11 months ago

Log when HomeBridge restarts after upgrading the plugin and running config creator with " Use "Fan" accessory with integrated temperature and myZone switch (recommended)" selected.

When I re-run config creator with Use "Lightbulb/Switch" * accessory with standalone temperature and myZone switch (legacy)" it operates with no issues.

I have been running plugin since Feb 2023 and have made each update when it is released.

[08/08/2023, 18:34:37] Error: Polling for: "rotationSpeed" requested, but characteristic is not in your config.json file for: "Living Zone".
    at /var/lib/homebridge/node_modules/homebridge-cmd4/Cmd4Accessory.js:500:28
    at Array.forEach (<anonymous>)
    at Cmd4Accessory.checkPollingConfigForUnsetCharacteristics (/var/lib/homebridge/node_modules/homebridge-cmd4/Cmd4Accessory.js:435:21)
    at new Cmd4Accessory (/var/lib/homebridge/node_modules/homebridge-cmd4/Cmd4Accessory.js:286:12)
    at /var/lib/homebridge/node_modules/homebridge-cmd4/Cmd4Platform.js:444:25
    at Array.forEach (<anonymous>)
    at Cmd4Platform.discoverDevices (/var/lib/homebridge/node_modules/homebridge-cmd4/Cmd4Platform.js:370:58)
    at HomebridgeAPI.<anonymous> (/var/lib/homebridge/node_modules/homebridge-cmd4/Cmd4Platform.js:121:15)
    at HomebridgeAPI.emit (node:events:526:35)
    at HomebridgeAPI.signalFinished (/var/lib/homebridge/node_modules/homebridge/src/api.ts:275:10)
[08/08/2023, 18:34:38] Got SIGTERM, shutting down Homebridge...
[08/08/2023, 18:34:38] AssertionError [ERR_ASSERTION]: Cannot generate setupURI on an accessory that isn't published yet!
    at Bridge.Accessory.setupURI (/var/lib/homebridge/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:994:11)
    at Server.setServerStatus (/var/lib/homebridge/node_modules/homebridge/src/server.ts:155:45)
    at Server.teardown (/var/lib/homebridge/node_modules/homebridge/src/server.ts:199:10)
    at signalHandler (/var/lib/homebridge/node_modules/homebridge/src/cli.ts:93:12)
    at process.emit (node:events:514:28)
    at process.emit (/var/lib/homebridge/node_modules/homebridge/node_modules/source-map-support/source-map-support.js:516:21)

Cmd4 Config:

{
    "platform": "Cmd4",
    "name": "Cmd4",
    "debug": false,
    "outputConstants": false,
    "statusMsg": true,
    "timeout": 60000,
    "stateChangeResponseTime": 0,
    "constants": [
        {
            "key": "${AAIP}",
            "value": "192.168.8.3:2025"
        }
    ],
    "queueTypes": [
        {
            "queue": "AAA",
            "queueType": "WoRm2"
        }
    ],
    "accessories": [
        {
            "type": "Thermostat",
            "displayName": "MyAir",
            "currentHeatingCoolingState": "OFF",
            "targetHeatingCoolingState": "OFF",
            "currentTemperature": 24,
            "targetTemperature": 24,
            "temperatureDisplayUnits": "CELSIUS",
            "name": "MyAir",
            "manufacturer": "Advantage Air Australia",
            "model": "MyAir5",
            "serialNumber": "xx",
            "queue": "AAA",
            "polling": [
                {
                    "characteristic": "currentHeatingCoolingState"
                },
                {
                    "characteristic": "targetHeatingCoolingState"
                },
                {
                    "characteristic": "currentTemperature"
                },
                {
                    "characteristic": "targetTemperature"
                }
            ],
            "state_cmd": "'/var/lib/homebridge/node_modules/.bin/../homebridge-cmd4-advantageair/AdvAir.sh'",
            "state_cmd_suffix": "${AAIP}",
            "linkedTypes": [
                {
                    "type": "Fan",
                    "displayName": "MyAir FanSpeed",
                    "on": "TRUE",
                    "rotationSpeed": 100,
                    "name": "MyAir FanSpeed",
                    "manufacturer": "Advantage Air Australia",
                    "model": "MyAir5",
                    "serialNumber": "xx",
                    "queue": "AAA",
                    "polling": [
                        {
                            "characteristic": "on"
                        },
                        {
                            "characteristic": "rotationSpeed"
                        }
                    ],
                    "state_cmd": "'/var/lib/homebridge/node_modules/.bin/../homebridge-cmd4-advantageair/AdvAir.sh'",
                    "state_cmd_suffix": "${AAIP} fanSpeed"
                }
            ]
        },
        {
            "type": "Fan",
            "displayName": "MyAir Fan",
            "on": "FALSE",
            "rotationSpeed": 100,
            "name": "MyAir Fan",
            "manufacturer": "Advantage Air Australia",
            "model": "MyAir5",
            "serialNumber": "xx",
            "queue": "AAA",
            "polling": [
                {
                    "characteristic": "on"
                },
                {
                    "characteristic": "rotationSpeed"
                }
            ],
            "state_cmd": "'/var/lib/homebridge/node_modules/.bin/../homebridge-cmd4-advantageair/AdvAir.sh'",
            "state_cmd_suffix": "${AAIP}"
        },
        {
            "type": "Lightbulb",
            "displayName": "MyAir Timer",
            "on": "FALSE",
            "brightness": 0,
            "name": "MyAir Timer",
            "manufacturer": "Advantage Air Australia",
            "model": "MyAir5",
            "serialNumber": "xx",
            "queue": "AAA",
            "polling": [
                {
                    "characteristic": "on"
                },
                {
                    "characteristic": "brightness"
                }
            ],
            "state_cmd": "'/var/lib/homebridge/node_modules/.bin/../homebridge-cmd4-advantageair/AdvAir.sh'",
            "state_cmd_suffix": "timer ${AAIP}"
        },
        {
            "type": "Fanv2",
            "displayName": "Living Zone",
            "active": 0,
            "rotationSpeed": 100,
            "swingMode": 0,
            "name": "Living Zone",
            "manufacturer": "Advantage Air Australia",
            "model": "MyAir5",
            "serialNumber": "xx",
            "queue": "AAA",
            "polling": [
                {
                    "characteristic": "active"
                },
                {
                    "characteristic": "rotationSpeed"
                },
                {
                    "characteristic": "swingMode"
                }
            ],
            "state_cmd": "'/var/lib/homebridge/node_modules/.bin/../homebridge-cmd4-advantageair/AdvAir.sh'",
            "state_cmd_suffix": "z01 ${AAIP}",
            "linkedTypes": [
                {
                    "type": "TemperatureSensor",
                    "displayName": "Living Temperature",
                    "currentTemperature": 25,
                    "statusLowBattery": "BATTERY_LEVEL_LOW",
                    "name": "Living Temperature",
                    "manufacturer": "Advantage Air Australia",
                    "model": "MyAir5",
                    "serialNumber": "xx",
                    "queue": "AAA",
                    "polling": [
                        {
                            "characteristic": "currentTemperature"
                        },
                        {
                            "characteristic": "statusLowBattery"
                        }
                    ],
                    "state_cmd": "'/var/lib/homebridge/node_modules/.bin/../homebridge-cmd4-advantageair/AdvAir.sh'",
                    "state_cmd_suffix": "z01 ${AAIP}"
                }
            ]
        },
        {
            "type": "Fanv2",
            "displayName": "Lounge Zone",
            "active": 0,
            "rotationSpeed": 100,
            "swingMode": 0,
            "name": "Lounge Zone",
            "manufacturer": "Advantage Air Australia",
            "model": "MyAir5",
            "serialNumber": "xx",
            "queue": "AAA",
            "polling": [
                {
                    "characteristic": "active"
                },
                {
                    "characteristic": "rotationSpeed"
                },
                {
                    "characteristic": "swingMode"
                }
            ],
            "state_cmd": "'/var/lib/homebridge/node_modules/.bin/../homebridge-cmd4-advantageair/AdvAir.sh'",
            "state_cmd_suffix": "z02 ${AAIP}",
            "linkedTypes": [
                {
                    "type": "TemperatureSensor",
                    "displayName": "Lounge Temperature",
                    "currentTemperature": 25,
                    "statusLowBattery": "BATTERY_LEVEL_LOW",
                    "name": "Lounge Temperature",
                    "manufacturer": "Advantage Air Australia",
                    "model": "MyAir5",
                    "serialNumber": "xx",
                    "queue": "AAA",
                    "polling": [
                        {
                            "characteristic": "currentTemperature"
                        },
                        {
                            "characteristic": "statusLowBattery"
                        }
                    ],
                    "state_cmd": "'/var/lib/homebridge/node_modules/.bin/../homebridge-cmd4-advantageair/AdvAir.sh'",
                    "state_cmd_suffix": "z02 ${AAIP}"
                }
            ]
        },
        {
            "type": "Fanv2",
            "displayName": "Master Zone",
            "active": 0,
            "rotationSpeed": 100,
            "swingMode": 0,
            "name": "Master Zone",
            "manufacturer": "Advantage Air Australia",
            "model": "MyAir5",
            "serialNumber": "xx",
            "queue": "AAA",
            "polling": [
                {
                    "characteristic": "active"
                },
                {
                    "characteristic": "rotationSpeed"
                },
                {
                    "characteristic": "swingMode"
                }
            ],
            "state_cmd": "'/var/lib/homebridge/node_modules/.bin/../homebridge-cmd4-advantageair/AdvAir.sh'",
            "state_cmd_suffix": "z03 ${AAIP}",
            "linkedTypes": [
                {
                    "type": "TemperatureSensor",
                    "displayName": "Master Temperature",
                    "currentTemperature": 25,
                    "statusLowBattery": "BATTERY_LEVEL_LOW",
                    "name": "Master Temperature",
                    "manufacturer": "Advantage Air Australia",
                    "model": "MyAir5",
                    "serialNumber": "xx",
                    "queue": "AAA",
                    "polling": [
                        {
                            "characteristic": "currentTemperature"
                        },
                        {
                            "characteristic": "statusLowBattery"
                        }
                    ],
                    "state_cmd": "'/var/lib/homebridge/node_modules/.bin/../homebridge-cmd4-advantageair/AdvAir.sh'",
                    "state_cmd_suffix": "z03 ${AAIP}"
                }
            ]
        },
        {
            "type": "Fanv2",
            "displayName": "Office Zone",
            "active": 0,
            "rotationSpeed": 100,
            "swingMode": 0,
            "name": "Office Zone",
            "manufacturer": "Advantage Air Australia",
            "model": "MyAir5",
            "serialNumber": "xx",
            "queue": "AAA",
            "polling": [
                {
                    "characteristic": "active"
                },
                {
                    "characteristic": "rotationSpeed"
                },
                {
                    "characteristic": "swingMode"
                }
            ],
            "state_cmd": "'/var/lib/homebridge/node_modules/.bin/../homebridge-cmd4-advantageair/AdvAir.sh'",
            "state_cmd_suffix": "z04 ${AAIP}",
            "linkedTypes": [
                {
                    "type": "TemperatureSensor",
                    "displayName": "Office Temperature",
                    "currentTemperature": 25,
                    "statusLowBattery": "BATTERY_LEVEL_LOW",
                    "name": "Office Temperature",
                    "manufacturer": "Advantage Air Australia",
                    "model": "MyAir5",
                    "serialNumber": "xx",
                    "queue": "AAA",
                    "polling": [
                        {
                            "characteristic": "currentTemperature"
                        },
                        {
                            "characteristic": "statusLowBattery"
                        }
                    ],
                    "state_cmd": "'/var/lib/homebridge/node_modules/.bin/../homebridge-cmd4-advantageair/AdvAir.sh'",
                    "state_cmd_suffix": "z04 ${AAIP}"
                }
            ]
        },
        {
            "type": "Fanv2",
            "displayName": "Spare Room Zone",
            "active": 0,
            "rotationSpeed": 100,
            "swingMode": 0,
            "name": "Spare Room Zone",
            "manufacturer": "Advantage Air Australia",
            "model": "MyAir5",
            "serialNumber": "xx",
            "queue": "AAA",
            "polling": [
                {
                    "characteristic": "active"
                },
                {
                    "characteristic": "rotationSpeed"
                },
                {
                    "characteristic": "swingMode"
                }
            ],
            "state_cmd": "'/var/lib/homebridge/node_modules/.bin/../homebridge-cmd4-advantageair/AdvAir.sh'",
            "state_cmd_suffix": "z05 ${AAIP}",
            "linkedTypes": [
                {
                    "type": "TemperatureSensor",
                    "displayName": "Spare Room Temperature",
                    "currentTemperature": 25,
                    "statusLowBattery": "BATTERY_LEVEL_LOW",
                    "name": "Spare Room Temperature",
                    "manufacturer": "Advantage Air Australia",
                    "model": "MyAir5",
                    "serialNumber": "PIC8GS10",
                    "queue": "AAA",
                    "polling": [
                        {
                            "characteristic": "currentTemperature"
                        },
                        {
                            "characteristic": "statusLowBattery"
                        }
                    ],
                    "state_cmd": "'/var/lib/homebridge/node_modules/.bin/../homebridge-cmd4-advantageair/AdvAir.sh'",
                    "state_cmd_suffix": "z05 ${AAIP}"
                }
            ]
        },
        {
            "type": "Fanv2",
            "displayName": "Back Room Zone",
            "active": 0,
            "rotationSpeed": 100,
            "swingMode": 0,
            "name": "Back Room Zone",
            "manufacturer": "Advantage Air Australia",
            "model": "MyAir5",
            "serialNumber": "xx",
            "queue": "AAA",
            "polling": [
                {
                    "characteristic": "active"
                },
                {
                    "characteristic": "rotationSpeed"
                },
                {
                    "characteristic": "swingMode"
                }
            ],
            "state_cmd": "'/var/lib/homebridge/node_modules/.bin/../homebridge-cmd4-advantageair/AdvAir.sh'",
            "state_cmd_suffix": "z06 ${AAIP}",
            "linkedTypes": [
                {
                    "type": "TemperatureSensor",
                    "displayName": "Back Room Temperature",
                    "currentTemperature": 25,
                    "statusLowBattery": "BATTERY_LEVEL_LOW",
                    "name": "Back Room Temperature",
                    "manufacturer": "Advantage Air Australia",
                    "model": "MyAir5",
                    "serialNumber": "xx",
                    "queue": "AAA",
                    "polling": [
                        {
                            "characteristic": "currentTemperature"
                        },
                        {
                            "characteristic": "statusLowBattery"
                        }
                    ],
                    "state_cmd": "'/var/lib/homebridge/node_modules/.bin/../homebridge-cmd4-advantageair/AdvAir.sh'",
                    "state_cmd_suffix": "z06 ${AAIP}"
                }
            ]
        },
        {
            "type": "Fan",
            "displayName": "Bathroom Zone",
            "on": "FALSE",
            "rotationSpeed": 100,
            "name": "Bathroom Zone",
            "manufacturer": "Advantage Air Australia",
            "model": "MyAir5",
            "serialNumber": "xx",
            "queue": "AAA",
            "polling": [
                {
                    "characteristic": "on"
                },
                {
                    "characteristic": "rotationSpeed"
                }
            ],
            "state_cmd": "'/var/lib/homebridge/node_modules/.bin/../homebridge-cmd4-advantageair/AdvAir.sh'",
            "state_cmd_suffix": "z07 ${AAIP}"
        }
    ]
}

Screenshots:

Log extract at the the top shows the issue.

Advantage Air System:

Homebridge Environment:

mitch7391 commented 11 months ago

Hey @bigevtaylor , off the top of my head it sounds like a Homebridge cache issue like I describe how to fix in this comment. Can you please go about clearing the individual caches for the offending accessories and get back to me?

mitch7391 commented 11 months ago

If that does not work, @uswong this was the exact issue that happened to me twice during our testing when I said it threw a fit at me and would only come good if completely pasted over my entire config with my old config. Hopefully you took a copy @bigevtaylor (not that you should have to with tried and tested work); but at the very worst case take a copy form the daily Homebridge backups and paste it over and reboot.

uswong commented 11 months ago

off the top of my head it sounds like a Homebridge cache issue.

I agree totally. Whenever there is a change of config associated with an old displayName, Homebridge would use the old config associated with that displayName but AdvAir.sh would use the new config. Hence there is a conflict there. To overcome that, delete the cache associated with that displayName.

Run ConfigCreator using Fan for Zone Control again, before you reboot homebridge, go to delete all the zones in the cache, then reboot homebridge.

bigevtaylor commented 11 months ago

Thank you very much for the quick response!

So I ran ConfigCreator again using fan then removed each cached item against homebridge-cmd4, restarted the service and it launched with no errors and accessories are now updated in HomeKit along with their status - temp, fan speed, etc.

An interesting note, until it had completed what I assumed was a poll the fan switches were displaying the temperature and also showing battery % low against them. After about 5mins this all updated and now the fan shows ON/OFF status, the speed and when I expand the accessory it shows me speed and if the zone is master or not.

bigevtaylor commented 11 months ago

Resolved!

mitch7391 commented 11 months ago

Wonderful news @bigevtaylor and cheers for updating us! Next time if that ever happens you should only need to clear the cache for each of the zone accessories to save a little time; but doing the whole lot means you don’t end up missing one.

An interesting note, until it had completed what I assumed was a poll the fan switches were displaying the temperature and also showing battery % low against them.

What you have noticed here is cmd4 going through it’s initial polling, which does take a good 5 minutes or so depending how many accessories you have :)

uswong commented 11 months ago

when I expand the accessory it shows me speed and if the zone is master or not.

Hey @bigevtaylor, just in case you haven't read through the README in detail. The speed is a proxy for how much the vent of the zone is open in %. If the zone has temperature sensor, then it cannot be set, it is automatically set by your aircon system. It is there for info only. For the <> switch, if it shows the zone is not a master, you can set it as master by turning on the <> switch. Please note that you can only unset the current zone as master by setting another zone as master. This is not a limitation of the plugin but a design of AdvantageAir aircon system.

And just in case you haven't done so yet. There is a way to enhance the performance of the plugin by using an enhanced version of one of the Cmd4 modules. There is a script you can run to get the enhancement installed. This script can be found in the homebridge storage directory. If you are having a Raspberry Pi, then do the following:

ls -al /var/lib/homebridge/copyEnhancedCmd4PriorityPollingQueueJs.sh

if the above command shows the file is available, then run the script:

/var/lib/homebridge/copyEnhancedCmd4PriorityPollingQueueJs.sh

Then reboot homebridge.

if your system is a Mac, the directory of the script is in $HOME/.homebridge/ if you have a HOOBS, then the directory of the script is in /var/lib/hoobs/<bridge>/

if you don't find the script in the homebridge storage directory, then it is the indication that you already have the enhancement installed.

mitch7391 commented 11 months ago

Good info @uswong!

For the <> switch, if it shows the zone is not a master, you can set it as master by turning on the <> switch.

Also, I noticed @bigevtaylor used the same terminology ‘master’; we are talking ‘myZone’ right? As it should be for the ‘myZone’; just so we don’t get confused.

uswong commented 11 months ago

yes, for master I mean myZone.

bigevtaylor commented 11 months ago

Hey @bigevtaylor, just in case you haven't read through the README in detail. The speed is a proxy for how much the vent of the zone is open in %. If the zone has temperature sensor, then it cannot be set, it is automatically set by your aircon system. It is there for info only. For the <> switch, if it shows the zone is not a master, you can set it as master by turning on the <> switch. Please note that you can only unset the current zone as master by setting another zone as master. This is not a limitation of the plugin but a design of AdvantageAir aircon system.

That makes sense, thanks :)

And yes, in my mind master is myZone - the MyPlace mobile app uses a M icon against the zone that is myZone and I've just called it master.

I have also successfully run that script, thank you.

Great plugin guys, excellent work.