arachnetech / homebridge-mqttthing

A plugin for Homebridge allowing the integration of many different accessory types using MQTT.
Apache License 2.0
462 stars 104 forks source link

HeaterCooler - Accessory is out of compliance #592

Open rbswift opened 1 year ago

rbswift commented 1 year ago

I have a heater that I only use in the Australian winter and then take offline in spring. When I do this I find that all the accessories on that bridge stop working the next time I restart homebridge. I have managed to isolate the problem and reproduce it in the test config below.

testheater/getOnline is set to retain false by the LWT when I take my heater offline. This can be simulated with mosquitto_pub -t "testheater/getOnline" -m "false" -r No other mqtt subjects are set.

It is an unfortunate mode of failure as nothing is logged and the bridge just stops working if it is already added to the home. Only an attempt to newly add the bridge to the home while it is in this state will produce the error "Accessory is out of compliance". Nothing is logged by homebridge even when running with the -D debug switch.

Is getCurrentTemperature being validated against minTemperature even when no current temperature is received? This would not make much sense as the current temperature is what it is and in this case is not even present on mqtt. Is it inferring "0" from the absence of a current temperature? The offline status seems to somehow make it worse.

{
    "bridge": {
        "name": "Test Bridge",
        "username": "CC:22:DD:E4:CE:A3",
        "port": 51836,
        "pin": "031-45-914",
        "advertiser": "avahi",
        "bind": [
            "br0"
        ]
    },
    "description": "This is the test homebridge config file",
    "ports": {
        "start": 52200,
        "end": 52250
    },
    "accessories": [
     {
            "accessory": "mqttthing",
            "type": "heaterCooler",
            "name": "Test Heater",
            "minTemperature": 16,
            "topics": {
                "getCurrentHeaterCoolerState": "testheater/getCurrentHeaterCoolerState",
                "setTargetHeaterCoolerState": "testheater/setTargetHeaterCoolerState",
                "getTargetHeaterCoolerState": "testheater/getTargetHeaterCoolerState",
                "setActive": "testheater/setActive",
                "getActive": "testheater/getActive",
                "setHeatingThresholdTemperature": "testheater/setHeatingThresholdTemperature",
                "getHeatingThresholdTemperature": "testheater/getHeatingThresholdTemperature",
                "getCurrentTemperature":  "testheater/getCurrentTemperature",
                "getOnline": "testheater/getOnline"
            }
        }
    ]
}