Achronite / mqtt-energenie-ener314rt

MQTT interface for Energenie ENER314-RT add-on board for the Raspberry Pi, designed for use by Home Assistant.
MIT License
13 stars 5 forks source link

Device Type 18 #56

Closed DrOwl closed 4 months ago

DrOwl commented 7 months ago

Hi,

I have a Thermostat MIHO069.

Below are some logs from it hope the below can help generate a device file for it... Is there any other logging / debugging I can do to get data about it?

` mqtt-ener314rt info discovery found 14 devices mqtt-ener314rt info discovery discovered: {"mfrId":4,"productId":18,"deviceId":11111111,"control":2,"product":"Thermostat","joined":0} mqtt-ener314rt ERR! discovery skipped for device 11111111 - unknown device type 'devices/18.json' missing

mqtt-ener314rt http monitor received: {"deviceId":11111111,"mfrId":4,"productId":18,"timestamp":1700581965,"WAKEUP":0,"cmd":"monitor"} mqtt-ener314rt http monitor received: {"deviceId":11111111,"mfrId":4,"productId":18,"timestamp":1700581967,"BATTERY_LEVEL":2.562988,"THERMOSTAT_MODE":0,"cmd":"monitor"} mqtt-ener314rt http monitor received: {"deviceId":11111111,"mfrId":4,"productId":18,"timestamp":1700582018,"THERMOSTAT_MODE":0,"cmd":"monitor"} mqtt-ener314rt http monitor received: {"deviceId":11111111,"mfrId":4,"productId":18,"timestamp":1700582019,"THERMOSTAT_MODE":0,"cmd":"monitor"} mqtt-ener314rt http monitor received: {"deviceId":11111111,"mfrId":4,"productId":18,"timestamp":1700582615,"REL_HUMIDITY":59,"THERMOSTAT_MODE":0,"cmd":"monitor"} (2966 results) [945/24484] mqtt-ener314rt http monitor received: {"deviceId":11111111,"mfrId":4,"productId":18,"timestamp":1700582667,"REL_HUMIDITY":59,"THERMOSTAT_MODE":0,"cmd":"monitor"}

{"deviceId":11111111,"mfrId":4,"productId":18,,"TEMPERATURE":19.5,"REL_HUMIDITY":54,"THERMOSTAT_MODE":0,"cmd":"monitor"} {"deviceId":11111111,"mfrId":4,"productId":18,,"TEMPERATURE":19.5,"REL_HUMIDITY":55,"THERMOSTAT_MODE":0,"cmd":"monitor"} {"deviceId":11111111,"mfrId":4,"productId":18,,"TEMPERATURE":19,"THERMOSTAT_MODE":0,"cmd":"monitor"} {"deviceId":11111111,"mfrId":4,"productId":18,,"THERMOSTAT_MODE":0,"cmd":"monitor"} {"deviceId":11111111,"mfrId":4,"productId":18,,"WAKEUP":0,"cmd":"monitor"} {"deviceId":11111111,"mfrId":4,"productId":18,,"TEMPERATURE":19.25,"REL_HUMIDITY":56,"BATTERY_LEVEL":2.564941,"THERMOSTAT_MODE":0,"cmd":"monitor"} {"deviceId":11111111,"mfrId":4,"productId":18,,"TEMPERATURE":19.25,"THERMOSTAT_MODE":0,"cmd":"monitor"} {"deviceId":11111111,"mfrId":4,"productId":18,,"TEMPERATURE":19.375,"REL_HUMIDITY":55,"BATTERY_LEVEL":2.565918,"THERMOSTAT_MODE":0,"cmd":"monitor"} {"deviceId":11111111,"mfrId":4,"productId":18,,"REL_HUMIDITY":61,"THERMOSTAT_MODE":0,"cmd":"monitor"} {"deviceId":11111111,"mfrId":4,"productId":18,,"BATTERY_LEVEL":2.562988,"THERMOSTAT_MODE":0,"cmd":"monitor"}

`

Achronite commented 7 months ago

Wow that's a really weird deviceId!

You are the 1st with a thermostat to try this. I'll work on the 18.json file for you now, and let you know when it is in the 'develop' branch; I'm guessing you would like it as a climate control entity (like the eTRV)?

I'll leave a few config entries in there too; you'll just have to try them to see if they work. e.g. LOW_POWER_MODE, retries, REPORTING_INTERVAL, ERRORS, ERROR_TEXT.

Do you know what the valid values are for THERMOSTAT_MODE?

DrOwl commented 7 months ago

It the master device for the eTRV's i.e. will turn Boiler on / off

Currently i have my devices connected to the web service and this one so i just set the temp to 30 for this device and got:

mqtt-ener314rt http monitor received: {"deviceId":11111,"mfrId":4,"productId":18,"timestamp":1700588715,"TARGET_TEMP":30,"cmd":"monitor"} mqtt-ener314rt http monitor received: {"deviceId":11111,"mfrId":4,"productId":18,"timestamp":1700588717,"THERMOSTAT_MODE":1,"cmd":"monitor"}

I have not see any of the other entries, iv changed my log level to debug and an running in the foreground, so am using tmux to screen capt the logs, is there a syslog config option?

A few more logs: The Device has a motion detector so it lights up when to approach it... Not sure what the switch state was, maybe me powering on the heating?

I seem to remember there being a another THERMOSTAT_MODE for constantly on but i can not remember!

mqtt-energenie verb energenie received="{\"deviceId\":11111111,\"mfrId\":4,\"productId\":18,\"timestamp\":1700593886,\"WAKEUP\":0}" mqtt-energenie verb energenie received="{\"deviceId\":11111111,\"mfrId\":4,\"productId\":18,\"timestamp\":1700593887,\"TEMPERATURE\":21.375000,\"REL_HUMIDITY\":60,\"MOTION_DETECTOR\":4,\"THERMOSTAT_MODE\":1,\"TARGET_TEMP\":22.500000,\"SWITCH_STATE\":1}" mqtt-energenie verb energenie received="{\"deviceId\":11111111,\"mfrId\":4,\"productId\":18,\"timestamp\":1700593888,\"TEMPERATURE\":21.375000,\"REL_HUMIDITY\":60,\"MOTION_DETECTOR\":4,\"THERMOSTAT_MODE\":1,\"TARGET_TEMP\":22.500000,\"SWITCH_STATE\":1}" mqtt-energenie verb energenie received="{\"deviceId\":11111111,\"mfrId\":4,\"productId\":18,\"timestamp\":1700593889,\"TEMPERATURE\":21.375000,\"REL_HUMIDITY\":60,\"MOTION_DETECTOR\":4,\"THERMOSTAT_MODE\":1,\"TARGET_TEMP\":22.500000,\"SWITCH_STATE\":1}" Also, I have a spare one if you want it, i can mail it to you for testing ;)

Achronite commented 7 months ago

I use npmlog for this implementation, you can set the log level using the config.json file and restarting. verbose is the most comprehensive.

Achronite commented 7 months ago

@DrOwl it looks like more work than just adding 18.json is required to get this working properly if you want to issue commands as well. I remember you from the node-red implementation, did you ever get to the bottom of the valid commands that the thermostat can take?

Also regarding syslog, please follow the instructions for adding it as a service using systemd, then you can use journalctl to view the logs

DrOwl commented 7 months ago

Oh of course I'll add it as a service!

I only have some old notes from an email with their support team...

" 0x2a is the On/Off mode

0x59 is the Wake up message

I haven't found much in the way of details for 0x59, only a single character, Y is shown for the wakeup integer.

For 0x2a, the modes are as follows:

0           The Thermostat is set to standby, it will report the temperature but will not turn the boiler on if the temperature is low.

1           The Thermostat is set to ON, it will report the temperature and will turn the boiler on if the temperature is low.

2           The thermostat is set to Always ON, it will report the temperature but will not turn the boiler off if the temperature is high.

"

As I have a gateway and 314, maybe a little experiment with seeing what gets logged when I make calls via their GUI/api would help

Achronite commented 7 months ago

With OpenThings devices there is one parameter for setting and for the current state; I'm wondering if the thermostat mode is set using SWITCH_STATE and then reported by 'THERMOSTAT_MODE'?

WAKEUP is probably sent when it starts listening for commands, similar to what the eTRV does when it reports current temperature. Try using the app to change things, making note of when the state params from the device report back as changed. In the meantime I'll put a simple 18.json file together; just so that you can track the states in HA; the commands will have to come later...

Also try and do something with motion detector; it looks like energenie are not adhering to the OpenThings spec again and reporting it as a different datatype. '4'? That's not a boolean!

Achronite commented 7 months ago

Ok I've uploaded a basic 18.json file to the develop branch, please download and add to your devices folder. This does not have any commands enabled for now.

Let me know how you get on, and please answer the questions in my double post above.

DrOwl commented 7 months ago

Thanks I added the dev 18.json

SWITCH_STATE I think you are right about SWITCH_STATE, it for setting the value WAKEUP, i am not sure it "mostly" seem to come before any reports MOTION_DETECTOR, Would seem to be a count of detections since last report

`

== Power on via API (Google Home) ==

mqtt-ener314rt http monitor received: {"deviceId":1111,"mfrId":4,"productId":18,"timestamp":1700658549,"WAKEUP":0,"cmd":"monitor"} mqtt-ener314rt http monitor received: {"deviceId":1111,"mfrId":4,"productId":18,"timestamp":1700658550,"TEMPERATURE":16.75,"REL_HUMIDITY":63,"MOTION_DETECTOR":2,"THERMOSTAT_MODE":1,"SWITCH_STATE":1,"cmd":"monitor"} mqtt-ener314rt http monitor received: {"deviceId":1111,"mfrId":4,"productId":18,"timestamp":1700658552,"TEMPERATURE":16.75,"REL_HUMIDITY":63,"MOTION_DETECTOR":2,"THERMOSTAT_MODE":1,"SWITCH_STATE":1,"cmd":"monitor"}

mqtt-ener314rt http monitor received: {"deviceId":1111,"mfrId":4,"productId":18,"timestamp":1700658602,"WAKEUP":0,"cmd":"monitor"} mqtt-ener314rt http monitor received: {"deviceId":1111,"mfrId":4,"productId":18,"timestamp":1700658604,"REL_HUMIDITY":63,"THERMOSTAT_MODE":1,"cmd":"monitor"} mqtt-ener314rt http monitor received: {"deviceId":1111,"mfrId":4,"productId":18,"timestamp":1700658604,"REL_HUMIDITY":63,"THERMOSTAT_MODE":1,"cmd":"monitor"} mqtt-ener314rt http monitor received: {"deviceId":1111,"mfrId":4,"productId":18,"timestamp":1700658605,"REL_HUMIDITY":63,"THERMOSTAT_MODE":1,"cmd":"monitor"} < - Device switched on

== Power off via API ==

mqtt-ener314rt http monitor received: {"deviceId":1111,"mfrId":4,"productId":18,"timestamp":1700658698,"REL_HUMIDITY":64,"THERMOSTAT_MODE":0,"SWITCH_STATE":0,"cmd":"monitor"} mqtt-ener314rt http monitor received: {"deviceId":1111,"mfrId":4,"productId":18,"timestamp":1700658698,"REL_HUMIDITY":64,"THERMOSTAT_MODE":0,"SWITCH_STATE":0,"cmd":"monitor"} mqtt-ener314rt http monitor received: {"deviceId":1111,"mfrId":4,"productId":18,"timestamp":1700658699,"REL_HUMIDITY":64,"THERMOSTAT_MODE":0,"SWITCH_STATE":0,"cmd":"monitor"}

mqtt-ener314rt http monitor received: {"deviceId":1111,"mfrId":4,"productId":18,"timestamp":1700658744,"WAKEUP":0,"cmd":"monitor"} mqtt-ener314rt http monitor received: {"deviceId":1111,"mfrId":4,"productId":18,"timestamp":1700658746,"TEMPERATURE":16.5625,"REL_HUMIDITY":64,"THERMOSTAT_MODE":0,"cmd":"monitor"} < - Device switched off

== Power on via Switch ==

mqtt-ener314rt http monitor received: {"deviceId":1111,"mfrId":4,"productId":18,"timestamp":1700659850,"WAKEUP":0,"cmd":"monitor"} mqtt-ener314rt http monitor received: {"deviceId":1111,"mfrId":4,"productId":18,"timestamp":1700659851,"MOTION_DETECTOR":2,"THERMOSTAT_MODE":1,"TARGET_TEMP":20,"SWITCH_STATE":1,"cmd":"monitor"} mqtt-ener314rt http monitor received: {"deviceId":1111,"mfrId":4,"productId":18,"timestamp":1700659852,"MOTION_DETECTOR":2,"THERMOSTAT_MODE":1,"TARGET_TEMP":20,"SWITCH_STATE":1,"cmd":"monitor"} mqtt-ener314rt http monitor received: {"deviceId":1111,"mfrId":4,"productId":18,"timestamp":1700659853,"MOTION_DETECTOR":2,"THERMOSTAT_MODE":1,"TARGET_TEMP":20,"SWITCH_STATE":1,"cmd":"monitor"}

== Power off via Switch ==

mqtt-ener314rt http monitor received: {"deviceId":1111,"mfrId":4,"productId":18,"timestamp":1700659789,"WAKEUP":0,"cmd":"monitor"} mqtt-ener314rt http monitor received: {"deviceId":1111,"mfrId":4,"productId":18,"timestamp":1700659791,"TEMPERATURE":16,"REL_HUMIDITY":66,"MOTION_DETECTOR":2,"THERMOSTAT_MODE":0,"TARGET_TEMP":20,"SWITCH_STATE":0,"cmd":"monitor"} `

int-rpi-01:~/mqtt-energenie-ener314rt# bash do.search.sh "THERMOSTAT_MODE", 0, 1 "JOIN", 0, 25 "REL_HUMIDITY", 63, 64, 65, 66, 67, 59, 60, 61, 62 "SWITCH_STATE", 0, 1 "MOTION_DETECTOR", 9, 1, 2, 3, 5 "WAKEUP", 0 "TARGET_TEMP", 20, 30 "BATTERY_LEVEL", 2.553955, 2.557861 "TEMPERATURE", 16.5625, 17.1875, 17.6875, 16, 16.1875, 16.875, 16.25, 16.375, 16.6875, 18, 17.25, 16.5, 16.75, 17.875, 15.875, 17.0625, 17.375, 17.5625, 17.5

DrOwl commented 7 months ago

I have been playing a little, but this is just guess work based on what i have worked out in the lat days... 18.json

I tried sending some commands but found there is a section missing from app.js for this device. I have had a little hack but not got anywhere so far

Achronite commented 7 months ago

Yeah it needs a section writing for the thermostat; it really needs some mapping between the MQTT topic name and the underlying OpenThings otCommand number.

For other devices there is usually a current value and a set value; the difference in otCommand code is to add 0x80 to the underlying value; for example:

THERMOSTAT_MODE is parameter code 0x2A, to set this you would add 0x80 on so 0x2A+0x80 = 0xAA

Each of these will need to be mapped in the code, like I have done for the eTRV.

I'm now thinking that SWITCH_STATE may report if the thermostat is currently 'heating'.

What I've done, to get you up and running is clone the code for the eTRV and made some quick edits removing the valve stuff; this has been uploaded to develop.

The commands that you can try are setting SWITCH_STATE, THERMOSTAT_MODE and TARGET_TEMP, all are coded to be allowed; so I've updated 18.json with this (note I've left off the Climate Control bit off for now; we can add that back in when the basic topics are working).

There may be more code changes required to the energenie-ener314rt node module to make this work properly; I've not checked yet! I've also made a BIG assumption this requires cached commands to work (similar to eTRV) as it is a battery powered device.

DrOwl commented 7 months ago

Thank you ill test out the new code...

Is there a way to filter for messages from one device... i.e. my Gateway, so I could monitor what commands its sending?

DrOwl commented 7 months ago

FYI, Logs from HA

` Entity sensor.heating_11111_rel_humidity (<class 'homeassistant.components.mqtt.sensor.MqttSensor'>) is using native unit of measurement 'None' which is not a valid unit for the device class ('humidity') it is using; expected one of ['%']; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+mqtt%22 Entity sensor.heating_11111_temperature (<class 'homeassistant.components.mqtt.sensor.MqttSensor'>) is using native unit of measurement 'None' which is not a valid unit for the device class ('temperature') it is using; expected one of ['°F', '°C', 'K']; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+mqtt%22 Entity sensor.heating_11111_target_temp (<class 'homeassistant.components.mqtt.sensor.MqttSensor'>) is using native unit of measurement 'None' which is not a valid unit for the device class ('temperature') it is using; expected one of ['°F', '°C', 'K']; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+mqtt%22 Entity sensor.radiator_11111_rel_humidity (<class 'homeassistant.components.mqtt.sensor.MqttSensor'>) is using native unit of measurement 'None' which is not a valid unit for the device class ('humidity') it is using; expected one of ['%']; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+mqtt%22 Entity sensor.radiator_11111_temperature (<class 'homeassistant.components.mqtt.sensor.MqttSensor'>) is using native unit of measurement 'None' which is not a valid unit for the device class ('temperature') it is using; expected one of ['°F', '°C', 'K']; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+mqtt%22

Error 'expected SensorDeviceClass or one of 'date', 'enum', 'timestamp', 'apparent_power', 'aqi', 'atmospheric_pressure', 'battery', 'carbon_monoxide', 'carbon_dioxide', 'current', 'data_rate', 'data_size', 'distance', 'duration', 'energy', 'energy_storage', 'frequency', 'gas', 'humidity', 'illuminance', 'irradiance', 'moisture', 'monetary', 'nitrogen_dioxide', 'nitrogen_monoxide', 'nitrous_oxide', 'ozone', 'ph', 'pm1', 'pm10', 'pm25', 'power_factor', 'power', 'precipitation', 'precipitation_intensity', 'pressure', 'reactive_power', 'signal_strength', 'sound_pressure', 'speed', 'sulphur_dioxide', 'temperature', 'volatile_organic_compounds', 'volatile_organic_compounds_parts', 'voltage', 'volume', 'volume_storage', 'water', 'weight', 'wind_speed' for dictionary value @ data['device_class']' when processing MQTT discovery message topic: 'homeassistant/sensor/ener314rt/11111-MOTION_DETECTOR/config', message: '{'device': {'name': 'Radiator 11111', 'identifiers': ['ener314rt-11111'], 'model': 'Radiator', 'manufacturer': 'Energenie', 'sw_version': 'mqtt-ener314rt 0.6.0'}, 'unique_id': 'ener314rt-11111-MOTION_DETECTOR', 'name': 'Motion Detector', 'availability_topic': 'energenie/availability/state', 'origin': {'name': 'mqtt-energenie-ener314rt', 'sw_version': '0.6.0', 'support_url': 'https://github.com/Achronite/mqtt-energenie-ener314rt'}, 'device_class': 'motion', 'state_topic': 'energenie/18/11111/MOTION_DETECTOR/state', 'platform': 'mqtt'}'

`

Achronite commented 7 months ago

Is there a way to filter for messages from one device... i.e. my Gateway, so I could monitor what commands its sending?

Can you see these messages in the log file? (I don't have an MiHome gateway) I can't see anything in what you posted earlier...

Various type errors

HA is getting really picky these days! One of '%' really? :) I've updated 18.json to try and fix these errors

More importantly, have you manged to do a successful set/command request from HA yet?

genestealer commented 7 months ago

FYI, you have set mdl to Radiator in, I strongly think this should be Thermostat in 18.json

Achronite commented 7 months ago

FYI, you have set mdl to Radiator in, I strongly think this should be Thermostat in 18.json

Thanks for this; fixed now. (It's what happens when you cut'n'paste!!) :)

DrOwl commented 7 months ago

Can you see these messages in the log file? (I don't have an MiHome gateway) I can't see anything in what you posted earlier...

I am not sure how to work out where the messages are coming from... i.e. with an entry like this, is it a massage addressed to that device or one sent by it? mqtt-energenie verb energenie received="{\"deviceId\":1111111,\"mfrId\":4,\"productId\":18,\"timestamp\":1701027474,\"THERMOSTAT_MODE\":0,\"SWITCH_STATE\":0}"

HA is getting really picky these days! One of '%' really? :) I've updated 18.json to try and fix these errors

thank you

More importantly, have you manged to do a successful set/command request from HA yet?

i don't think so, I do not know how to send commands / set values with out a Climate Control, so I added one back in and i am not convinced i am creating it correctly I got a crash from app.js as msg_data had not been defined, so change the var name ;) "let msg_data18 = Number(msg);"

` == Switched off via app ==

mqtt-energenie verb energenie received="{\"deviceId\":1111111,\"mfrId\":4,\"productId\":18,\"timestamp\":1700949116,\"WAKEUP\":0}" mqtt-ener314rt http monitor received: {"deviceId":1111111,"mfrId":4,"productId":18,"timestamp":1700949116,"WAKEUP":0,"cmd":"monitor"} mqtt-ener314rt verb < energenie/18/1111111/last_seen/state: 1700949116 mqtt-ener314rt verb < energenie/18/1111111/WAKEUP/state: 0 mqtt-energenie verb energenie received="{\"deviceId\":1111111,\"mfrId\":4,\"productId\":18,\"timestamp\":1700949117,\"TEMPERATURE\":22.500000,\"THERMOSTAT_MODE\":0,\"SWITCH_STATE\":0}" mqtt-ener314rt http monitor received: {"deviceId":1111111,"mfrId":4,"productId":18,"timestamp":1700949117,"TEMPERATURE":22.5,"THERMOSTAT_MODE":0,"SWITCH_STATE":0,"cmd":"monitor"} mqtt-ener314rt verb < energenie/18/1111111/last_seen/state: 1700949117 mqtt-ener314rt verb < energenie/18/1111111/TEMPERATURE/state: 22.5 mqtt-ener314rt verb < energenie/18/1111111/THERMOSTAT_MODE/state: 0 mqtt-ener314rt verb < energenie/18/1111111/switch/state: OFF mqtt-energenie verb energenie received="{\"deviceId\":1111111,\"mfrId\":4,\"productId\":18,\"timestamp\":1700949117,\"TEMPERATURE\":22.500000,\"THERMOSTAT_MODE\":0,\"SWITCH_STATE\":0}" mqtt-ener314rt http monitor received: {"deviceId":1111111,"mfrId":4,"productId":18,"timestamp":1700949117,"TEMPERATURE":22.5,"THERMOSTAT_MODE":0,"SWITCH_STATE":0,"cmd":"monitor"} mqtt-ener314rt verb < energenie/18/1111111/last_seen/state: 1700949117 mqtt-ener314rt verb < energenie/18/1111111/TEMPERATURE/state: 22.5 mqtt-ener314rt verb < energenie/18/1111111/THERMOSTAT_MODE/state: 0 mqtt-ener314rt verb < energenie/18/1111111/switch/state: OFF

== Switched on Via button on device ==

mqtt-energenie verb energenie received="{\"deviceId\":1111111,\"mfrId\":4,\"productId\":18,\"timestamp\":1701006000,\"WAKEUP\":0}" mqtt-ener314rt http monitor received: {"deviceId":1111111,"mfrId":4,"productId":18,"timestamp":1701006000,"WAKEUP":0,"cmd":"monitor"} mqtt-ener314rt verb < energenie/18/1111111/last_seen/state: 1701006000 mqtt-ener314rt verb < energenie/18/1111111/WAKEUP/state: 0 mqtt-energenie verb energenie received="{\"deviceId\":1111111,\"mfrId\":4,\"productId\":18,\"timestamp\":1701006001,\"MOTION_DETECTOR\":1,\"THERMOSTAT_MODE\":1,\"TARGET_TEMP\":26.000000,\"SWITCH_STATE\":1}" mqtt-ener314rt http monitor received: {"deviceId":1111111,"mfrId":4,"productId":18,"timestamp":1701006001,"MOTION_DETECTOR":1,"THERMOSTAT_MODE":1,"TARGET_TEMP":26,"SWITCH_STATE":1,"cmd":"monitor"} mqtt-ener314rt verb < energenie/18/1111111/last_seen/state: 1701006001 mqtt-ener314rt verb < energenie/18/1111111/motion/state: ON mqtt-ener314rt verb < energenie/18/1111111/THERMOSTAT_MODE/state: 1 mqtt-ener314rt verb < energenie/18/1111111/TARGET_TEMP/state: 26 (retained) mqtt-ener314rt verb < energenie/18/1111111/switch/state: ON

== Switched on Via HA ==

mqtt-ener314rt http monitor received: {"deviceId":1111111,"mfrId":4,"productId":18,"timestamp":1701029445,"THERMOSTAT_MODE":0,"cmd":"monitor"} mqtt-ener314rt verb < energenie/18/1111111/last_seen/state: 1701029445 mqtt-ener314rt verb < energenie/18/1111111/THERMOSTAT_MODE/state: 0 mqtt-ener314rt http monitor received: {"deviceId":1111111,"mfrId":4,"productId":18,"timestamp":1701029446,"THERMOSTAT_MODE":0,"cmd":"monitor"} mqtt-ener314rt verb < energenie/18/1111111/last_seen/state: 1701029446 mqtt-ener314rt verb < energenie/18/1111111/THERMOSTAT_MODE/state: 0

mqtt-ener314rt verb > energenie/18/1111111/SWITCH_STATE/command: 1 mqtt-ener314rt http command {"cmd":"cacheCmd","mode":"fsk","repeat":5,"command":"SWITCH_STATE","productId":18,"deviceId":1111111,"otCommand":243,"data":1} mqtt-energenie verb energenie cmd: {"cmd":"cacheCmd","mode":"fsk","repeat":5,"command":"SWITCH_STATE","productId":18,"deviceId":1111111,"otCommand":243,"data":1} mqtt-ener314rt http monitor received: {"cmd":"cacheCmd","mode":"fsk","repeat":5,"command":"SWITCH_STATE","productId":18,"deviceId":1111111,"otCommand":243,"data":1,"retries":10} mqtt-ener314rt http cached {"cmd":"cacheCmd","mode":"fsk","repeat":5,"command":"SWITCH_STATE","productId":18,"deviceId":1111111,"otCommand":243,"data":1,"retries":10} mqtt-ener314rt verb < energenie/18/1111111/retries/state: 10 mqtt-ener314rt verb < energenie/18/1111111/command/state: 243

mqtt-ener314rt http monitor received: {"deviceId":1111111,"mfrId":4,"productId":18,"timestamp":1701029493,"WAKEUP":0,"cmd":"monitor"} mqtt-ener314rt verb < energenie/18/1111111/last_seen/state: 1701029493 mqtt-ener314rt verb < energenie/18/1111111/WAKEUP/state: 0 mqtt-ener314rt http monitor received: {"deviceId":1111111,"mfrId":4,"productId":18,"timestamp":1701029493,"JOIN":0,"cmd":"monitor"} mqtt-ener314rt verb < energenie/18/1111111/last_seen/state: 1701029493 mqtt-ener314rt verb < energenie/18/1111111/JOIN/state: 0 mqtt-ener314rt http monitor received: {"deviceId":1111111,"mfrId":4,"productId":18,"timestamp":1701029496,"THERMOSTAT_MODE":0,"cmd":"monitor"} mqtt-ener314rt verb < energenie/18/1111111/last_seen/state: 1701029496 mqtt-ener314rt verb < energenie/18/1111111/THERMOSTAT_MODE/state: 0 mqtt-ener314rt http monitor received: {"deviceId":1111111,"mfrId":4,"productId":18,"timestamp":1701029496,"JOIN":0,"cmd":"monitor"} mqtt-ener314rt verb < energenie/18/1111111/last_seen/state: 1701029496 mqtt-ener314rt verb < energenie/18/1111111/JOIN/state: 0

mqtt-ener314rt http monitor received: {"deviceId":1111111,"mfrId":4,"productId":18,"timestamp":1701029591,"THERMOSTAT_MODE":0,"cmd":"monitor"} mqtt-ener314rt verb < energenie/18/1111111/last_seen/state: 1701029591
mqtt-ener314rt verb < energenie/18/1111111/THERMOSTAT_MODE/state: 0
mqtt-ener314rt http monitor received: {"deviceId":1111111,"mfrId":4,"productId":18,"timestamp":1701029592,"THERMOSTAT_MODE":0,"cmd":"monitor"} mqtt-ener314rt verb < energenie/18/1111111/last_seen/state: 1701029592
mqtt-ener314rt verb < energenie/18/1111111/THERMOSTAT_MODE/state: 0
mqtt-ener314rt http monitor received: {"deviceId":1111111,"mfrId":4,"productId":18,"timestamp":1701029593,"THERMOSTAT_MODE":0,"cmd":"monitor"} mqtt-ener314rt verb < energenie/18/1111111/last_seen/state: 1701029593
mqtt-ener314rt verb < energenie/18/1111111/THERMOSTAT_MODE/state: 0

== Change Temp via HA ==

mqtt-ener314rt http monitor received: {"deviceId":1111111,"mfrId":4,"productId":18,"timestamp":1701029688,"THERMOSTAT_MODE":0,"cmd":"monitor"} mqtt-ener314rt verb < energenie/18/1111111/last_seen/state: 1701029688 mqtt-ener314rt verb < energenie/18/1111111/THERMOSTAT_MODE/state: 0 mqtt-ener314rt verb > energenie/18/1111111/TARGET_TEMP/command: 22.0 mqtt-ener314rt http command {"cmd":"cacheCmd","mode":"fsk","repeat":5,"command":"TARGET_TEMP","productId":18,"deviceId":1111111,"otCommand":244,"data":22} mqtt-energenie verb energenie cmd: {"cmd":"cacheCmd","mode":"fsk","repeat":5,"command":"TARGET_TEMP","productId":18,"deviceId":1111111,"otCommand":244,"data":22} mqtt-energenie verbmqtt-ener314rt http monitor received: {"cmd":"cacheCmd","mode":"fsk","repeat":5,"command":"TARGET_TEMP","productId":18,"deviceId":1111111,"otCommand":244,"data":22,"retries":10} mqtt-ener314rt http cached {"cmd":"cacheCmd","mode":"fsk","repeat":5,"command":"TARGET_TEMP","productId":18,"deviceId":1111111,"otCommand":244,"data":22,"retries":10} mqtt-ener314rt verb < energenie/18/1111111/retries/state: 10 energeniemqtt-ener314rt verb < energenie/18/1111111/command/state: Set Temperature

mqtt-ener314rt http monitor received: {"deviceId":1111111,"mfrId":4,"productId":18,"timestamp":1701029735,"WAKEUP":0,"cmd":"monitor"} mqtt-ener314rt verb < energenie/18/1111111/last_seen/state: 1701029735 mqtt-ener314rt verb < energenie/18/1111111/WAKEUP/state: 0 mqtt-ener314rt http monitor received: {"deviceId":1111111,"mfrId":4,"productId":18,"timestamp":1701029735,"JOIN":0,"cmd":"monitor"} mqtt-ener314rt verb < energenie/18/1111111/last_seen/state: 1701029735 mqtt-ener314rt verb < energenie/18/1111111/JOIN/state: 0

`

Achronite commented 7 months ago

I am not sure how to work out where the messages are coming from... i.e. with an entry like this, is it a massage addressed to that device or one sent by it?

I believe that is the report coming from the Thermostat.

i don't think so, I do not know how to send commands / set values with out a Climate Control, so I added one back in and i am not convinced i am creating it correctly

I've updated 18.json, try this; it may still need some tuning...

I got a crash from app.js as msg_data had not been defined, so change the var name ;) "let msg_data18 = Number(msg);"

Fixed.

EDIT: If you have not already done so, I recommend getting MQTT Explorer (windows app) and using it monitor what is going on underneath the covers with MQTT.

Achronite commented 7 months ago

I am not sure how to work out where the messages are coming from... i.e. with an entry like this, is it a massage addressed to that device or one sent by it?

@DrOwl I've been having a think about this, some of the messages might be coming from the gateway. The simple way to test would be to remove the batteries from the thermostat and send the requests from the gateway again.

If this does turn out to be the case try and do as many different things as possible on the gateway and paste the logfile and commentary.

DrOwl commented 7 months ago

I've been having a think about this, some of the messages might be coming from the gateway. The simple way to test would be to remove the batteries from the thermostat and send the requests from the gateway again.

If this does turn out to be the case try and do as many different things as possible on the gateway and paste the logfile and commentary.

I tested this out and when the batteries out, no matter the commands i sent via the gateway, I say no messages at all...

Still not having any success setting commands but I did make at least 1/2 a step with the MOTION_DETECTOR "if (msg[key] >= 1" greater instead of just equal, seems both on the Thermostat and the motion detector they give the number of detections since the last report so the value can be greater than 1. This is of course more trouble for the Thermo as it never reports 0! Also the update for type 18 was being published to "motion" but the config was for "MOTION_DETECTOR"

Achronite commented 7 months ago

@DrOwl Did you download the new code and 18.json file it has a Climate Control entry in it...

If this new code doesn't still work I will need you to enable debug in the dependent node module to see what is going on at the radio level. Please follow the instructions I've just added here https://github.com/Achronite/mqtt-energenie-ener314rt/wiki

DrOwl commented 7 months ago

One think i have noted is that '"data":null' even when switching On

mqtt-ener314rt verb MQTTIN> energenie/18/222222/SWITCH_STATE/command: ON mqtt-ener314rt http ENGPUSH command {"cmd":"cacheCmd","mode":"fsk","repeat":5,"command":"SWITCH_STATE","productId":18,"deviceId":222222,"otCommand":243,"data":null} mqtt-energenie verb energenieGOT cmd: {"cmd":"cacheCmd","mode":"fsk","repeat":5,"command":"SWITCH_STATE","productId":18,"deviceId":222222,"otCommand":243,"data":null} mqtt-ener314rt http monitor received: {"cmd":"cacheCmd","mode":"fsk","repeat":5,"command":"SWITCH_STATE","productId":18,"deviceId":222222,"otCommand":243,"data":0,"retries":10} mqtt-ener314rt http cached {"cmd":"cacheCmd","mode":"fsk","repeat":5,"command":"SWITCH_STATE","productId":18,"deviceId":222222,"otCommand":243,"data":0,"retries":10} mqtt-ener314rt verb < energenie/18/222222/retries/state: 10 mqtt-ener314rt verb < energenie/18/222222/command/state: 243 mqtt-energenie verb energenie received="{\"deviceId\":222222,\"mfrId\":4,\"productId\":18,\"timestamp\":1701192558,\"WAKEUP\":0}" mqtt-ener314rt http monitor received: {"deviceId":222222,"mfrId":4,"productId":18,"timestamp":1701192558,"WAKEUP":0,"cmd":"monitor"} mqtt-ener314rt verb MQTTPUSH < energenie/18/222222/last_seen/state: 1701192558 mqtt-ener314rt verb MQTTPUSH < energenie/18/222222/WAKEUP/state: 0

a Minor thing but i set min / max for temp...

`- {"id": "TARGET_TEMP", "component":"number", "stat_t":"~@/state","cmd_t":"~@/command","config": {"dev_cla":"temperature","unit_of_meas":"°C"}},

DrOwl commented 7 months ago

If this new code doesn't still work I will need you to enable debug in the dependent node module to see what is going on at the radio level. Please follow the instructions I've just added here https://github.com/Achronite/mqtt-energenie-ener314rt/wiki

I am using the new code... and have enabled the debugging!

Achronite commented 7 months ago

I meant the 'Advanced Debugging' that one that needs you to run node-gyp...

Achronite commented 7 months ago

That's weird the deviceId has changed from 111111 to 222222 .... I wonder if it is a precision/length issue on the deviceId... enabling Advanced Debugging ^ would help with this

DrOwl commented 7 months ago

That's weird the deviceId has changed from 111111 to 222222 .... I wonder if it is a precision/length issue on the deviceId... enabling Advanced Debugging ^ would help with this

Apologies, that is me confusing the issue, 111111 is a masked version of the device ID of my Thermostat, 2222222 is a masked ID for the extra one it just turned today so i could see if it was responding as its on my desk.

I have updated the C script and recompiled, drop me a mail to my address and ill mail you over my debug log .

Achronite commented 7 months ago

drop me a mail

Done

Achronite commented 7 months ago

It'll take me a while to go through this. I'll get back to you soon™

DrOwl commented 7 months ago

Here is a filtered version of the full log...

Things i noted: 1) the retries goes down by 2 each time 2) Retries are sent the first time to mqtt / HA but not updated 3) in openThings.c "Store any output only variables in eTRV state" this is done only for type 13, is this needed for 18 too?

`Send Power on...

*mqtt-ener314rt verb MQTTIN> energenie/18/2222222/SWITCH_STATE/command: ON mqtt-ener314rt http ENGPUSH command {"cmd":"cacheCmd","mode":"fsk","repeat":5,"command":"SWITCH_STATE","productId":18,"deviceId":2222222,"otCommand":243,"data":null} mqtt-energenie verb energenieGOT cmd: {"cmd":"cacheCmd","mode":"fsk","repeat":5,"command":"SWITCH_STATE","productId":18,"deviceId":2222222,"otCommand":243,"data":null} openThings_cache_cmd(): deviceId=2222222, cmd=243, data=0 openThings_build_msg: productId=18, deviceId=2222222, cmd=243, data=0 cmd=OTCP_SWITCH_STATE msglen=14 Built payload (unencrypted): 13,4,18,46,99,224,29,132,243,1,0,0,212,83, Built payload (encrypted): 13,4,18,46,99,9,215,167,137,122,26,144,142,185, _update_cachedcmd_count(1,1) has set cached=1, pre-cached=0 1 payload(s) cached, 0 payload(s) PRE-cached mqtt-energenie verb TESTenergenie cached cmd=243, res=0 mqtt-ener314rt http monitor received: {"cmd":"cacheCmd","mode":"fsk","repeat":5,"command":"SWITCH_STATE","productId":18,"deviceId":2222222,"otCommand":243,"data":0,"retries":10} mqtt-ener314rt http cached {"cmd":"cacheCmd","mode":"fsk","repeat":5,"command":"SWITCH_STATE","productId":18,"deviceId":2222222,"otCommand":243,"data":0,"retries":10} mqtt-ener314rt verb < energenie/18/2222222/retries/state: 10 mqtt-ener314rt verb < energenie/18/2222222/command/state: 243

****HRF_readfifo_burst_cbp() len=13, data:12:4:18:84:78:204:242:221:163:127:96:185:19:210:19:133:188:170:185:193:62:178:100:27:158:30:51:203:60:80:187:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0: @openThings_cache_send(): sending cached msg radio_mod_transmit() mode changed to 12 HRF_writereg(1,12) _wait_ready(): _wait_txready radio_send_payload(): HRF_writereg(60,13) 1 tx payloads PX<PPirqflags1,2=176,8 mode changed to 16 HRF_writereg(1,16) _wait_ready(): PopenThings_cache_send(): g_CachedCmds=1, g_PreCachedCmds=0, deviceId=2222222, retries=9 rlen=0 openThings_receive(): rec:0 {"name":"WAKEUP","id":89,"type":1,"str":"","int":0,"float":65.000000} openThings_cache_send(): sending cached msg radio_mod_transmit() mode changed to 12 HRF_writereg(1,12) _wait_ready(): _wait_txready radio_send_payload(): HRF_writereg(60,13) 1 tx payloads PX<PPirqflags1,2=176,8 mode changed to 16 HRF_writereg(1,16) _wait_ready(): PopenThings_cache_send(): g_CachedCmds=1, g_PreCachedCmds=0, deviceId=2222222, retries=8 openThings_receive: Returning: {"deviceId":2222222,"mfrId":4,"productId":18,"timestamp":1701275313,"WAKEUP":0} mqtt-energenie verb energenie received="{\"deviceId\":2222222,\"mfrId\":4,\"productId\":18,\"timestamp\":1701275313,\"WAKEUP\":0}" mqtt-ener314rt http monitor received: {"deviceId":2222222,"mfrId":4,"productId":18,"timestamp":1701275313,"WAKEUP":0,"cmd":"monitor"} mqtt-ener314rt verb MQTTPUSH < energenie/18/2222222/last_seen/state: 1701275313 mqtt-ener314rt verb MQTTPUSH < energenie/18/2222222/WAKEUP/state: 0

*****HRF_readfifo_burst_cbp() len=13, data:12:4:18:39:241:137:179:254:34:34:107:94:78:94:218:51:226:217:144:246:0:58:228:227:235:59:193:129:1:31:202:8:22:80:78:3:176:145:5:72:0:74:134:16:128:145:65:129:29:128:235:41:0:224:67:49:4:33:176:224:0:0:0:0:0:0:0: @openThings_cache_send(): sending cached msg radio_mod_transmit() mode changed to 12 HRF_writereg(1,12) _wait_ready(): _wait_txready Pradio_send_payload(): HRF_writereg(60,13) 1 tx payloads PX<PPirqflags1,2=176,8 mode changed to 16 HRF_writereg(1,16) _wait_ready(): PopenThings_cache_send(): g_CachedCmds=1, g_PreCachedCmds=0, deviceId=2222222, retries=7 rlen=0 openThings_receive(): rec:0 {"name":"WAKEUP","id":89,"type":1,"str":"","int":0,"float":40.000000} openThings_cache_send(): sending cached msg radio_mod_transmit() mode changed to 12 HRF_writereg(1,12) _wait_ready(): _wait_txready Pradio_send_payload(): HRF_writereg(60,13) 1 tx payloads PX<PPirqflags1,2=176,8 mode changed to 16 HRF_writereg(1,16) _wait_ready(): PopenThings_cache_send(): g_CachedCmds=1, g_PreCachedCmds=0, deviceId=2222222, retries=6 openThings_receive: Returning: {"deviceId":2222222,"mfrId":4,"productId":18,"timestamp":1701275378,"WAKEUP":0} mqtt-energenie verb energenie received="{\"deviceId\":2222222,\"mfrId\":4,\"productId\":18,\"timestamp\":1701275378,\"WAKEUP\":0}" mqtt-ener314rt http monitor received: {"deviceId":2222222,"mfrId":4,"productId":18,"timestamp":1701275378,"WAKEUP":0,"cmd":"monitor"} mqtt-ener314rt verb MQTTPUSH < energenie/18/2222222/last_seen/state: 1701275378 mqtt-ener314rt verb MQTTPUSH < energenie/18/2222222/WAKEUP/state: 0

****HRF_readfifo_burst_cbp() len=13, data:12:4:18:250:147:91:129:67:142:250:127:1:180:111:174:178:148:228:183:133:118:52:216:76:187:20:109:233:87:31:202:8:22:80:78:3:176:145:5:72:0:74:134:16:128:145:65:129:29:128:235:41:0:224:67:49:4:33:176:224:0:0:0:0:0:0:0: @openThings_cache_send(): sending cached msg radio_mod_transmit() mode changed to 12 HRF_writereg(1,12) _wait_ready(): _wait_txready Pradio_send_payload(): HRF_writereg(60,13) 1 tx payloads PX<PPirqflags1,2=176,8 mode changed to 16 HRF_writereg(1,16) _wait_ready(): PopenThings_cache_send(): g_CachedCmds=1, g_PreCachedCmds=0, deviceId=2222222, retries=5 rlen=0 openThings_receive(): rec:0 {"name":"WAKEUP","id":89,"type":1,"str":"","int":0,"float":8.000000} openThings_cache_send(): sending cached msg radio_mod_transmit() mode changed to 12 HRF_writereg(1,12) _wait_ready(): _wait_txready Pradio_send_payload(): HRF_writereg(60,13) 1 tx payloads PX<PPirqflags1,2=176,8 mode changed to 16 HRF_writereg(1,16) _wait_ready(): PopenThings_cache_send(): g_CachedCmds=1, g_PreCachedCmds=0, deviceId=2222222, retries=4 openThings_receive: Returning: {"deviceId":2222222,"mfrId":4,"productId":18,"timestamp":1701275445,"WAKEUP":0} mqtt-energenie verb energenie received="{\"deviceId\":2222222,\"mfrId\":4,\"productId\":18,\"timestamp\":1701275445,\"WAKEUP\":0}" mqtt-ener314rt http monitor received: {"deviceId":2222222,"mfrId":4,"productId":18,"timestamp":1701275445,"WAKEUP":0,"cmd":"monitor"} mqtt-ener314rt verb MQTTPUSH < energenie/18/2222222/last_seen/state: 1701275445 mqtt-ener314rt verb MQTTPUSH < energenie/18/2222222/WAKEUP/state: 0

****HRF_readfifo_burst_cbp() len=13, data:12:4:18:221:196:182:162:2:221:181:200:35:156:235:233:88:246:126:158:91:241:170:221:215:109:100:83:1:83:4:44:4:62:66:97:136:160:208:0:136:139:70:44:97:165:0:168:32:16:137:12:98:9:226:8:136:80:16:183:151:50:0:0:165:36:64:0: @openThings_cache_send(): sending cached msg radio_mod_transmit() mode changed to 12 HRF_writereg(1,12) _wait_ready(): _wait_txready radio_send_payload(): HRF_writereg(60,13) 1 tx payloads PX<PPirqflags1,2=176,8 mode changed to 16 HRF_writereg(1,16) _wait_ready(): PopenThings_cache_send(): g_CachedCmds=1, g_PreCachedCmds=0, deviceId=2222222, retries=3 rlen=0 openThings_receive(): rec:0 {"name":"WAKEUP","id":89,"type":1,"str":"","int":0,"float":40.000000} openThings_cache_send(): sending cached msg radio_mod_transmit() mode changed to 12 HRF_writereg(1,12) _wait_ready(): _wait_txready radio_send_payload(): HRF_writereg(60,13) 1 tx payloads PX<PPirqflags1,2=176,8 mode changed to 16 HRF_writereg(1,16) _wait_ready(): PopenThings_cache_send(): g_CachedCmds=1, g_PreCachedCmds=0, deviceId=2222222, retries=2 openThings_receive: Returning: {"deviceId":2222222,"mfrId":4,"productId":18,"timestamp":1701275514,"WAKEUP":0} mqtt-energenie verb energenie received="{\"deviceId\":2222222,\"mfrId\":4,\"productId\":18,\"timestamp\":1701275514,\"WAKEUP\":0}" mqtt-ener314rt http monitor received: {"deviceId":2222222,"mfrId":4,"productId":18,"timestamp":1701275514,"WAKEUP":0,"cmd":"monitor"} mqtt-ener314rt verb MQTTPUSH < energenie/18/2222222/last_seen/state: 1701275514 mqtt-ener314rt verb MQTTPUSH < energenie/18/2222222/WAKEUP/state: 0

***HRF_readfifo_burst_cbp() len=13, data:12:4:18:180:44:246:192:24:21 4:226:109:5:190:27:187:15:230:251:14:18:101:177:82:42:123:66:233:250:214:4:44:4:62:66:97:136:160:208:0:136:139:70:44:97:165:0:168:32:16:137:12:98 :9:226:8:136:80:16:183:151:50:0:0:165:36:64:0: @openThings_cache_send(): sending cached msg radio_mod_transmit() mode changed to 12 HRF_writereg(1,12) _wait_ready(): _wait_txready Pradio_send_payload(): HRF_writereg(60,13) 1 tx payloads PX<PPirqflags1,2=176,8 mode changed to 16 HRF_writereg(1,16) _wait_ready(): PopenThings_cache_send(): g_CachedCmds=1, g_PreCachedCmds=0, deviceId=2222222, retries=1 rlen=0 openThings_receive(): rec:0 {"name":"WAKEUP","id":89,"type":1,"str":"","int":0,"float":40.000000} openThings_cache_send(): sending cached msg radio_mod_transmit() mode changed to 12 HRF_writereg(1,12) _wait_ready(): _wait_txready Pradio_send_payload(): HRF_writereg(60,13) 1 tx payloads PX<PPirqflags1,2=176,8 mode changed to 16 HRF_writereg(1,16) _wait_ready(): P_update_cachedcmd_count(-1,1) has set cached=0, pre-cached=0 openThings_cache_send(): g_CachedCmds=0, g_PreCachedCmds=0, deviceId=2222222, retries=0 openThings_receive: Returning: {"deviceId":2222222,"mfrId":4,"productId":18,"timestamp":1701275578,"WAKEUP":0} mqtt-energenie verb energenie received="{\"deviceId\":2222222,\"mfrId\":4,\"productId\":18,\"timestamp\":1701275578,\"WAKEUP\":0}" mqtt-ener314rt http monitor received: {"deviceId":2222222,"mfrId":4,"productId":18,"timestamp":1701275578,"WAKEUP":0,"cmd":"monitor"} mqtt-ener314rt verb MQTTPUSH < energenie/18/2222222/last_seen/state: 1701275578 mqtt-ener314rt verb MQTTPUSH < energenie/18/2222222/WAKEUP/state: 0

*****HRF_readfifo_burst_cbp() len=13, data:12:4:18:100:57:152:71:62:20:141:179:74:49:204:204:238:74:184:101:199:44:69:247:71:116:103:35:151:35:4: 44:4:62:66:97:136:160:208:0:136:139:70:44:97:165:0:168:32:16:137:12:98:9:226:8:136:80:16:183:151:50:0:0:165:36:64:0: @rlen=0 openThings_receive(): rec:0 {"name":"WAKEUP","id":89,"type":1,"str":"","int":0,"float":40.000000} openThings_receive: Returning: {"deviceId":2222222,"mfrId":4,"productId":18,"timestamp":1701275709,"WAKEUP":0} mqtt-energenie verb energenie received="{\"deviceId\":2222222,\"mfrId\":4,\"productId\":18,\"timestamp\":1701275709,\"WAKEUP\":0}" mqtt-ener314rt http monitor received: {"deviceId":2222222,"mfrId":4,"productId":18,"timestamp":1701275709,"WAKEUP":0,"cmd":"monitor"} mqtt-ener314rt verb MQTTPUSH < energenie/18/2222222/last_seen/state: 1701275709 mqtt-ener314rt verb MQTTPUSH < energenie/18/2222222/WAKEUP/state: 0`

Achronite commented 7 months ago

@DrOwl Just to let you know that I've got the pi5 working now, so I should have a bit more time to look into this issue...

I think we maybe need to take a step back and work out how the thermostat actually works. Looking into the manual, and the app (which I don't have as I don't have a gateway), it looks like we just need to get 2/3 commands working, and to work out how the thermostat receives commands, so here are the goals: 1) Does the thermostat 'listen' for commands all of the time or only periodically? 2) Does the WAKEUP command come from the gateway or the thermostat? If it comes from the gateway then this might be how other commands are subsequently sent. 3) The command to Switch on / off thermostat (SWITCH_STATE = 0xF3 = 243 or THERMOSTAT_MODE = 0xAA?) 4) The command to set the target temperature (TEMP_SET = 0xF4 = 244)

It also looks like I need to change the C code to make this work properly. In the meantime can you give me your thoughts on the above? I know we have gone through some of this already, but it would be good if you could answer these points so that I can focus my efforts.

BTW: I uploaded a new 18.json file that is pretty printed so we should be able to track changes in this more easily.

DrOwl commented 7 months ago

I think we maybe need to take a step back and work out how the thermostat actually works. Looking into the manual, and the app (which I don't have as I don't have a gateway), it looks like we just need to get 2/3 commands working, and to work out how the thermostat receives commands, so here are the goals:

1. Does the thermostat 'listen' for commands all of the time or only periodically?

2. Does the WAKEUP command come from the gateway or the thermostat?  If it comes from the gateway then this might be how other commands are subsequently sent.

I think it comes from the thermostat as the second one i have (device 222222) is not connected to my gateway but we still see WAKEUP's.

also when turning on via the app i see messages like "THERMOSTAT_MODE":1,"SWITCH_STATE":1} with no wake_up before (Would this answer 1)? )

I was trying to understand what was happening in the C code to see if a filter could be created for the gateway, but I can not see any way to check what the source device is for the message i very much do not understand what is happening though!

3. The command to Switch on / off thermostat (SWITCH_STATE = 0xF3 = 243 or THERMOSTAT_MODE = 0xAA?)

I would say its SWITCH_STATE as checking the logs when issuing the on command via the app shows SWITCH_STATE... it looks like its being reported by the Thermostat though as it can come with other messages:

`"REL_HUMIDITY":48,"THERMOSTAT_MODE":1,"SWITCH_STATE":1,"cmd":"monitor"!

going back to my comments on the C code maybe its not showing messages from the gateway as its not a reconised device?

4. The command to set the target temperature (TEMP_SET = 0xF4 = 244)

It also looks like I need to change the C code to make this work properly. In the meantime can you give me your thoughts on the above? I know we have gone through some of this already, but it would be good if you could answer these points so that I can focus my efforts.

BTW: I uploaded a new 18.json file that is pretty printed so we should be able to track changes in this more easily.

Achronite commented 7 months ago

@DrOwl I've done a quick update to develop for just this repository to test that the thermostat can be switched on/off without caching the command. This is the only non-cached functionality ATM to prove it can operate with immediate commands.

It's a bit of a hack, but let me know if this works OK, then I'll make the wider changes.

DrOwl commented 7 months ago

Here are some logs after updating the code.

`mqtt-ener314rt verb > energenie/18/11111/SWITCH_STATE/command: ON mqtt-ener314rt http command {"cmd":"send","mode":"fsk","repeat":5,"command":"SWITCH_STATE","productId":18,"deviceId":11111,"otCommand":243,"data":null} mqtt-energenie verb energenie cmd: {"cmd":"send","mode":"fsk","repeat":5,"command":"SWITCH_STATE","productId":18,"deviceId":11111,"otCommand":243,"data":null}
openThings_switch: productId=18, deviceId=11111, state=0
_wait_ready(): P*mqtt-energenie verb energenie openThingsSwitch(18,11111,false,5) returned $j 0

openThings_receive: Returning: {"deviceId":11111,"mfrId":4,"productId":18,"timestamp":1701855298,"WAKEUP":0} mqtt-energenie verb energenie received="{\"deviceId\":11111,\"mfrId\":4,\"productId\":18,\"timestamp\":1701855298,\"WAKEUP\":0}" mqtt-ener314rt http monitor received: {"deviceId":11111,"mfrId":4,"productId":18,"timestamp":1701855298,"WAKEUP":0,"cmd":"monitor"} mqtt-ener314rt verb < energenie/18/11111/last_seen/state: 1701855298 mqtt-ener314rt verb < energenie/18/11111/WAKEUP/state: 0 openThings_receive: Returning: {"deviceId":11111,"mfrId":4,"productId":18,"timestamp":1701855299,"THERMOSTAT_MODE":0} mqtt-energenie verb energenie received="{\"deviceId\":11111,\"mfrId\":4,\"productId\":18,\"timestamp\":1701855299,\"THERMOSTAT_MODE\":0}" mqtt-ener314rt http monitor received: {"deviceId":11111,"mfrId":4,"productId":18,"timestamp":1701855299,"THERMOSTAT_MODE":0,"cmd":"monitor"} mqtt-ener314rt verb < energenie/18/11111/last_seen/state: 1701855299 mqtt-ener314rt verb < energenie/18/11111/THERMOSTAT_MODE/state: 0 openThings_receive: Returning: {"deviceId":11111,"mfrId":4,"productId":18,"timestamp":1701855299,"THERMOSTAT_MODE":0}
mqtt-energenie verb energenie received="{\"deviceId\":11111,\"mfrId\":4,\"productId\":18,\"timestamp\":1701855299,\"THERMOSTAT_MODE\":0}"
mqtt-ener314rt http monitor received: {"deviceId":11111,"mfrId":4,"productId":18,"timestamp":1701855299,"THERMOSTAT_MODE":0,"cmd":"monitor"}
mqtt-ener314rt verb < energenie/18/11111/last_seen/state: 1701855299 mqtt-ener314rt verb < energenie/18/11111/THERMOSTAT_MODE/state: 0 openThings_receive: Returning: {"deviceId":11111,"mfrId":4,"productId":18,"timestamp":1701855300,"THERMOSTAT_MODE":0} mqtt-energenie verb energenie received="{\"deviceId\":11111,\"mfrId\":4,\"productId\":18,\"timestamp\":1701855300,\"THERMOSTAT_MODE\":0}" mqtt-ener314rt http monitor received: {"deviceId":11111,"mfrId":4,"productId":18,"timestamp":1701855300,"THERMOSTAT_MODE":0,"cmd":"monitor"}
mqtt-ener314rt verb < energenie/18/11111/last_seen/state: 1701855300
mqtt-ener314rt verb < energenie/18/11111/THERMOSTAT_MODE/state: 0

openThings_receive: Returning: {"deviceId":11111,"mfrId":4,"productId":18,"timestamp":1701855346,"WAKEUP":0} mqtt-energenie verb energenie received="{\"deviceId\":11111,\"mfrId\":4,\"productId\":18,\"timestamp\":1701855346,\"WAKEUP\":0}"
mqtt-ener314rt http monitor received: {"deviceId":11111,"mfrId":4,"productId":18,"timestamp":1701855346,"WAKEUP":0,"cmd":"monitor"}
mqtt-ener314rt verb < energenie/18/11111/last_seen/state: 1701855346
mqtt-ener314rt verb < energenie/18/11111/WAKEUP/state: 0

openThings_receive: Returning: {"deviceId":11111,"mfrId":4,"productId":18,"timestamp":1701855393,"WAKEUP":0}
mqtt-energenie verb energenie received="{\"deviceId\":11111,\"mfrId\":4,\"productId\":18,\"timestamp\":1701855393,\"WAKEUP\":0}"
mqtt-ener314rt http monitor received: {"deviceId":11111,"mfrId":4,"productId":18,"timestamp":1701855393,"WAKEUP":0,"cmd":"monitor"}
mqtt-ener314rt verb < energenie/18/11111/last_seen/state: 1701855393 mqtt-ener314rt verb < energenie/18/11111/WAKEUP/state: 0

openThings_receive: Returning: {"deviceId":11111,"mfrId":4,"productId":18,"timestamp":1701855394,"BATTERY_LEVEL":2.554932,"MOTION_DETECTOR":2,"THERMOSTAT_MODE":0}
mqtt-energenie verb energenie received="{\"deviceId\":11111,\"mfrId\":4,\"productId\":18,\"timestamp\":1701855394,\"BATTERY_LEVEL\":2.554932,\"MOTION_DETECTOR\":2,\"THERMOSTAT_MODE\":0}"
mqtt-ener314rt http monitor received: {"deviceId":11111,"mfrId":4,"productId":18,"timestamp":1701855394,"BATTERY_LEVEL":2.554932,"MOTION_DETECTOR":2,"THERMOSTAT_MODE":0,"cmd":"monitor"}
mqtt-ener314rt verb < energenie/18/11111/last_seen/state: 1701855394 mqtt-ener314rt verb < energenie/18/11111/battery/state: 36 mqtt-ener314rt verb < energenie/18/11111/BATTERY_LEVEL/state: 2.554932 mqtt-ener314rt verb < energenie/18/11111/motion/state: OFF mqtt-ener314rt verb < energenie/18/11111/THERMOSTAT_MODE/state: 0 openThings_receive: Returning: {"deviceId":11111,"mfrId":4,"productId":18,"timestamp":1701855395,"BATTERY_LEVEL":2.554932,"MOTION_DETECTOR":2,"THERMOSTAT_MODE":0}
mqtt-energenie verb energenie received="{\"deviceId\":11111,\"mfrId\":4,\"productId\":18,\"timestamp\":1701855395,\"BATTERY_LEVEL\":2.554932,\"MOTION_DETECTOR\":2,\"THERMOSTAT_MODE\":0}"
mqtt-ener314rt http monitor received: {"deviceId":11111,"mfrId":4,"productId":18,"timestamp":1701855395,"BATTERY_LEVEL":2.554932,"MOTION_DETECTOR":2,"THERMOSTAT_MODE":0,"cmd":"monitor"}
mqtt-ener314rt verb < energenie/18/11111/last_seen/state: 1701855395 mqtt-ener314rt verb < energenie/18/11111/battery/state: 36 mqtt-ener314rt verb < energenie/18/11111/BATTERY_LEVEL/state: 2.554932 mqtt-ener314rt verb < energenie/18/11111/motion/state: OFF mqtt-ener314rt verb < energenie/18/11111/THERMOSTAT_MODE/state: 0 openThings_receive: Returning: {"deviceId":11111,"mfrId":4,"productId":18,"timestamp":1701855396,"BATTERY_LEVEL":2.554932,"MOTION_DETECTOR":2,"THERMOSTAT_MODE":0}
mqtt-energenie verb energenie received="{\"deviceId\":11111,\"mfrId\":4,\"productId\":18,\"timestamp\":1701855396,\"BATTERY_LEVEL\":2.554932,\"MOTION_DETECTOR\":2,\"THERMOSTAT_MODE\":0}"
mqtt-ener314rt http monitor received: {"deviceId":11111,"mfrId":4,"productId":18,"timestamp":1701855396,"BATTERY_LEVEL":2.554932,"MOTION_DETECTOR":2,"THERMOSTAT_MODE":0,"cmd":"monitor"}
mqtt-ener314rt verb < energenie/18/11111/last_seen/state: 1701855396 mqtt-ener314rt verb < energenie/18/11111/battery/state: 36 mqtt-ener314rt verb < energenie/18/11111/BATTERY_LEVEL/state: 2.554932 mqtt-ener314rt verb < energenie/18/11111/motion/state: OFF mqtt-ener314rt verb < energenie/18/11111/THERMOSTAT_MODE/state: 0

****mqtt-ener314rt verb > energenie/18/11111/SWITCH_STATE/command: ON mqtt-ener314rt http command {"cmd":"send","mode":"fsk","repeat":5,"command":"SWITCH_STATE","productId":18,"deviceId":11111,"otCommand":243,"data":null} mqtt-energenie verb energenie cmd: {"cmd":"send","mode":"fsk","repeat":5,"command":"SWITCH_STATE","productId":18,"deviceId":11111,"otCommand":243,"data":null}
openThings_switch: productId=18, deviceId=11111, state=0 _wait_ready(): Pmqtt-energenie verb energenie openThingsSwitch(18,11111,false,5) returned $j 0 openThings_receive(): New device found, sending ACK: deviceId:11111 _wait_ready(): PopenThings_receive: Returning: {"deviceId":11111,"mfrId":4,"productId":18,"timestamp":1701855409,"JOIN":0} mqtt-energenie verb energenie received="{\"deviceId\":11111,\"mfrId\":4,\"productId\":18,\"timestamp\":1701855409,\"JOIN\":0}" mqtt-ener314rt http monitor received: {"deviceId":11111,"mfrId":4,"productId":18,"timestamp":1701855409,"JOIN":0,"cmd":"monitor"} mqtt-ener314rt verb < energenie/18/11111/last_seen/state: 1701855409 mqtt-ener314rt verb < energenie/18/11111/JOIN/state: 0

openThings_receive: Returning: {"deviceId":11111,"mfrId":4,"productId":18,"timestamp":1701855439,"WAKEUP":0} mqtt-energenie verb energenie received="{\"deviceId\":11111,\"mfrId\":4,\"productId\":18,\"timestamp\":1701855439,\"WAKEUP\":0}" mqtt-ener314rt http monitor received: {"deviceId":11111,"mfrId":4,"productId":18,"timestamp":1701855439,"WAKEUP":0,"cmd":"monitor"} mqtt-ener314rt verb < energenie/18/11111/last_seen/state: 1701855439 mqtt-ener314rt verb < energenie/18/11111/WAKEUP/state: 0 openThings_receive: Returning: {"deviceId":11111,"mfrId":4,"productId":18,"timestamp":1701855440,"REL_HUMIDITY":49,"THERMOSTAT_MODE":0} mqtt-energenie verb energenie received="{\"deviceId\":11111,\"mfrId\":4,\"productId\":18,\"timestamp\":1701855440,\"REL_HUMIDITY\":49,\"THERMOSTAT_MODE\":0}"
mqtt-ener314rt http monitor received: {"deviceId":11111,"mfrId":4,"productId":18,"timestamp":1701855440,"REL_HUMIDITY":49,"THERMOSTAT_MODE":0,"cmd":"monitor"}
mqtt-ener314rt verb < energenie/18/11111/last_seen/state: 1701855440 mqtt-ener314rt verb < energenie/18/11111/REL_HUMIDITY/state: 49 mqtt-ener314rt verb < energenie/18/11111/THERMOSTAT_MODE/state: 0 openThings_receive: Returning: {"deviceId":11111,"mfrId":4,"productId":18,"timestamp":1701855442,"REL_HUMIDITY":49,"THERMOSTAT_MODE":0} mqtt-energenie verb energenie received="{\"deviceId\":11111,\"mfrId\":4,\"productId\":18,\"timestamp\":1701855442,\"REL_HUMIDITY\":49,\"THERMOSTAT_MODE\":0}"
mqtt-ener314rt http monitor received: {"deviceId":11111,"mfrId":4,"productId":18,"timestamp":1701855442,"REL_HUMIDITY":49,"THERMOSTAT_MODE":0,"cmd":"monitor"}
mqtt-ener314rt verb < energenie/18/11111/last_seen/state: 1701855442 mqtt-ener314rt verb < energenie/18/11111/REL_HUMIDITY/state: 49 mqtt-ener314rt verb < energenie/18/11111/THERMOSTAT_MODE/state: 0 openThings_receive: Returning: {"deviceId":11111,"mfrId":4,"productId":18,"timestamp":1701855488,"WAKEUP":0}
mqtt-energenie verb energenie received="{\"deviceId\":11111,\"mfrId\":4,\"productId\":18,\"timestamp\":1701855488,\"WAKEUP\":0}"
mqtt-ener314rt http monitor received: {"deviceId":11111,"mfrId":4,"productId":18,"timestamp":1701855488,"WAKEUP":0,"cmd":"monitor"}
mqtt-ener314rt verb < energenie/18/11111/last_seen/state: 1701855488
mqtt-ener314rt verb < energenie/18/11111/WAKEUP/state: 0
openThings_receive: Returning: {"deviceId":11111,"mfrId":4,"productId":18,"timestamp":1701855490,"REL_HUMIDITY":49,"THERMOSTAT_MODE":0} mqtt-energenie verb energenie received="{\"deviceId\":11111,\"mfrId\":4,\"productId\":18,\"timestamp\":1701855490,\"REL_HUMIDITY\":49,\"THERMOSTAT_MODE\":0}" mqtt-ener314rt http monitor received: {"deviceId":11111,"mfrId":4,"productId":18,"timestamp":1701855490,"REL_HUMIDITY":49,"THERMOSTAT_MODE":0,"cmd":"monitor"} mqtt-ener314rt verb < energenie/18/11111/last_seen/state: 1701855490 mqtt-ener314rt verb < energenie/18/11111/REL_HUMIDITY/state: 49 mqtt-ener314rt verb < energenie/18/11111/THERMOSTAT_MODE/state: 0 openThings_receive: Returning: {"deviceId":11111,"mfrId":4,"productId":18,"timestamp":1701855491,"REL_HUMIDITY":49,"THERMOSTAT_MODE":0} mqtt-energenie verb energenie received="{\"deviceId\":11111,\"mfrId\":4,\"productId\":18,\"timestamp\":1701855491,\"REL_HUMIDITY\":49,\"THERMOSTAT_MODE\":0}" mqtt-ener314rt http monitor received: {"deviceId":11111,"mfrId":4,"productId":18,"timestamp":1701855491,"REL_HUMIDITY":49,"THERMOSTAT_MODE":0,"cmd":"monitor"} mqtt-ener314rt verb < energenie/18/11111/last_seen/state: 1701855491 mqtt-ener314rt verb < energenie/18/11111/REL_HUMIDITY/state: 49 mqtt-ener314rt verb < energenie/18/11111/THERMOSTAT_MODE/state: 0`

DrOwl commented 7 months ago

FYI, error on discovery:

    Error 'invalid temperature unit (expected C or F) for dictionary value 
    @ data['temperature_unit']' when processing MQTT discovery message topic: 
    'homeassistant/climate/ener314rt/11111-Climate_Control/config'
message: '{'device': {'name': 'Thermostat 11111'
'identifiers': ['ener314rt-11111']
'model': 'Thermostat'
'manufacturer': 'Energenie'
'sw_version': 'mqtt-ener314rt 0.6.0'}
'unique_id': 'ener314rt-11111-Climate_Control'
'name': 'Climate Control'
'availability_topic': 'energenie/availability/state'
'origin': {'name': 'mqtt-energenie-ener314rt'
'sw_version': '0.6.0'
'support_url': 'https://github.com/Achronite/mqtt-energenie-ener314rt'}
'current_temperature_topic': 'energenie/18/11111/TEMPERATURE/state'
'max_temp': 30
'min_temp': 10
'modes': ['heat'
'off']
'mode_command_topic': 'energenie/18/11111/SWITCH_STATE/command'
'mode_state_topic': 'energenie/18/11111/THERMOSTAT_MODE/state'
'mode_command_template': "{% if value == 'off' %} 0 {% else %} 1 {% endif %}"
'mode_state_template': "{% if value == '0' %} off {% else %} heat {% endif %}"
'temperature_command_topic': 'energenie/18/11111/TARGET_TEMP/command'
'temperature_state_topic': 'energenie/18/11111/TEMPERATURE/state'
'current_humidity_topic': 'energenie/18/11111/REL_HUMIDITY/state'
'icon': 'mdi:thermostat'
'optimistic': 'true'
'temp_step': '0.5'
'temperature_unit': '°C'
'platform': 'mqtt'}'
Achronite commented 7 months ago

@DrOwl Doh! I forgot to add the value of switch state. Please try again.

Achronite commented 7 months ago

Just to provide an update, I've received the thermostat and am currently testing it. I've managed to get it to set the thermostat_mode (using cached command), but I've yet to make it switch on/off.

It looks like the only data it regularly sends (unless it receives a command) is WAKEUP; but the values can be pretty weird. When it proceses the THERMOSTAT_MODE command it reports quite a bit...

mqtt-ener314rt verb < energenie/18/X/WAKEUP/state: 0
*****HRF_readfifo_burst_cbp() len=28, data:27:4:18:119:224:149:75:75:4:135:224:17:30:39:65:215:218:73:168:194:130:46:95:127:248:183:127:58:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:
@openThings_cache_send(): sending cached msg for device X
radio_mod_transmit()
 mode changed to 12
_wait_ready(): _wait_txready
radio_send_payload(): 1 tx payloads
PX<PPirqflags1,2=176,8
 mode changed to 16
_wait_ready(): PopenThings_cache_send(): g_CachedCmds=1, g_PreCachedCmds=0, deviceId=X, retries=8
openThings_receive(): hdr: {"deviceId":X,"mfrId":4,"productId":18,"timestamp":1702497678
openThings_receive(): rec:0 {"name":"TEMPERATURE","id":116,"type":2,"str":"","int":316,"float":19.750000}
openThings_receive(): rec:1 {"name":"REL_HUMIDITY","id":104,"type":1,"str":"","int":72,"float":72.000000}
openThings_receive(): rec:2 {"name":"BATTERY_LEVEL","id":98,"type":2,"str":"","int":10792,"float":2.634766}
openThings_receive(): rec:3 {"name":"MOTION_DETECTOR","id":109,"type":1,"str":"","int":25,"float":25.000000}
openThings_receive(): rec:4 {"name":"THERMOSTAT_MODE","id":42,"type":1,"str":"","int":1,"float":1.000000}
_update_cachedcmd_count(-1,1) has set cached=0, pre-cached=0
openThings_receive: Returning: {"deviceId":X,"mfrId":4,"productId":18,"timestamp":1702497678,"TEMPERATURE":19.750000,"REL_HUMIDITY":72,"BATTERY_LEVEL":2.634766,"MOTION_DETECTOR":25,"THERMOSTAT_MODE":1}
mqtt-energenie verb energenie received="{\"deviceId\":X,\"mfrId\":4,\"productId\":18,\"timestamp\":1702497678,\"TEMPERATURE\":19.750000,\"REL_HUMIDITY\":72,\"BATTERY_LEVEL\":2.634766,\"MOTION_DETECTOR\":25,\"THERMOSTAT_MODE\":1}"
mqtt-ener314rt http monitor received: {"deviceId":X,"mfrId":4,"productId":18,"timestamp":1702497678,"TEMPERATURE":19.75,"REL_HUMIDITY":72,"BATTERY_LEVEL":2.634766,"MOTION_DETECTOR":25,"THERMOSTAT_MODE":1,"cmd":"monitor"}
mqtt-ener314rt verb < energenie/18/X/last_seen/state: 1702497678
mqtt-ener314rt verb < energenie/18/X/TEMPERATURE/state: 19.75
mqtt-ener314rt verb < energenie/18/X/REL_HUMIDITY/state: 72
mqtt-ener314rt verb < energenie/18/X/battery/state: 49
mqtt-ener314rt verb < energenie/18/X/BATTERY_LEVEL/state: 2.634766
mqtt-ener314rt verb < energenie/18/X/motion/state: OFF
mqtt-ener314rt verb < energenie/18/X/THERMOSTAT_MODE/state: 1
Achronite commented 7 months ago

@DrOwl Can you send me a debug log of the thermostat / Gateway over a few minutes when you are doing NOTHING via the app. I would like to understand how the thermostat data is updated on the MiHome gateway; The gateway must be sending out some sort of command to get back the telemetry.

The key is capturing anything other than a WAKEUP from the Thermostat; and what the gateway does in order to get it reported.

DrOwl commented 7 months ago

@Achronite Logs sent

Achronite commented 6 months ago

I'm getting there.... image

image

@DrOwl One question - I'm concerned that the telemetry values only update when a command is sent to the thermostat. Do you think it is worth AUTOMATICALLY sending a THERMOSTAT_MODE command (potentially duplicating/overriding what the MiHome gateway does) to the device when it sends a WAKEUP?

Achronite commented 6 months ago

@DrOwl - I think this is stable enough now for you to test the 'develop' branch. NOTE: you will also need to download the develop branch from energenie-ener314rt dependency as well. (sort of) instructions for doing this are in the FAQ

Auto-reporting

This version also contains a rudimentary method for obtaining more telemetry from the thermostat (rather than just WAKEUPs!); it works by capturing the last THERMOSTAT_MODE command issued via MQTT and then replaying it approximately every 2 minutes.

So... if you are using a gateway to also control the schedule it may mess things up by overriding the THERMOSTAT_MODE; you can avoid this happening by not changing the mode in HA.

DrOwl commented 6 months ago

I think this is stable enough now for you to test the 'develop' branch. NOTE: you will also need to download the develop branch from energenie-ener314rt dependency as well.

Okay i did:

 cd node_modules
 mv energenie-ener314rt{,.from-mqtt-2023-12-16}
 git clone https://github.com/Achronite/energenie-ener314rt.git
 cd energenie-ener314rt
 git branch -r
 git checkout -b develop origin/develop 
 ls
 cd C/energenie/
 ls
 vim trace.h 
 cd ../../
 node-gyp configure build
 apt-get install gpiod libgpiod-dev # Very useful comment thank you
 node-gyp configure build

Auto-reporting

This version also contains a rudimentary method for obtaining more telemetry from the thermostat (rather than just WAKEUPs!); it works by capturing the last THERMOSTAT_MODE command issued via MQTT and then replaying it approximately every 2 minutes.

So... if you are using a gateway to also control the schedule it may mess things up by overriding the THERMOSTAT_MODE; you can avoid this happening by not changing the mode in HA.

I wonder what the SWITCH_STATE does then, as that what i saw being used when using the app!

Id like to check if the auto sending T_M will overwrite physical button presses as that would not be ideal. Ill check if it sends out updates when the buttons are pressed or not.

Achronite commented 6 months ago

I've just checked; it looks like the on/off button does switch the thermostat mode. :( But it doesnt send out any updates when you do!

It would be good to know what the gateway does to get around this issue, that's why I was asking you about how does it update the telemetry. I need to think about this.... do you have any ideas?

DrOwl commented 6 months ago

I've just checked; it looks like the on/off button does switch the thermostat mode. :( But it doesnt send out any updates when you do!

It would be good to know what the gateway does to get around this issue, that's why I was asking you about how does it update the telemetry. I need to think about this.... do you have any ideas?

Ill do some testing

Achronite commented 6 months ago

I've also asked the author of the original code to see if he has any ideas: https://github.com/whaleygeek/pyenergenie/issues/135

Achronite commented 6 months ago

@DrOwl Any Updates? Is the integration running OK for you? Mine seems fine in 'without gateway' mode.

sgulati-hub commented 6 months ago

In my case Thermostat reports all the parameters (humidity, battery level etc) correctly on HA dashboard but changing the Target Temp in HA has no effect. However, if I change the target temperature via MiHome App (i.e. Mihome Gateway) it always takes effect within 10 to 30 seconds and then it reports updated Target Temp on HA as well. My setup is as following: 1) HA and mqtt-energenie-ener314rt are deployed on two separate raspberrypis. HA is deployed on Docker while mqtt-energenie-ener314rt is deployed directly on raspberry pi. 2) Using Develop branches of both mqtt-energenie-ener314rt and dependent module energenie-ener314rt. 3) Thermostat was automatically added on HA (no pairing etc was required).

Nb: Couple of other MiHome devices e.g. ENER010 (needed manual entry in HA config and pairing), MIHO005 are working perfectly fine.

Achronite commented 6 months ago

In my case Thermostat reports all the parameters (humidity, battery level etc) correctly on HA dashboard but changing the Target Temp in HA has no effect. However, if I change the target temperature via MiHome App (i.e. Mihome Gateway) it always takes effect within 10 to 30 seconds and then it reports updated Target Temp on HA as well. My setup is as following:

@sgulati-hub The temperature change works OK for me (without a gateway). Are you using the code that is on the develop branch of both this and the energenie-ener314rt repositories? I've made a lot of changes from the released code.

sgulati-hub commented 6 months ago

me

In my case Thermostat reports all the parameters (humidity, battery level etc) correctly on HA dashboard but changing the Target Temp in HA has no effect. However, if I change the target temperature via MiHome App (i.e. Mihome Gateway) it always takes effect within 10 to 30 seconds and then it reports updated Target Temp on HA as well. My setup is as following:

@sgulati-hub The temperature change works OK for me (without a gateway). Are you using the code that is on the develop branch of both this and the energenie-ener314rt repositories? I've made a lot of changes from the released code.

Yes, I am using develop branches for both repositories. Is there any specific configuration for 'without gateway' mode?

Achronite commented 6 months ago

Is there any specific configuration for 'without gateway' mode?

No. How we understand it is a thermostat only sends data If it is requested to. So if a thermostat is installed without a gateway then it never reports telemetry data.

To get round this issue, I store the latest value of the 'thermostat mode' command sent (from HA this is via heat/off). Each THERMOSTAT_MODE value will be stored (until a restart) and will be used to prompt the thermostat into providing it's telemetry data; this is usually every 2 minutes.

Using this approach could have the effect of overriding any mode set by the MiHome gateway / App. Maybe there is something similar on the gateway - So IT could be overriding your commands sent from HA?

sgulati-hub commented 6 months ago

@Achronite Thermostat controls are working for me after switching off the gateway. As you mentioned probably gateway was somehow overriding HA commands.

Achronite commented 6 months ago

@DrOwl @sgulati-hub I have a couple of question for you to test with your gateways.

1) Can you please test manually switching the thermostat on/off (using the power button on the thermostat) and let me know if the app/gateways deals with this correctly and doesn't override the thermostat mode?

If it does deal with it OK, then it must have a way of retrieving the telemetry data without changing the thermostst state....

2) Can you please do the following: a) remove the batteries from the thermostat b) start capture of a trace from this code c) issue a thermostat mode change via the MiHome app (to see if this code captures any commands issued by the gateway) d) wait a couple of minutes, then stop the trace capture

Hopefully with a combination of both of these we can get to the bottom of how the MiHome app works with the thermostat which can then be replicated here.