revk / ESP32-Faikin

ESP32 based module to control Daikin aircon units
GNU General Public License v3.0
415 stars 62 forks source link

MQTT Current Temperature #424

Closed Cees-tech closed 3 weeks ago

Cees-tech commented 1 month ago

Hello, I have a question about the current temperature being send over MQTT in 'state/Faikin ESP32/status/home'

This data much be handled by MQTTThing I'm using these topics in MQTTThing which are all working except 'Get Current Temperature':

Scherm­afbeelding 2024-08-10 om 20 31 53

I get this error: [homebridge-mqttthing] This plugin generated a warning from the characteristic 'Current Temperature': characteristic was supplied illegal value: number 0 exceeded minimum of 18. See https://homebridge.io/w/JtMGR for more info.

[10/08/2024, 20:43:28] [homebridge-mqttthing] Error: 
    at CurrentTemperature.Characteristic.characteristicWarning (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:3016:105)
    at CurrentTemperature.Characteristic.validateUserInput (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:2928:14)
    at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:2493:24
    at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/util/once.ts:15:18
    at handleGetStateCallback (/usr/local/lib/node_modules/homebridge-mqttthing/index.js:284:21)
    at CurrentTemperature.<anonymous> (/usr/local/lib/node_modules/homebridge-mqttthing/index.js:1206:21)
    at CurrentTemperature.emit (node:events:519:28)
    at CurrentTemperature.emit (node:domain:488:12)
    at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:2468:14
    at new Promise (<anonymous>)

I think that MQTTThing has a problem with the number format of the temperature but I can't figure out what's wrong here. Off course the problem could be at MQTTThing but I thought its better to ask here first. Hopefully anyone can help me with this? Thanks in advance, Cees

Sonic-Amiga commented 1 month ago

Hmm... Current temperature of 0 degrees feels strange... Can you show the MQTT message itself, which causes that ?

My gut feels this has to do with https://github.com/Sonic-Amiga/ESP8266-Faikin/issues/18 ; and even perhaps with https://github.com/revk/ESP32-Faikin/issues/409

Tried to frob "fixstatus" ?

revk commented 1 month ago

A topic like state/name/status/temp is not sensible. The topic would be state/name or state/name/status and then a json payload with a field called temp.

Also the "status" usually outputs an array of min/ave/max which you probably want a fixed single value.

As said, the fixstatus setting may help.

Cees-tech commented 1 month ago

I turned "fixstatus" on. I also noticed that the topic state/Faikin ESP32/status doesn't update at all. Therefore I also turned "homeassistent" on and grabbed the required data from state/Faikin ESP32/ha

A topic like state/name/status/temp is not sensible. The topic would be state/name or state/name/status and then a json payload with a field called temp.

Your'e right, I'm still learning MQTT and JSON. If I read the documentation of MQTTThing correctly is supposed to be like this (with $. sign):

"type": "heaterCooler",
            "name": "Airco Woonkamer",
            "topics": {
                "getOnline": "state/Faikin ESP32/ha$.online",
                "getRotationMode": "state/Faikin ESP32/ha$.fan",
                "setRotationMode": "command/Faikin ESP32/fan",
                "getActive": "state/Faikin ESP32/status$.power",
                "setActive": "command/Faikin ESP32/power",
                "getCoolingThresholdTemperature": "state/Faikin ESP32/ha$.target",
                "setCoolingThresholdTemperature": "command/Faikin ESP32/temp",
                "getCurrentHeaterCoolerState": "state/Faikin ESP32/status$.mode",
                "getCurrentTemperature": "state/Faikin ESP32/ha$.temp",
                "getHeatingThresholdTemperature": "state/Faikin ESP32/ha$.target",
                "setHeatingThresholdTemperature": "command/Faikin ESP32/temp",
                "getTargetHeaterCoolerState": "state/Faikin ESP32/status$.mode",
                "setTargetHeaterCoolerState": "command/Faikin ESP32/mode"
            },
            "onValue": "1",
            "offValue": "0",
            "minTemperature": 18,
            "maxTemperature": 33,
            "manufacturer": "Daikin",
            "accessory": "mqttthing"

Is it correct that commands can be send in seperate topics like "command/Faikin ESP32/temp" and "command/Faikin ESP32/mode"?

With the configuration above Homekit gets the measured temperature, I can turn the AC on/off, set modes and temperature. So everything I need is working now!

revk commented 1 month ago

Try latest beta code please as /ha is changing.

I'll make a release in fact...

njh commented 1 month ago

@Cees-tech it would be really good to get a Wiki page setup with Homebridge instructions on it. I had a go a while ago but didn't manage to get the fan control settings sorted out.

I am currently using homebridge-daikin-local, which works over the emulated HTTP API. But I like the idea of it being event driven over MQTT.

revk commented 1 month ago

You should be able to see the MQTT messages. HA on will send the main status message, but I suggest ensuring to to date.

MQTT is likely a lot better than the legacy APIs, yes.

Cees-tech commented 1 month ago

Try latest beta code please as /ha is changing. I'll make a release in fact...

See below, got it working now with topic 'state/Faikin ESP32/status' so I turned off Homeassistant. The last days I noticed the AC going on sometime during the night. Have to look into that why.

@Cees-tech it would be really good to get a Wiki page setup with Homebridge instructions on it. I had a go a while ago but didn't manage to get the fan control settings sorted out.

See below how it's working here for reading and setting of power, heating, cooling and temperatures. I'm not planning to implement fan mode and the special functions. Will set them once in the Daikin app and don't want Homekit to be able to change that.

{ "accessory": "mqttthing", "manufacturer": "Daikin", "type": "heaterCooler", "name": "Airco Woonkamer", "topics": { "getOnline": "state/Faikin ESP32/status$.online", "getActive": "state/Faikin ESP32/status$.power", "setActive": "command/Faikin ESP32/power", "getCoolingThresholdTemperature": "state/Faikin ESP32/status$.temp", "setCoolingThresholdTemperature": "command/Faikin ESP32/temp", "getCurrentHeaterCoolerState": "state/Faikin ESP32/status$.mode", "getCurrentTemperature": "state/Faikin ESP32/status$.home", "getHeatingThresholdTemperature": "state/Faikin ESP32/status$.temp", "setHeatingThresholdTemperature": "command/Faikin ESP32/temp", "getTargetHeaterCoolerState": "state/Faikin ESP32/status$.mode", "setTargetHeaterCoolerState": "command/Faikin ESP32/mode" }, "onValue": "1", "offValue": "0", "minTemperature": 18, "maxTemperature": 33, "restrictHeaterCoolerState": [ 1, 2 ], "currentHeaterCoolerValues": [ "", "0", "H", "C" ], "targetHeaterCoolerValues": [ "A", "H", "C" ], "logMqtt": true }

I am currently using homebridge-daikin-local, which works over the emulated HTTP API. But I like the idea of it being event driven over MQTT.

I have been using the Daikin cloud for a few years with homebridge-daikin-cloud. But couldn't get it working with the new API. With Faikin it's a lot faster and probably more reliable without the cloud.

revk commented 3 weeks ago

As I say try latest code. It is released now using state/nameoffaikin and no /ha on the end.