Skip to content

Commit

Permalink
Support for JSON objects for mqtt temperature reporting in the “air-c…
Browse files Browse the repository at this point in the history
…onditioner” accessory.
  • Loading branch information
lprhodes committed Mar 27, 2018
1 parent 246216d commit 1936bc7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions accessories/aircon.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,14 @@ class AirConAccessory extends BroadlinkRMAccessory {

let temperature = this.mqttValues[identifier];

try {
const temperatureJSON = JSON.parse(temperature);

if (typeof temperatureJSON === 'object') {
temperature = temperatureJSON.temp || temperatureJSON.Temp || temperatureJSON.temperature || temperatureJSON.Temperature
}
} catch (err) {}

if (temperature === undefined || (typeof temperature === 'string' && temperature.trim().length === 0)) {
log(`\x1b[31m[ERROR] \x1b[0m${name} onMQTTMessage (mqtt temperature temperature not found)`);

Expand Down

0 comments on commit 1936bc7

Please sign in to comment.