kiwi-cam / homebridge-broadlink-rm

[This fork supports TV accessories] Broadlink RM Mini and Pro plugin for homebridge: https://github.com/nfarina/homebridge
Apache License 2.0
304 stars 96 forks source link

Aircon MQTT Temperature Error #154

Closed ashtonaut closed 3 years ago

ashtonaut commented 3 years ago

I'd like to get my aircon temperature from MQTT.

I'm using the following in my config.json (partial config only):

"mqttURL": "10.1.1.3",
"mqttTopic": "zigbee2mqtt/aqara_lounge",

However, the MQTT topic isn't a straight integer return, it's an array of values:

{
  "battery": 100,
  "humidity": 43.85,
  "linkquality": 81,
  "pressure": 1012.6,
  "temperature": 24.53,
  "voltage": 3115
}

I understood from the original plugin documentation that as long as the topic included an item called "temperature" then this would be returned.

However, I get the following error when I try to start Homebridge:

TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at AirConAccessory.addTemperatureCallbackToQueue (/usr/lib/node_modules/homebridge-broadlink-rm-pro/accessories/aircon.js:400:16)
    at AirConAccessory.getCurrentTemperature (/usr/lib/node_modules/homebridge-broadlink-rm-pro/accessories/aircon.js:535:10)
    at CurrentTemperature.emit (events.js:314:20)
    at CurrentTemperature.EventEmitter.emit (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/EventEmitter.ts:42:22)
    at CurrentTemperature.Characteristic._this.getValue (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:489:12)
    at ServiceManager.refreshCharacteristicUI (/usr/lib/node_modules/homebridge-broadlink-rm-pro/helpers/serviceManager.js:27:44)
    at Timeout._onTimeout (/usr/lib/node_modules/homebridge-broadlink-rm-pro/node_modules/homebridge-platform-helper/accessory.js:195:42)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7)

I assume this is because the plugin is expecting a different type of returned value from the MQTT topic than what it's actually getting.

Any ideas? Is this expected behavior, or should it work as I've got it configured?

Thanks in advance!

ashtonaut commented 3 years ago

OK, I've now solved this, so I'll post what required so others don't have the same frustration.

The mqttURL needs to be in the form "mqtt://10.1.1.3".

Be aware that (at least, for my Aqara sensors), after restarting Homebridge it can take a few minutes for the sensor to push an update to the MQTT server. During this time, Homebridge will give the following error repeatedly:

[ERROR] Heat Pump No MQTT value could be found for topic with identifier "temperature".

However, once the sensor has published to the MQTT server, this error stops appearing and all appears to be well!