Closed catalinbordan closed 4 years ago
Hi. Here is my working config `service: daemon_mode: True update_interval: 10 self_discovery: false
mqtt: host: 192.168.1.110 port: 1883 client_id: ac_to_mqtt user: user passwd: pass topic_prefix: tele/aircon discovery: true auto_discovery_topic: homeassistant auto_discovery_topic_retain: true
devices:
Hello, thank your time. I can see that on topic prefix you have something else. I will try right to see it is from here Regarding your last remark, I don't know where to look. can you please provide more details (I'm noobhere in this area) here it is what I see in mqtt explorer
Topic prefix just config. I provide screenshot with mqtt explorer in other issue (50), check it. Im not near laptop right now..
it is not working :( with tele/aircon in front. but now I have a new grup like in the picture but I can see the messages are not retained. also I can see some improvement because I have discovered some messages retained that I have deleted and now when I stop/star monitor.py I do not hear the unit make beep(receiving commands). So I am on a good track. It must be something with my broker settings I have the addon Mosquitto broker with this settings: logins: [] anonymous: false customize: active: false folder: mosquitto certfile: fullchain.pem keyfile: privkey.pem require_certificate: false
and nothing that I know in configuration.yaml
It must be something here because also entities from tasmota do not keep state and I have to wait tele messages(tele period messages) to be sent again by tasmota.
Topic prefix just config. I provide screenshot with mqtt explorer in other issue (50), check it. Im not near laptop right now..
Aha, so this is it? As i can see it is not retained. in fact no messages are retained from aircon. I will search your screenshot to see if I understand.
later edit: I have checked your picture and I can see that my messages are not retained. why...? I don't know. I can only tell that before changing the prefix from aircon to tele/aircon that I have found a category named aircon with a lot of messages retained(i have deleted) wich explain why when i was starting monitor.py my unit AC was receveing commands(temperature and fan settings)
I'll try to explain.
You have 'discovery' topic and 'telemetry' topic (state and command).
Discovery topic keep messages with says HA info\configuration about your device, like name, type, modes list and path to the telemetry topic.
Telemetry topic (topic_prefix: xxx
) contain messages with current state of you device. Here HA get any values and send commands.
Messages in discovery topic (monitor: auto_discovery_topic: homeassistant
and the same topic name in HA configuration) must be retained - HA needs to know info about device (tasmota messages are retained too as you can see)
Messages in 'telemetry' topic don't need retain if your device update it (like telemetry period).
There are 3 possible problems (in my opinion):
The best way just debug your bam copy :)
@mrekin thank for sharing your knowledge. I undestand a little bit and I am trying to make analogies with practical examples to understand better this technical words and ideas. until you write the message I search on internat how to retain message in broker and I found some guys that to solve the issues it retained messages they have deleted the add on to clear the database of mqtt messages. so I have deleted the add on, then the integration, then restart the HA, start add on, then configure the integration, then start the monitor.py. now in mqtt explorer I can see that the config topic it is retained. so to test it, I have made the restart of HA. Again the states of my climate it is empty and I can not push any button on climate. (later edit) actually I can go to change the fan settings (status remain)(speed is changing but the the mode is empty and is I change it it comes back to empty. pls see the image I check again the mqtt explorer and I can see that the topic config it is not anymore retained. But I have an ideea. I know tasmota is sending from 5 to 5 min the tele topic. Should not do the same also monitor.py? I can see that I have received almost 69 messages in less than half hour(many with fan speed change by me) when a tasmota sensor(am2301 temperature) is sending almost 131 messages. Or monitor.py is checking for changes and send only changes?
Bam is shorted broadlink_ac_mqtt :) Let me check tomorrow again. You might be right - my mqtt broker can contain retain messages in tele topic from the old test with code. I will do clean test. But why your messages in discovery topic stay/changed to not retained - I have no idea now. (May be you have another one monitor instance which send not retained messages?) I use standalone mqtt broker, but i dont think it causes.
Morning
sorry , not read whole thing
I updated lot of the code for HA . I know what the issue is regarding keeping entity between restarts (its almost working), but need to discuss what best options.. I will add disccord link soon
Few changes made
Its shows up as device now:
After restart, the device stays online, but data of device is not there (this is cause mqtt don't send all data each update), only new values gets shown in HA
Its still bit buggy, just working out some kinks .. then we can discuss best approach forward to make it work 100%
Please join on https://discord.gg/j6JN6s
Hi. Get clean test in my env and get the same situation. I think we need to set retain to all messages, not only broadcast. As i remember, monitor publish only if new values not the same last published. So after restart HA dont see actual values until anything changed. Broker store only last retained message in topic, so there are no problem with mass messages/storage.
Or we can set retained only first message after start, but if HA will restart with a big delay- values will not actual
@mrekin
The problem with retain is just that .. always retain, even if you remove the device. Only way to remove it is to do manual MQTT server cleanup when you remove the device (or the mac changes)
I added commond now todo force refresh of all values. Busy chatting on discord to see how to make HA to publish the command on status change of the device
mosquitto_pub -h mqtt.wonderland.internal -t "/aircon/b4430da741af/state/set" -m "refresh"
@liaan I don't think external refresh command is best way, if HA not support it out of the box. Retain for tele topics not big problem - HA must check discovery topic and LWT. But yes - mqtt broker will have additional garbage if device not used. upd: now i set retain for all publishing messages (discovery\tele\LWT) in my repo (i don't change any variables names and so on) as temporary workaround.
HA don't have any nice options for device state change .. so there no real option to do a "refresh" without doing it with manual automation and system restart trigger. This is pia
I simple forcing all values update every update_interval. Its not much more traffic on MQTT as default is only 10 seconds. I tested now all all working between restarts on HA. If its to much traffic, one can up the update interval to longer.
I still need to check of the retain on config publish is still needed, i'm assuming it is
Latest version with fixes is
./monitor.py -v
Monitor Version: 1.0.16, Class version:1.1.1
I simple forcing all values update every update_interval. Its not much more traffic on MQTT as default is only 10 seconds. I tested now all all working between restarts on HA. If its to much traffic, one can up the update interval to longer.
Yep, this is another way :)
@catalinbordan
Can you pull latest code (not sure if the docker has been updated) and check if worknig as expected now. It should be at most 10 seconds after HA restart that the status is correct (if update_interval is still on 10s)
@liaan sorry for delay, I had a busy day at work What I can say, You are awesome. You dit it! It works after restart. No more going to vbox to stop/start monitor.py
I have a laptop with win10 and virtualbox with 2 guests: one for hass os and one with xubuntu to run this script on terminal( on win, python do not want to install the dependency addons for this python script to work. So until now I did not know about the docker(already have a docker and docker-compose install for another integration of a inverter) or a possibility put on the same guest of hass os. I should investigate how to do it in HA, to not use another VM.
So to have a new fresh start, I stop the monitor.py(old version), delete with the help of mosquito explorer all the topics, download the last sources, put the old configuration file like @mrekin example and start it. It works even I restart the HA or wifi. did multiple restart of HA to be sure :)
Thank you for your efort and suport!
@catalinbordan Script works on win10, but need to install other dependencies (crypto). Need to remember them and add to description
@liaan sorry for delay, I had a busy day at work What I can say, You are awesome. You dit it! It works after restart. No more going to vbox to stop/start monitor.py
I have a laptop with win10 and virtualbox with 2 guests: one for hass os and one with xubuntu to run this script on terminal( on win, python do not want to install the dependency addons for this python script to work. So until now I did not know about the docker(already have a docker and docker-compose install for another integration of a inverter) or a possibility put on the same guest of hass os. I should investigate how to do it in HA, to not use another VM.
So to have a new fresh start, I stop the monitor.py(old version), delete with the help of mosquito explorer all the topics, download the last sources, put the old configuration file like @mrekin example and start it. It works even I restart the HA or wifi. did multiple restart of HA to be sure :)
Thank you for your efort and suport!
Glad you got it sorted!
Still need to think how to make the installs simpler, but for now I think docker is the simplest, it should always be up to date with the latest releases
Can I close this issue?
@liaan yes please. Indeed it will be great to use in HACS, or to find a way to add as a docker in HASS OS. I will try to figure out how to use the docker provided by Backslashh, but for me it is like chineze the instructions to install it.
@Backslashh , possible you can assist @catalinbordan with docker installation?
@catalinbordan , you can join discord server at https://discord.gg/Un7FW3X to ask for help bit more realtime
Closing, asume all werking
Hello,
It is possible to do something settings in code or my HA to keep climate entity between restart? I have this configuration:
mqtt: host: 192.168.0.2 port: 1883 client_id: ac_to_mqtt user: mqtt passwd: pass topic_prefix: /aircon auto_discovery_topic: homeassistant auto_discovery_topic_retain: True discovery: True
Devices
devices:
If I put self_discovery: true in HA I have a climate climate.unnamed_device and when HA having a restart I have to stop/start monitor.py When I am stop/start monitor.py the AC make beep sound like receiving commands and I found the climate on fan low setting (not last state). Some time it give me this error: "AcToMqtt object has no attribute 'device objects'" when I start monitor.py If I put self_dicovery false I have the name of AC put in config on HA climate entity, but still I need to stop/start monitor between restart of HA If I put in configuration.yaml of HA the manual entity for climate, then I will have 2 climate for the same unit after restart(xxx_2). Also need to stop/start after of a restart. If I also put discovery:false, still I have 2 climate entity. and also after restart I need to stop/start monitor.py That's the tests I made so far. Hope it is usefull.
Others errors: network time out from time to time. If network it is down for some reason(router restart for example) I have to go to start again the monitor.py because it is closed. Even if I not having monitor.py with debug option the log file it is growing to big(1.5gb - 3gb). It can take all the space on hdd