-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
eq3btsmart Thermostat misbehaviour #3885
Comments
the above approach seemed to work quite well with 3 thermostats. yesterday I bought a forth one and had the same issue again.. sometimes the thermostats set the correct temperature, but just don't open/close the valve. Currently I am testing to connect before every write and disconnect after every write. I assume it is not a good idea to hold the BT connection, when multiple thermostats are in use. |
Why don't we use this rather clean implementation of the eq3 protocol? It also does not seem to keep an open connection. |
looks good. I digged around now for another few days. It seems, that the main problem is, that HA reads the temperature every minute. So for this thermostat it does a write every 1 minute, even if inbetween a settemperature write was called. I assume the next write (for getting temperature) "disturbs" the thermostat and it does not open/close the valve. I implemented a delay in my testcode. After set temperature it sets nextupdate time delay to 2minutes, after update() it sets it to 15 minutes. Since I did this, the thermostats behave perfectly. just the time is still not correct. |
Yes, that is another bug to my mind. Is temperature is set to target temperature. But for this device one cannot read the Is temperature. I would like to be able to take any other sensor values as Is temperature, otherwise it should not show up. |
@bimbar Your implementation does not work well, I would go for a more or less complete rewrite. E.g. why do you use |
for my testing I returned the valve state (in %) instead of current temperature. made it easier for digging out the problem :-) just to give you an idea what I did to solve the problem.
|
I just bought some thermostats today, made the firmware update and run into the same problem. Could anyone post his working eq3btsmart.py file? It seems to look different now in 0.31.1. |
I have also bought 3 of them (package) as the seemed the right choice for me at least. If there is any prerelease available for testing I'm happy to help. It seems in this forum https://forum.fhem.de/index.php/topic,39308.105.html they also start making some progress, |
I have four of these thermostats and it would be great if somebody could get them to work properly. Could you pleas post the complete Code? |
yes, sure. here you go. replace both eq3btsmart.py files. the location within your installation might differ from mine. I also added a file hcireset.sh. Copy to directory /home/hass/ or any convenient location and change accordingly in ....bluepy_devices/devices/eq3btsmart.py line 121. if, for any reason, the script is not able to connect to one of your bt devices after 10 connection attempts, it resets the bluetooth controller. you need to add hass user to sudoers file.
also please make sure you disconnect all your bt thermostats before starting homeassistant.
good luck! the script writes some log entries in /var/log/messages. You can change the loglevel in ....bluepy_devices/devices/eq3btsmart.py to match your needs. for the istemperature it returns the valve open state (0-100%) also keep in mind that you need to replace the files again after you upgraded homeassistant. |
Thank you very much, but in your zip is only one eq3btsmart.py from the components/climate folder. You wrote about exchanging anotherone, in the bluepy_devices/devices folder? |
see |
Thank you. But I'm still having issues with an updated thermostat. The one with the original firmware works just fine. After the So I inserted a This is still not really stable but it seems to work most of the time. |
The commits in https://github.com/jannau/bluepy_devices/tree/fixes fixes the current eq3 bt thermostat integration via bluepy_devices. I submitted a pull request: bimbar/bluepy_devices#3 |
Ok, After spending more time with it I finally discovered the main issue with the time. The update request always needs to include the time. New pull request submitted. |
Thank you for your effort. The main issue with this component is IMHO, that the update is called to frequently and there are more and more issues connecting to devices. Besides battery drain this might be ok for one, maybe two thermostats. I own 4 and it was almost never possible to set the temperatures, or when the temperature was set, the thermostat did not change valve state, because it was interrupted with the next update call before it changed the valve. with the code i attached above i have almost no issues. maybe once per two weeks 1 of 4 thermostats does misbehave or not change the valve. Maybe you can add something similar like i did (update delay). Also it would be nice to see the valve state in home assistant. Thank you again. |
I mostly agree and I have already implemented most of the missing functionality in bluepy_devices locally. The only major thing I haven't implemented is reading and writing the internal program. I'm now looking at integrating the added features in home-assistant. I tried to increase the scan interval (via setting SCAN_INTERVAL in the component) but for some reason that's not working. The valve status could actually justify a shorter scan interval than the 15 minutes you're using. I think that's a sensible interval. |
@jannau: |
@DavidLP: |
And here are my changes to home-assistant to use the eq3btsmart enhancements in bimbar/bluepy_devices#5. Auto, Manual, Boost , Closed and Open are available as operation mode. Home-assistant's away mode is also supported. It currently programs the thermostat's holiday or party mode for 30 days at 12 degree Celsius. It also reports the low battery warning and valve state as attributes. @alexxxo I suspect the problems you had with setting the temperatures could be the broken update command. Are your thermostats in the 'auto' or 'manual' mode? |
I just peeked into the available btle wrappers as I was also tinkering with bluepy support for bt le tracker (while waiting for my eq3 to arrive), a short (and very superficial) summary of findings: pygattlib
bluepy
pygattNote: uses https://github.com/jrowberg/bglib for windows support (only bluegiga?), which could be used with other libs too.
gatt dbus api
Other:
Conclusion: In the future gatt's dbus api sounds the sanest option, needs wrapping though. For the time being, hard to decide as all of those have their pros and cons.. bluepy sounds however nicer than pygatt API-wise, and nicer than gattlib due to its fewer requirements. |
@rytilahti: This is a very nice overview / review of the possible ways to use bluetooth with Python. I agree to all points. Generally we should maybe think about a bluetooth hub for home assistant to serialize bluetooth calls. This would circumvent the issue we have if several devices use bluetooth at the same time. Or is the |
I've modified example-gatt-client to speak with the eq-3 bluetooth thermostat. It is indeed a little annoying without wrapping. I wouldn't expect thread-safety problems with the dbus api considering that dbus is explicitly a many to many message bus. I'm however unclear how the requirement for the glib main loop (event loop to receive callbacks) interacts with the rest of HA. Devices still need to be connected for communication and if one would like to drop the connection if it's not in use that has to be done manually. So there would be use for a central arbitration to share the limited resource of bluetooth connections (4 on my laptop). Bluez's example-gatt-client (and server) are of course bad examples since the use the deprecated dbus-python instead of pydbus. |
@DavidLP: I'm not sure about the bluetooth specifics, but if one "requests" to be notified by the devices, is there still a need for a connection, or just when queries are made from the client to the device? Anyway, I agree with the notion of having a centralized bluetooth hub, even if active connections are needed, as it it easier to support other platforms. Plus in principle the components wanting to use bluetooth should not care about low-level details where possible, or that's my opinion anyway for what it's worth. @jannau: cool, I'm receiving my eq3 test piece tomorrow, I'll hope to give it a whirl then. I don't see a problem with the event-loop, in worst case it's blocking and with asyncio it can be made non-blocking where needed, it's just an event-loop like any other, right? |
eq3bt_gatt_dbus.py is example-gatt-client adapted for the eq3 bt thermostat. There is one insteresting thing in the bluez gatt dbus API. It's possible to register profiles (client equivalent of gatt services) and Bluez would then auto-connect. Probably not useable due the connection limitation. |
Ok, so I received one thermostat today and I'm currently testing it, seems to work just fine without applying your updates @jannau. However, can't connect at the same time with the app (probably because the connection is being held like indicated before), looking into the code, is there some specific reason why the connection needs to be active all the time? I would just create a context manager for doing connect & disconnect around calls, would that work? edit: on another (happy) note, bluepy seems to have gotten new commits just yesterday from the original author, so it's not completely inactive :) edit: yet another note, bluetooth le is marketed as connectionless, but that isn't the case? Btw, how come the mobile app needs pairing with a pin, but it works just fine through the plugin without it? |
@rytilahti Bluetooth LE devices support only one concurrent connection. Wrapping each write request with connect()/disconnect() works fine. I tried that before I discovered that the short update()/set_time() is responsible. That seemed to work. |
I changed the behaviour of polling by not holding the connection open but making it connect whenever it requires send data and receive updates. This will 1) allow usage of mobile app or the debug client and 2) will get rid of potential "hanging socket" problems. Let's try to get it merged back to the upstream (bimbar/bluepy_devices#6) as that would be the easiest way to handle it. I created a couple of WIP pull reqs: |
Good, I merged the connection manager and commented on the homeassistant WIP PR. Do we have a backup plan if @bimbar remains elusive? He also owns the package on pypi. I guess the next step would be to handle unavailable devices more gracefully than passing exceptions down. |
Let's wait over the holidays and figure out the plan after that. In worst case we will have to create a fork & probably rename it too to avoid problems with pypi & others. I'm also wondering whether it really makes sense to have a separate "collection" package like bluepy_devices, but simply just have something like python-eq3btsmart which uses bluepy (or whatever backend will be chosen) directly, the bluepy_devices library itself is just a small <100LOC wrapper for bluepy.. |
Thank's for the great work. The thermostats have become way more reliable. But sometimes my Pi still can't connect. The only error messages I get, are these: One Bug I found in eq3cli: |
@maunsen sometimes homeassistant can't connect to the device for unknown reasons, I've seen it happening, but I'm unsure what causes it. (Too many concurrent connections? Adapter not allowing any more connections? Something else?) However, I'll fix the failed to connect error by letting homeassistant to know that the device is currently not available, when I get some time to do that. The manual mode is only possible with the restructure branch from git at the moment, it's still work in progress, but that's how I'm driving a couple of my thermostats and it seems to be working just fine. |
Hello All! About a month ago I setup brand new RPI3 + HASS installed with All-In-One installer (version before 36.1). Somehow I managed my eq3btsmart to work (I did several manual installs). After upgrade to 36.1 it stopped working (I have no logs from this). I cleaned my RPI3 and installed HASS from beging using Manual "mode". Now HASS works ok, but it cannot initiallize eq3btsmart.py while starting. The problem is with installation of python-eq3bt (v 0.1.4). I understood after reading 2017 messages above, that with HASS 36.1 + python-eq3bt 0.1.4 it should work. This is what I see on this subject in HASS init logs:
Can you help me? |
Sorry, somehow my notification settings on github were wrong, so I slept through all of that. I concur that bluepy is not the perfect solution and we should standardize on a common BTLE library. So, if you want, I can merge your pull into bluepy_devices, or we change over to @rytilahti fork of it, at least in the interim, until we can ditch bluepy altogether (which I always have to build manually when updating HA, for some reason). I'm probably not the perfect maintainer anyway, since I only have one EQ3BT Smart thermostat and don't really use it actively. |
@teamdif it's unable to install bluepy for some reason, but there's not enough information in that error message.. Can you try to manually install it with pip into your virtualenv and see the logs? @bimbar it's unfortunate that I didn't notice to write an e-mail before doing the fork. I wrote you an email now, let us find out how to proceed from here. |
Hey when I run If i run the command However, when i then try to run i get I have tried it on "clean" hass images, same result. I am running python 2.7.9. Do you guys have any idea what could be wrong with my setup? Cheers, |
It is better to use virtualenv than installing anything as root, see http://docs.python-guide.org/en/latest/dev/virtualenvs/ . The easiest way to fix your problem is to use python3 instead of python2, homeassistant does not even work with python2. On hassbian you can use the same virtualenv as homeassistant is using, see https://home-assistant.io/getting-started/installation-raspberry-pi-image/#update-home-assistant-on-hassbian - the parts you need to activate the environment are lines 2 and 3. |
ohh thank you very much. It now at least gives me the error it cant connect to the device. So it seems to work just fine |
I can see the device in bluetoothctl. I have successfully paired and connected to it but I cant seem to get the command working. `WARNING:eq3bt.connection:Unable to connect to the device 00:1A:22:06:50:, retrying: Failed to connect to peripheral 00:1A:22:06:50:, addr type: public During handling of the above exception, another exception occurred: Traceback (most recent call last): |
|
@rytilahti I will do what you recommend and share feedbak - thanks! (PS. I use manually installend Jessie Lite + RPI3 + VirtualEnv). Just to be sure on what I will do: I will log in to my "pi" user, switch to virtual env + activate it and than I will do "pip" with do: "pip install python-eq3bt" and share output here... |
@teamdif yes, although if the install is successful, just try to use |
Hi @rytilahti It seems tha glib.h is missing... am I wright?
|
Looking at the error (fatal error: glib.h: No such file) it seems that you need glib headers. Maybe installing libglib2.0-dev package will help? |
OK I will try. Strange is the fact that I follow all instructions, so I thought I will not need to do guessed fixing/installation... Thanks. UPDATE: It seems that this HOW-TO had this (installing dependencies) STEP in scope... @rytilahti Do you know if there is a chance to link to EQ3btsmart current temperature from external DHT22, so it will be shown in the chart together with target temperature and later (ideally) making possible to set some automation (if TARGET >= CURRENT then SET TARGET = CURRENT)? |
@teamdif no, it's not possible. We really should remove the current temperature from EQ3btsmart. If the DHT22 temperature is integrated in home-assistant it should be possible to use home-assistant's [generic thermostat](https://home-assistant.io/components/climate.generic_thermostat/ thermostat). I'm not sure if the thermostat can be used directly. it should support toggling (switching on/off) but the other states might confuse the generic thermostat. That could be solved by a template switch. I'm not sure if that's desirable though. If the thermostat is used with a target temperature it can open the valve partially. So I would use the thermostat and the temperature sensor separately. You can still monitor the difference between the actual temperature and the target temperature and use that to program a temperature offset. Using it for automations in home-assistant is of course also possible. |
Yeah, that's not possible at the moment. I'm unsure if that would be doable with templates somehow though? But that's something I would prefer to see myself, a generic "temperature_from: <entity.property>", unsure if the main devs would approve it though. |
BTW, However, it is unclear to me whether the temperature sensor value is accessible via BLE. I'm still digging. |
Yes, it contains a sensor as it can display when the temperature suddenly drops (through window open state). However, afaik it's not accessible through BLE. If you find out something, a patch and/or notes are very welcome :-) |
hey
Command "/srv/homeassistant/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-build-a8nvo8cj/bluepy/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-v40zyqag-record/install-record.txt --single-version-externally-managed --compile --install-headers /srv/homeassistant/include/site/python3.4/bluepy" failed with error code 1 in /tmp/pip-build-a8nvo8cj/bluepy/ As far as I can see, its telling me glib2.0 is not installed. Is that the issue? It would be really great if anybody could give me a hint on what i am doing wrong. |
@rytilahti is there any progress in reliability? Thank you very much for your effort. If the connection was stable these things wouild be awesome! |
@maunsen, no news on that regard, it's not about the distance itself nor the device I'm afraid, but when you have multiple bluetooth devices your Pi 3 can't connect to them at the same time, causing troubles. That all requires much more work or some way to serialize the bluetooth calls made by homeassistant, but I don't know what's the best approach for that. |
I have git the same proble like @teamdif, except for me eq3bt works well in the console. However, I still get the error |
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 |
This issue still exists on Hassbian "image_2017-09-13-Hassbian" / Home Assistant 0.55.0. Running the following command resolves the issue:
|
Home Assistant release (
hass --version
):0.30.2
Python release (
python3 --version
):Python 3.4.2
Component/platform:
eq3btsmart
Description of problem:
Thermostats show temperature, but valve does not open or close.
Thermostats (at least the ones with latest firmware) need a disconnect after setting temperature.
Also the datetime in the thermostats is set to 2030/2040 something with wrong time (month and day are correct).
Expected:
Thermostats should react after changing temperature. Time should be set correctly.
Problem-relevant
configuration.yaml
entries and steps to reproduce:proof, that disconnect is needed:
with a 2 hour quick and dirty hack, I have working thermostats, including correct time and date
Additional info:
about the datetime bug, I think the PROP_INFO_QUERY (or a '03') is missing
Thank you.
The text was updated successfully, but these errors were encountered: