liaan / broadlink_ac_mqtt

Broadlink Air Conditioners to mqtt
MIT License
100 stars 43 forks source link

current ac temp #1

Closed makleso6 closed 4 years ago

makleso6 commented 5 years ago

Hello! Thanks for library! Its helped me a lot!! is it possible to check internal sensor temperature of AC? (0x4E2a) if payload 1900bb00070000000f000111672010a0000000000000100000a62d9175160165 internal temp is 21

if payload 1900bb00070000000f000111672015a0000000000000100000a12d9175160165 internal temp is 22

difference in byte 14 and 25

I can't find combination to check temp, may be you can help me?

wjbeckett commented 4 years ago

this would be amazing. If the temperature sensor could be leveraged then this could easily be added into Home Assistant as a Generic Thermostat.

@liaan, Any chance there's a way to expose the temperature sensor?

liaan commented 4 years ago

Hi, The other temps seem to use a offset . 0 => 16 and 01->17 (if I recall) with another bit to set the 0.5 . I will try have a look at this again, not touched this code since i've done this 2 years ago so bit rusty

wjbeckett commented 4 years ago

@liaan I completely appreciate how long it's been. Thank you for replying at all.

This is the only way I've been able to get my Home-Assistant to interface with my Rinnai Air Conditioners so I am unbelievably grateful for this. As there is no Home-Assistant component written for these types of Air Conditioners this is the best way I can think of integrating them.

I would love for an integration with Home-Assistant so these AC units will show up as climate devices and have proper usability but this would still work if the temp sensor could be utilised too.

I also noticed the program breaks when an incorrect command is sent and it doesn't restart. Is there a way to dump the error but continue on so the program can continue to run?

liaan commented 4 years ago

I know it just crashes and don't continue ... I just walk to my berry and reboot it .. could never bother to fix it.

The errors should log into a file in same folder. Once can probably then use the try/catch to restart the main routine (python is not my normal day to day language, so will need to figure out how to catch/restart). I know my biggest issue is when the network have a dip and timeout happens, then all just stop.

I hacked the temp sensor for our environment control by using a Sonoff with ds1820 reading current temprature just cause I had the sensor already before writing this

wjbeckett commented 4 years ago

Ah fair enough. I did experience that timeout a couple of times, but like you said, I just restart the program again. I was only making that comment as a nice to have.

I would just take the same approach and use an external temp sensor - I just don't have any laying around so thought that if it wasn't too much trouble to expose the temp sensor of the unit itself then that would be amazing.

liaan commented 4 years ago

ok, had quick look at this . I cannot find the temprature bit yet (my house is bit constant so difficult to find any changes).

If you run the monitor.py with -d flag , it will do full debug logging into error.log file with the actual status printed in bit format. Maybe one of you can see the bit that changes with temperature. I know there 1 or 2 bytes that is like "timetamp" or "serial" that changes each time, so difficult to trace

sample output: [ac_db.py:699] 00010001 10001111 00100110 00011010 10100000 00000000 00100000 00000000 00000000 00100000 00000000 00010000 00000000 00000000 01010100 00000111 00100010 10010101 10111100 10000110 10010010

liaan commented 4 years ago

ok,

Found 1 value that is the same as what is displayed on the app in standby mode. Not sure if the value is correct for ambient while things are running. . busy testing that

liaan commented 4 years ago

ok,

Found 1 value that is the same as what is displayed on the app in standby mode. Not sure if the value is correct for ambient while things are running. . busy testing that

Ok

All looking good. Been running for while and both arcons tracking temps correctly

Published under abient_temp on mqtt

makleso6 commented 4 years ago

Many thanks!

wjbeckett commented 4 years ago

Amazing! Thank you!!

wjbeckett commented 4 years ago

Now I need to figure out how to make this into a Home Assistant integration.😁

liaan commented 4 years ago

Now I need to figure out how to make this into a Home Assistant integration.😁

Sorry, I cannot help there .... just did quick google and found this: https://www.home-assistant.io/integrations/climate.mqtt/ .. not sure if might work?

liaan commented 4 years ago

@liaan I completely appreciate how long it's been. Thank you for replying at all. This is the only way I've been able to get my Home-Assistant to interface with my Rinnai Air Conditioners so I am unbelievably grateful for this. As there is no Home-Assistant component written for these types of Air Conditioners this is the best way I can think of integrating them. I would love for an integration with Home-Assistant so these AC units will show up as climate devices and have proper usability but this would still work if the temp sensor could be utilised too. I also noticed the program breaks when an incorrect command is sent and it doesn't restart. Is there a way to dump the error but continue on so the program can continue to run?

I made the error now exit the monitor.py script completely (not just half fail) .. so you need to have the system restart it either via cron every 1 minute (there is a check in the monitor.py to prevent duplicates) or you need to make shell wrapper of some sort to restart the script on crash. My cron:

* * * * * root /root/ac_db/monitor.py&

I don't have the energy to learn python error handling , python is Pyin in the arThon.

wjbeckett commented 4 years ago

I have my ac usints working via the MQTT climate integration and it's working well. But I have some issues with the power off command sending mulltiple times and breaking the script.

I also have a problem where the modes don't exactly match up to the commands monitor.py accepts. For example, the climate integration can accept modes of "auto, "heat", "cool", "off" (in that exact case) whereas monitor.py looks for "AUTO", "HEATING", "COOLING", "OFF". I've not found an elegant way to translate that so while it does work, it's not stable enough really.

liaan commented 4 years ago

Ja, multiple times seems to timeout , the ac units are not very good at fast packet processing

Let me check the lower case thing .. maybe can just add topic for with lower case

liaan commented 4 years ago

I have my ac usints working via the MQTT climate integration and it's working well. But I have some issues with the power off command sending mulltiple times and breaking the script. I also have a problem where the modes don't exactly match up to the commands monitor.py accepts. For example, the climate integration can accept modes of "auto, "heat", "cool", "off" (in that exact case) whereas monitor.py looks for "AUTO", "HEATING", "COOLING", "OFF". I've not found an elegant way to translate that so while it does work, it's not stable enough really.

I added topic "homeassist" (hope spelling correcT) with auto, heat, cool, off commands

MQTT topics 
SET  aircon/b4430dce73f1/homeassist/set
Current  aircon/b4430dce73f1/homeassist/value
wjbeckett commented 4 years ago

I have my ac usints working via the MQTT climate integration and it's working well. But I have some issues with the power off command sending mulltiple times and breaking the script. I also have a problem where the modes don't exactly match up to the commands monitor.py accepts. For example, the climate integration can accept modes of "auto, "heat", "cool", "off" (in that exact case) whereas monitor.py looks for "AUTO", "HEATING", "COOLING", "OFF". I've not found an elegant way to translate that so while it does work, it's not stable enough really.

I added topic "homeassist" (hope spelling correcT) with auto, heat, cool, off commands

MQTT topics 
SET  aircon/b4430dce73f1/homeassist/set
Current  aircon/b4430dce73f1/homeassist/value

Amazing! Is it possible to update the fanspeed one too? Homeassistant expects: auto, low, medium, high

Could the mode topics be:

SET aircon/b4430dce73f1/homeassistant/mode/set
CURRENT aircon/b4430dce73f1/homeassistant/mode/value

Just so there is still the definition that it's the mode.

And for fanspeed:

SET aircon/b4430dce73f1/homeassistant/fanspeed/set
CURRENT aircon/b4430dce73f1/homeassistant/fanspeed/value

Thankyou again so much for this. I'll test it out and see how I go. I may need some.helpnwith the power issue, but we'll see.

The main issue is that home assistant expects that when you see the mode, it will turn the power on if it's off. So I have an automation to send the power command first, followed by the mode select.

Do you know if there is any way to make that happen within the one topic/command?

liaan commented 4 years ago

I have my ac usints working via the MQTT climate integration and it's working well. But I have some issues with the power off command sending mulltiple times and breaking the script. I also have a problem where the modes don't exactly match up to the commands monitor.py accepts. For example, the climate integration can accept modes of "auto, "heat", "cool", "off" (in that exact case) whereas monitor.py looks for "AUTO", "HEATING", "COOLING", "OFF". I've not found an elegant way to translate that so while it does work, it's not stable enough really.

I added topic "homeassist" (hope spelling correcT) with auto, heat, cool, off commands MQTT topics SET aircon/b4430dce73f1/homeassist/set Current aircon/b4430dce73f1/homeassist/value

Amazing! Is it possible to update the fanspeed one too? Homeassistant expects: auto, low, medium, high Could the mode topics be: SET aircon/b4430dce73f1/homeassistant/mode/set CURRENT aircon/b4430dce73f1/homeassistant/mode/value

Just so there is still the definition that it's the mode. And for fanspeed: SET aircon/b4430dce73f1/homeassistant/fanspeed/set CURRENT aircon/b4430dce73f1/homeassistant/fanspeed/value

Thankyou again so much for this. I'll test it out and see how I go. I may need some.helpnwith the power issue, but we'll see. The main issue is that home assistant expects that when you see the mode, it will turn the power on if it's off. So I have an automation to send the power command first, followed by the mode select. Do you know if there is any way to make that happen within the one topic/command?

I'm just off to lunch .. will check what I can do later or tommorrow

Currently if you sent Mode Heat, it will switch it the mode to Heat AND switch it ON .. , same with cool/fan. Off switch all off.

I probably should go check how the plugin works :)

wjbeckett commented 4 years ago

Oh, if sending the mode also sends the power then that should be all I need. I'll give it a crack and see how it goes with the new mode and fanspeed topics.

Thanks again!

wjbeckett commented 4 years ago

Okay, so how it's configured now, works perfectly! No errors and it perfectly integrates with Home-Assisstant.

No need to add the topic for fanspeed. Just leave it as it is now. 😊

liaan commented 4 years ago

Okay, so how it's configured now, works perfectly! No errors and it perfectly integrates with Home-Assisstant. No need to add the topic for fanspeed. Just leave it as it is now. 😊

Excellent!

i installed homeassist last night (what a mission) and noticed it works okish. could be better :)

i'm workin on redoing the logic on this service so its more stable and don't redo discovery's etc each time but one can use config files or at least save the discovered devices between restarts.

Can I close this issue for now ?

wjbeckett commented 4 years ago

Ah nice. I'm finding that it is stopping quite frequently..not sure why - I assume from the timeout issue.

That sounds great. Once it's stable we could look at an official integration maybe.

Anyway, super happy with this now it's at least more stable than it was before.

Thanks again, and yeah - close this issue off.

liaan commented 4 years ago

I found 2 bugs so far .. one is in the VERY old paho library (1.0.0) it uses that dont' close the threads properly on mqtt server disconnects causing cpu/mem leak over time, moved it now to use the latest paho library ("pip install paho-mqtt") where its apparentley fixed.

also had status field missing on first start, so sometimes crashed if timing was correct

Added config files added update interval to reduce device network load. seems less timeouts now

Busy testing, will push code during the week