liaan / broadlink_ac_mqtt

Broadlink Air Conditioners to mqtt
MIT License
101 stars 44 forks source link

how to install this? #63

Closed xally-pt closed 3 years ago

xally-pt commented 3 years ago

I'm using home assistant, tried a lot of stuff but nothing seems to be working. I can't see the output in mqtt explorer for the settings in HA card, but can't communicate with the AC. The only info from the ac I got is the IP and Mac address. I've added the AC units to AC_freedom app with no problems, but can't manage to work in HA.

Can anyone please help?

liaan commented 3 years ago

Hi,

The simplest is to use the docker version of this https://github.com/broadlink-ac/broadlink_ac_mqtt_docker

This service simply discover the AC and send the info to MQTT where HA then pickup the MQTT config (if HA is setup for MQTT discovery) and start managing it.

So first you need to check if you can see the AC using ./monitory -S .. it should dump something like:

`*** start copy below **** devices:

If you don't see this, make sure the device you running monitor.py is on the same network segment as the AC

xally-pt commented 3 years ago

I've install the docker and the result was an error. I've changed the config.yaml in the configuration directory with the user; password and ip + mac of my ac. but the result is an error.

"[cont-init.d] 10-adduser: exited 0.

[cont-init.d] 30-config: executing...

Config file exists already

Already at latest version

[cont-init.d] 30-config: exited 0.

[cont-init.d] 99-custom-files: executing...

[custom-init] no custom files found exiting...

[cont-init.d] 99-custom-files: exited 0.

[cont-init.d] done.

[services.d] starting services

[services.d] done.

Starting Monitor...

[Errno -2] Name does not resolve

Stopping"

liaan commented 3 years ago

Check the MQTT server name, it seems like its not resolving correctley.

[Errno -2] Name does not resolve

From: xally-pt notifications@github.com Sent: Tuesday, 08 December 2020 18:45 To: liaan/broadlink_ac_mqtt broadlink_ac_mqtt@noreply.github.com Cc: Karman de Lange liaan@vpx.co.za; Comment comment@noreply.github.com Subject: Re: [liaan/broadlink_ac_mqtt] how to install this? (#63)

I've install the docker and the result was an error. I've changed the config.yaml in the configuration directory with the user; password and ip + mac of my ac. but the result is an error.

"[cont-init.d] 10-adduser: exited 0.

[cont-init.d] 30-config: executing...

Config file exists already

Already at latest version

[cont-init.d] 30-config: exited 0.

[cont-init.d] 99-custom-files: executing...

[custom-init] no custom files found exiting...

[cont-init.d] 99-custom-files: exited 0.

[cont-init.d] done.

[services.d] starting services

[services.d] done.

Starting Monitor...

[Errno -2] Name does not resolve

Stopping"

- You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fliaan%2Fbroadlink_ac_mqtt%2Fissues%2F63%23issuecomment-740751987&data=04%7C01%7C%7C78b72035a7f64b679a3608d89b98893c%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637430426724513345%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=nPeUDtYGQLdezc%2BMr7hgBuz2iloawatCVSvU47tsaXE%3D&reserved=0, or unsubscribehttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAAGTCXYKUI3KZRR2U2A54T3STZJW5ANCNFSM4UPM4Q4Q&data=04%7C01%7C%7C78b72035a7f64b679a3608d89b98893c%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637430426724513345%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=tfaGKXIcCL9YGx4FghiqHkS6%2FTUZ7tX0oKSW2LyFPR0%3D&reserved=0.

xally-pt commented 3 years ago

Sucess... yes finally some hope!

After setting the host, still no luck, but when I set "self-discovery: False" and added the ip's (mac's, ports and names) under devices it started to get replies from the ac units, all of them.

Now i know this works and that my ac's can communicate with something else than the app in my smartphone. Nice work you're the best!!! I don't know nothing about programming and i'm so excited with your work.

I think i've tried everything in HACS and HA repositories related to ac's and broadlink, and nothing seemed to work. Anyway now my problems are, I have docker running in my mac and HA in a Raspi4. Can I run this only in my pi? When I reboot the Home Assistant, i have to come back to docker to stop and run it again. I Even get the HA Add-on package for your code, but never get it to work. Is this add-on an all in one solution for the HA? Can I find the config.yml in HA like in docker? For now all I've configured was the "configuration" tab.

this is the log from the add-on when executed

[s6-init] making user provided files available at /var/run/s6/etc...exited 0. [s6-init] ensuring user provided files have correct perms...exited 0. [fix-attrs.d] applying ownership & permissions fixes... [fix-attrs.d] done. [cont-init.d] executing container initialization scripts... [cont-init.d] done. [services.d] starting services [services.d] done. Copy this in your configuration.yaml: Traceback (most recent call last): File "./monitor.py", line 7, in import yaml ImportError: No module named yaml [cmd] /run.sh exited 1 [cont-finish.d] executing container finish scripts... [cont-finish.d] done. [s6-finish] waiting for services. [s6-finish] sending all processes the TERM signal.

liaan commented 3 years ago

HA add on ? Never wrote something like that, maybe it was split from this code... Do you have link please so I can have a look

The error you get now is cause pyyaml is not installed.. on the read me you will see what need to be installed.:

uses Pahoo MQTT so run :

pip install paho-mqtt
pip install pyyaml
pip install PyCrypto

you can run all on same raspberry. Just make sure mqtt is installed. HA is setup to use MQTT and MQTT discovery and clone this repository (or use the docker image).
I simply have cron calling monitor.py every minute to make sure it starts up.

Regarding having to restart the service to make HA see it again , it should rediscovery automatically after 60 seconds (if I recall), you can reduce this in the config file.

L:

xally-pt commented 3 years ago

I've already installed the dependencies you have listed, all seems to be installed except for the last one. I've search for how to install it in HA, and it seems that it's no longer accepted or allowed since is an "old unsecured library".

about the add-on here's the link : https://github.com/elmerenges/broadlink_ac_mqtt_addon

I simply have cron calling monitor.py every minute to make sure it starts up.

How do you do that? how do I write that in HA configuration.yaml.

clone this repository (or use the docker image).

What do you mean with this? I should install a docker in a raspi4 and instal one container with your repository, and another with Home Assistant? or do you mean run your repository in a docker inside the Home assistant?

xally-pt commented 3 years ago

Hello again, I've managed to get this working, but I'm struggling in making it auto-restarting correctly.

I have a docker running in a raspberry pi 4, with home assistant inside containers and your image in another container.

All the images are set to "restart unless-stoped"

And when I restart, they are all there running but not showing any inormation in the HA until I restart the broadlink_ac_mqtt container.

This happens because at boot the mqtt broker is not up at the same time that the broadlink_ac_mqtt, and for that reason it remains stuck with something like "host not found".

I've research about delaying the container start but it's quite confuse since I don't have any docker or docker-compose experience.

Is it possible to make anything in your code that could perform this delay?

Do you have any suggestions on this?

liaan commented 3 years ago

Hi, sorry , been on leave for a while ..

ummm.. I'm actually have no clue about docker .. //Asking the expert and docker repo guy ;-) @Backslashh, do you maybe know if you can setup docker image to be dependended on a nother docker before starting?

wjbeckett commented 3 years ago

@xally-pt how are you controlling your docker containers? Are you using docker-conpose? If so, adding depends_on: will make the container wait for the depended upon container before it starts.

So it should look like:

depends_on:
  - mqtt

The "mqtt" in the above is the name of the mqtt container. The depends on block above should go in the ac2mqtt docker config.

xally-pt commented 3 years ago

Hi @Backslashh , I wasn't using anything to control my containers, I've just set them to start automatic in docker. It's my first time using docker. and I have it installed in a raspberry pi4 and im running it trough ssh command line. I don't know how to use docker compose. I've come with a workaround, installing Portainer to manage the containers with a graphical interface, and with HA-dockermon. The last one let's me run/stop, and see the status of the containers from HA. Right know what I do is start Home Assistant, and after a few minutes, I switch the container to ON and it's working. One other thing I notice is that, if immediately turn it on after Home assistant starts it won't start. I think mqtt broker is even slower than home assistant. I'll see if I can use the "depends on" in Portainer and let you know the result. @liaan This is working fine for me, but with a lot of workaround, I thing most HA user will give up. I don't know nothing about programming, but it seem the problem in HA is that you are using Pycrypto and wich is not allowed to install, can't you write the code without these? That would be a lot more easier, and I can tested if you like. Btw you can add "Baxi ANORI" using "Wi-Fi TXAC" (adapter using the broadlink) to the list of Compatible AC's.

xally-pt commented 3 years ago

Here's my system running screenshot 👍 You can see a switch to enable the container, and a sensor indicating uptime.

Captura de ecrã 2021-01-09, às 18 53 17 2

liaan commented 3 years ago

Closing this as seems to be resolved?

hwcconde commented 3 years ago

I've already installed the dependencies you have listed, all seems to be installed except for the last one. I've search for how to install it in HA, and it seems that it's no longer accepted or allowed since is an "old unsecured library".

about the add-on here's the link : https://github.com/elmerenges/broadlink_ac_mqtt_addon

I simply have cron calling monitor.py every minute to make sure it starts up.

How do you do that? how do I write that in HA configuration.yaml.

clone this repository (or use the docker image).

What do you mean with this? I should install a docker in a raspi4 and instal one container with your repository, and another with Home Assistant? or do you mean run your repository in a docker inside the Home assistant?

The addon link seems to be broken, which is a pity. That's exactly what I was looking for

TommisGR commented 2 years ago

There is also this https://github.com/emosenkis/broadlink_ac_mqtt_addon but dont know how to go about using it