python-eq3bt
python-eq3bt copied to clipboard
Provide asyncio interface for homeassistant
It likely doesn't make sense to convert the whole library to use asyncio, but providing a separate homeassistant-friendly interface could be fairly straightforward to implement.
See https://github.com/home-assistant/developers.home-assistant/pull/1412 and https://github.com/home-assistant/developers.home-assistant/pull/1412#issuecomment-1194723457 for best practices.
I just read https://developers.home-assistant.io/docs/network_discovery/ but it is not 100% clear to me what is needed here.
Do I understand correctly that the BLEDevice
instances need to be passed from homeassistant to the eq3bt library?
@rytilahti Friendly ping!
Hi @TechHummel, sorry for the delay and thanks for the remainder!
Yeah, my understanding is also that the way to handle this would be by passing the BLEDevice
created by homeassistant to this library, use it for the update cycle, toss it, and re-do the same procedure on the next cycle. As that doesn't map nicely to the existing API (performing connect on __enter__
), it might make sense to create a very lightweight pure-bleak, asyncio interface separate from the existing ones that wraps the synchronous thermostat.
I created previously https://github.com/home-assistant/core/pull/74864 to modernize the code base, but I'm currently occupied with other things so I have no time to look into that until very late autumn or so...
I am looking into this, but I am currently blocked https://github.com/hbldh/bleak/issues/946. Will let you know about any progress.
Hi! I am hitting the same issue here.... I will start checking out this. Any progress on this?
Sadly not! Not sure what's causing the issue!
do you have your implementation working on the latest homeassistant? it seems that they want that you don't use the BleakClient() directly, instead the BLEDevice(). I am quite new with the Bleak library too.
It seems that doings so, home assistant can handle multiple BLE python interfaces (what makes sense).
I can use your package as an standalone application (without Home assistant), but once that I integrate it I can't use the functionality, and now I am trying to learn how to debug it :)
No, I don't have a working implementation! I am considering just using a MQTT bridge though!
mm, could me maybe a easier solution for the moment, but is quite unfortunate that after a home assistant update the things stopped working (my wife is quite piss off :P)
mm, could me maybe a easier solution for the moment, but is quite unfortunate that after a home assistant update the things stopped working (my wife is quite piss off :P)
It's super easy to downgrade HA via the SSH Plugin, worked great for me at least. Tho it's of course only a temporary fix. Make a full backup and download it, before sending this command to your HA.
ha core update --version 2022.6.7
Hope that helps to make your wife a bit happier again. ;-)
cheers, Kay
ha core update --version 2022.6.7
Hope that helps to make your wife a bit happier again. ;-)
I don't have a wife, but thank you very much. I'm happy now. Outside is cold and I need my thermostats working.
I made the downgrade but then other things stop work as I wanted (specially the new zigbee stuff). I will check more in detail all this but time is limited... (wife again) xD
I am using Home Assistant now on a downgraded version (2022.6.7) and everything works as it should. However, with every every release I feel the dire consequence of not being able to access the new features and also a bad feeling creeping in due to staying on an outdated version. Our whole apartment works fine with these thermostats and they consume almost no batteries, we recharge once every 18 months. I am more than happy and would love to support any kind of kickstarter request if any of the previous developers would be happy to assigns some valuable time to it.
This is no solution, but as a temporary fix, I switched to an bt-mqtt bridge, to work with home-assistant. https://github.com/zewelor/bt-mqtt-gateway
This is no solution, but as a temporary fix, I switched to an bt-mqtt bridge, to work with home-assistant. https://github.com/zewelor/bt-mqtt-gateway
Is there a way to run this on Hassio OS or did you use a separate Pi / PC for hosting this?
This is no solution, but as a temporary fix, I switched to an bt-mqtt bridge, to work with home-assistant. https://github.com/zewelor/bt-mqtt-gateway
Is there a way to run this on Hassio OS or did you use a separate Pi / PC for hosting this?
I have the same issue and the same question.
This is no solution, but as a temporary fix, I switched to an bt-mqtt bridge, to work with home-assistant. https://github.com/zewelor/bt-mqtt-gateway
Is there a way to run this on Hassio OS or did you use a separate Pi / PC for hosting this?
I have had the same issue and the same question.
It is hosted separately. For me it was just another VM, because my HA is also virtualized. It is a bit of a downside, but even if the HA integration is fixed, I will stay at the mqtt bridge. It is much faster, and pops out more usable data, like valve state.
Edit: seems like there is a HA addon version: https://github.com/FaserF/hassio-addons/tree/master/bt-mqtt-gateway
This is no solution, but as a temporary fix, I switched to an bt-mqtt bridge, to work with home-assistant. https://github.com/zewelor/bt-mqtt-gateway
Is there a way to run this on Hassio OS or did you use a separate Pi / PC for hosting this?
I have had the same issue and the same question.
It is hosted separately. For me it was just another VM, because my HA is also virtualized. It is a bit of a downside, but even if the HA integration is fixed, I will stay at the mqtt bridge. It is much faster, and pops out more usable data, like valve state.
Edit: seems like there is a HA addon version: https://github.com/FaserF/hassio-addons/tree/master/bt-mqtt-gateway
What I really liked about the solution via an integration was that it does not create more dependencies in form of further VM's and addons. It came out of the box and worked. 🥇
Btw, I was able to get the valve state from the original integration. Can look it up later if you are interested
like valve state
I can get valve level via template.
Everything from here can be gotten via templates.
Hello guys! It there any good changes in 2022.9.7? My HACS integration is dead now "You need HA version 2022.8.0 or newer to use this integration". And I understand further will come more and more problems with obsolete HA Core. It's annoying.
I am using Home Assistant now on a downgraded version (2022.6.7) and everything works as it should. However, with every every release I feel the dire consequence of not being able to access the new features and also a bad feeling creeping in due to staying on an outdated version. Our whole apartment works fine with these thermostats and they consume almost no batteries, we recharge once every 18 months. I am more than happy and would love to support any kind of kickstarter request if any of the previous developers would be happy to assigns some valuable time to it.
Just realised that one can actually support developers directly via github!
Hi all,
Meanwhile the issue is not resolved I found a temporal solution with a bluetooth to mqtt gateway. I hope it can help someone. I had mqtt configured previously. But if you don't have mqtt configured you should install the Mosquitto add-on previously. Then do the following:
- Set add-on repository on Home Assistant OS to https://github.com/faserf/hassio-addons
- Add user bt-mqtt-gateway in Mosquitto add-on or in Home Assistant with a password
- Install bt-mqtt-gateway and put the following into the file /share/bt-mqtt-gateway.yaml:
mqtt:
host: 192.168.1.2
port: 1883
username: bt-mqtt-gateway
password: ***
client_id: bt-mqtt-gateway
availability_topic: thermostat/lwt_topic
manager:
sensor_config:
topic: homeassistant
retain: true
topic_subscription:
update_all:
topic: homeassistant/status
payload: online
command_timeout: 35
workers:
thermostat:
args:
devices:
device1: 00:1A:22:xx:xx:xx
device2: 00:1A:22:xx:xx:xx
topic_prefix: thermostat
topic_subscription: thermostat/+/+/set
update_interval: 90
- Configure the devices with their mac addresses and start the add-on
Thanks to @faserf for the add-on development and to @zewelor for the bluetooth mqtt gateway development.
I've been using the MQTT gateway and it works great. However, since HomeAssistant introduced Bluetooth Proxies, I would love to have EQ3 over BT Proxy. May want to try to debug myself.
Hi all,
Meanwhile the issue is not resolved I found a temporal solution with a bluetooth to mqtt gateway. I hope it can help someone. I had mqtt configured previously. But if you don't have mqtt configured you should install the Mosquitto add-on previously. Then do the following:
- Set add-on repository on Home Assistant OS to https://github.com/faserf/hassio-addons
- Add user bt-mqtt-gateway in Mosquitto add-on or in Home Assistant with a password
- Install bt-mqtt-gateway and put the following into the file /share/bt-mqtt-gateway.yaml:
mqtt: host: 192.168.1.2 port: 1883 username: bt-mqtt-gateway password: *** client_id: bt-mqtt-gateway availability_topic: thermostat/lwt_topic manager: sensor_config: topic: homeassistant retain: true topic_subscription: update_all: topic: homeassistant/status payload: online command_timeout: 35 workers: thermostat: args: devices: device1: 00:1A:22:xx:xx:xx device2: 00:1A:22:xx:xx:xx topic_prefix: thermostat topic_subscription: thermostat/+/+/set update_interval: 90
- Configure the devices with their mac addresses and start the add-on
Thanks to @FaserF for the add-on development and to @zewelor for the bluetooth mqtt gateway development.
Stupid question, but where can I find the /share folder?
Hi all, Meanwhile the issue is not resolved I found a temporal solution with a bluetooth to mqtt gateway. I hope it can help someone. I had mqtt configured previously. But if you don't have mqtt configured you should install the Mosquitto add-on previously. Then do the following:
- Set add-on repository on Home Assistant OS to https://github.com/faserf/hassio-addons
- Add user bt-mqtt-gateway in Mosquitto add-on or in Home Assistant with a password
- Install bt-mqtt-gateway and put the following into the file /share/bt-mqtt-gateway.yaml:
mqtt: host: 192.168.1.2 port: 1883 username: bt-mqtt-gateway password: *** client_id: bt-mqtt-gateway availability_topic: thermostat/lwt_topic manager: sensor_config: topic: homeassistant retain: true topic_subscription: update_all: topic: homeassistant/status payload: online command_timeout: 35 workers: thermostat: args: devices: device1: 00:1A:22:xx:xx:xx device2: 00:1A:22:xx:xx:xx topic_prefix: thermostat topic_subscription: thermostat/+/+/set update_interval: 90
- Configure the devices with their mac addresses and start the add-on
Thanks to @FaserF for the add-on development and to @zewelor for the bluetooth mqtt gateway development.
Stupid question, but where can I find the /share folder?
You need to use terminal plugin and use vim / nano to edit the file. At least I didn’t find a way to do it via GUI
Hi all, As more and more people tend to look at this (broken) integration due to winter coming, I wanted to share my quick alternative to fix this issue without much hassle or custom integrations (MQTT is known to require configuration and altering .py files is also fairly complex). My take on this is simple: use 2 separate HASS instances (onw with latest version - the main one - and another using an older version - the remote one - which still allows the old bluez mechanism) To do this, you should:
- Install a separate HASS (even HassOS) image
- Add the eq3btsmart integration to the remote (old version) HASS
- Install and configure the Remote Home Assistant on both instances (https://github.com/custom-components/remote_homeassistant)
- Share the Climate devices from the remote HASS to the new HASS
It works, it simply works; the only problem is that you need separate hardware for the remote Hass, as you need BlueZ running on Host. I used an old RPi 3b+ for this and even allowed me to place it in the house so that it reaches via BT the required thermostats.
I consider this approach to be the easiest with almost no impact as you use a separate HW and it's really easy to "undo" once the eq3 (using Bleak) is updated - you just need to remove the auxiliary Remote HASS HW.
Hope this helps. PS: I tried with different approaches before taking this approach (tried altering the eq3 integration to work with bleak - complicated and has many many dependencies; tried writing a custom Py component to work with Eq3 Thermostats - too many flows and use-cases to be handled; also tried replacing the old py files (that work with BlueZ) in the latest HASS codebase - too many errors due to Core dependencies on Bleak) The MQTT approach works well, however I found it to be fairly unstable and I had to constantly debug it
I have good news and bad news.
Bad news
I know barely anything about custom integrations, bluetooth, asyncio and python, so there is no way I can send a meaningful PR. Particularly because my changes break CLI usage, and it also requires changes on the Home Assistant's component too.
Good news
I managed to hack something together
It still has some issues, so I'll try to fix them in the coming days. I hope somebody with more knowledge than me will eventually do it the proper way :) but in the mean time, I will make a temporary custom_component installable through HACS in the next 1 to two weeks.
Here you can find the HACS custom component.
https://github.com/dbuezas/eq3btsmart
I added some extra stuff like:
- Bluetooth autodiscovery
- Add via config flow
- ~~BTProxies support (just using the correct APIs)~~ (probably only in firmware < 1.20)
- retries
- ported everything to async
- fixed setting operation mode
- allowed to turn off by setting temp to 4.5°
- fetching schedules in HA
- (future) setting schedules via HA



My Apologies to @rytilahti for going this way instead of making a PR, I left my reasons in the readme (mostly that the changes I made were too many, and they break the CLI and other backends)
Hi @dbuezas ,
Thank you!! I have got 3 of these valves and it's working for two of them but it's not connecting to one of the devices and the following errors are showing:
Logger: homeassistant.helpers.entity
Source: custom_components/dbuezas_eq3btsmart/python_eq3bt/eq3bt/bleakconnection.py:97
Integration: dbuezas EQ3 Bluetooth Smart Thermostats
First occurred: 18 d’octubre de 2022, a les 23:14:42 (114 occurrences)
Last logged: 01:30:03
Update for climate.eq3_salon2 fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 515, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 718, in async_device_update
await task
File "/config/custom_components/dbuezas_eq3btsmart/climate.py", line 388, in async_update
await self._async_thermostat_update()
File "/config/custom_components/dbuezas_eq3btsmart/climate.py", line 381, in _async_thermostat_update
await self._thermostat.async_update()
File "/config/custom_components/dbuezas_eq3btsmart/python_eq3bt/eq3bt/eq3btsmart.py", line 239, in async_update
await self._conn.async_make_request(PROP_WRITE_HANDLE, value)
File "/config/custom_components/dbuezas_eq3btsmart/python_eq3bt/eq3bt/bleakconnection.py", line 111, in async_make_request
raise ex
File "/config/custom_components/dbuezas_eq3btsmart/python_eq3bt/eq3bt/bleakconnection.py", line 97, in async_make_request
await conn.start_notify(
File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 546, in start_notify
raise BleakError(f"Characteristic {char_specifier} not found!")
bleak.exc.BleakError: Characteristic 1056 not found!
I know the device is not the cause because it works ok with the bt-mqtt-gateway.