There will be two parts in this post: descriptive and question.
Part I: My configuration
I have AUX ASW-H09A4 WiFi air conditioner (further AC). I chose it especially to work with home assistant (further HA). It has Broadlink WiFi module.
It worth mentioning that I installed python version of HA to have minimal footprint and be able to make rapid update (but that’s another story).
This article assumes you already have mosquitto MQTT broker configured and users added.
To control my AC unit I use this script here: https://github.com/liaan/broadlink_ac_mqtt
Here’s my service file (
/etc/systemd/system/ac_mqtt.service) for this script:
[Unit] Description=AC connection service After=syslog.target network.target ha.service PartOf=ha.service [Service] WorkingDirectory=/opt/broadlink_ac_mqtt ExecStartPre=/bin/sleep 20 ExecStart=/opt/homeassistant/bin/python3 /opt/broadlink_ac_mqtt/monitor.py -b Restart=on-failure RestartSec=60s [Install] WantedBy=multi-user.target
This service has it’s own config file which should be located in
<workdir>/settings (in my case
/opt/broadlink_ac_mqtt/settings) or specified via command line.
Here’s my config file with some placeholders:
service: daemon_mode: True update_interval: 10 self_discovery: True bind_to_ip: False mqtt: host: 127.0.0.1 port: 1883 client_id: ac_to_mqtt user: <mqtt user, added in mqtt broker> passwd: <your passord here> # Line below shows where in mqtt you will search for AC messages # feel free use name to your liking topic_prefix: /aircon auto_discovery_topic: homeassistant auto_discovery_topic_retain: False discovery: False ##Devices devices: - ip: 192.168.0.10 (or any other IP you/dhcp like) mac: <here should be mac of your AC, I looked my up in DHCP> name: climatic_ctrl port: 80
In HA I have my AC device, which can be added to lovelace UI or controlled via automations.
– Up until this line everything works -------------------
Part II: This should work…
The issue I’ve been having is that if HA service restarts (or starts) after ac_mqtt is started, then HA show it unavailable. Once again:
- Start HA.
- Start ac_mqtt
- everything fine.
- Restart HA
- air conditioner controls unavailable.
I’m relatively new to HA, so I have a question: What will be the best way to resolve this?
Things that crossed my mind:
ac_mqttservice dependant on ha service in system - works so-so, doesn’t shine when HA gets restarted from UI.
airconentity state and on
shell_scriptto restart services - seems a little clumsy.
Would be glad to hear any suggestions.