awesome, will try this as soon as I can
Just tried it, now the press is correctly reported in hass
So one press does shortly pass the state to on-press
, and then is reverted back to off-release
.
toggle
was set as type, it however still behave as a simple binary input (only on when pressed, off otherwise). But that’s not really a problem, and when we want this kind of toggle function, it’s usually better to handle them in hass and keep the input as a simple input.
The double click was also recognized to my surprise , however their is still a small bug during processing of this event, here you can find the corresponding log:
Thanks for the infos !
-
The errors in the log are purely formatting errors, correction will be committed later today
-
Toggle not working is as if the parameter was not taken into account (behaving like a standard switch). No idea for the time being except for a conf / conf interpretation error. I need to reinforce conf validation just in case
-
Multi press is not complicated to implement : I just need to know if other messages are fired around it. I doubt it is standalone … is it like :
- press / multi / release
- or multi / release
- or others …
(NB : press = attribute id 0000 / data 00, release = 0000 / 01, multi = 8000 / 0x <- x being number of clicks)
I just tried and multi press works very well (except for a tiny typo, see PR7).
State is set to multi_4 for a 4 times click. multi_3 for a 3 times one, etc… with the maximum appearing to be 4 click in a row. 5 click simply being ignored (I see no traffic on the Zigate, so it’s to assume that the xiaomi button doesn’t transmit anything if pressed more than 4 times in a row).
DEBUG (MainThread) [zigate.interface] --------------------------------------
DEBUG (MainThread) [zigate.interface] RESPONSE 8102 : Attribute Report / Response
INFO (MainThread) [zigate.interface] * General: On/Off
INFO (MainThread) [zigate.interface] * Multi click
INFO (MainThread) [zigate.interface] * Pressed: 4 times
INFO (MainThread) [zigate.interface] FROM ADDRESS : b'f5c9'
DEBUG (MainThread) [zigate.interface] - Source EndPoint : b'01'
DEBUG (MainThread) [zigate.interface] - Cluster ID : b'0006'
DEBUG (MainThread) [zigate.interface] - Attribute ID : b'8000'
DEBUG (MainThread) [zigate.interface] - Attribute type : b'20'
DEBUG (MainThread) [zigate.interface] - Attribute size : 1
DEBUG (MainThread) [zigate.interface] - Attribute data : b'04'
DEBUG (MainThread) [zigate.interface] # encoded : b'018102120210021e77a2f5c9021102100216800210021020021002110214c603'
DEBUG (MainThread) [zigate.interface] # decoded : 0181 02 00 0E 77 A2 F5 C9 01 00 06 80 00 00 20 00 01 04 C603
DEBUG (MainThread) [zigate.interface] (@timestamp : 09:02:22
INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.my_push_button, new_state=<state sensor.my_push_button=multi_4; friendly_name=my_push_button, state=multi_4, last seen=2018-01-12 09:02:22 @ 2018-01-12T09:02:22.167025+01:00>, old_state=<state sensor.my_push_button=multi_2; friendly_name=my_push_button, state=multi_4, last seen=2018-01-12 09:02:22 @ 2018-01-12T09:02:18.922021+01:00>>
Thanks for the PR. Device is indeed sending a max of 4 clicks
Just to confirm : there is no press / release event just before and after the multi click event ?
(to implement proper management of switch state)
NB : WiFi is coming …
No, only what I posted is received (General ON/Off Multi click), no other press/release event.
My device now working flawlessly, I moved on to my second Aqara device, the wall switch. I posted the log on github.
This one might be harder to handle as it’s a press button, as well as an integrated switch (relay), and both are double
http://www.topelectroshop.co.uk/wp-content/uploads/2017/10/Xiaomi-Aqara-Smart-Home-ZiGBee-Wireless-Key-Live-Neutral-wire-Wall-Switch-Light-Control-Via-Smarphone.jpg
Nice work, I have received mine, I will follow this thread
Thanks for your work.
As a welcome gift , WiFi is now enabled
in order to activate, in configuration.yaml, just do
zigate:
host: '192.168.1.12'
(depending on the IP you chose for the ZiGate)
If you reinstall / upgrade now, be careful as config has to be updated
Device addresses are now on 6 bytes : 4 for short address (i.e. 34bc) & 2 for endpoint (i.e.01)
so in config.yaml if short address is 34bc and endpoint is 01, device address must be defined as 34bc01
@touliloup : this should help with your wall switch
I was almost starting a pyzigate project… and then I realized that somebody beat me to it.
Very nice! Congratulations for the library and the custom component. Are you planning to upload the pyzigate project to the Python Package Index? It will be easier to integrate with the custom component.
Do you need something? I am a Python developer, own a ZiGate and have Aqara devices… unfortunately, I have just finished moving places, so my HA environment is “WIP” right now
Any help is welcome (corrections, enhancements, tests, whatever ). You can propose patches anytime.
Indeed, we are currently improving the code in order to publish a pypi package. As it’s a first for me, I’m learning at the same time. Hopefully, it should be done this WE.
Hey there! Thanks for the work you did on this.
I bought my ZiGate device the other day, I hope it will arrive soon . I already have a Philips Hue Bridge with some Hue Lights, I’ll give it a test (and see how to unpair the lights and the bridge ) . I think I might also buy some Xiaomi sensors to check if it works well with your code .
I’m willing to give you some help and some feedbacks on this, I think this project is really great!
At leat, pyzigate library published under pypi
pyserial or asyncio / serial_asyncio required
use of the library through HASS coming soon (will bring battery level for some xiaomi sensors)
News : Component is now far easier to install
- Grab the release : https://github.com/elric91/homeassistant_zigate/releases/tag/v0.1.1
- Unzip it in your <conf_folder>/custom_components/
(you should put all the zigate, sensor & switches folders right under custom_components) - Adapt your <conf_folder>/configuration.yaml
done !
(It handles the download of the pizygate and asyncio-serial libraries as per homeassistant standard behavior)
NB1 : should work, but if you encounter problems, just ask here …
NB2 : configuration documentation still needs to be updated with the information available in this thread
I’m sorry i’m really a newbie
i download the release and put everything in my config folde :
ls /home/docker/hass/custom_components
LICENSE README.md sensor switch zigate
At the restart i have in logs :
Traceback (most recent call last):
File “/usr/src/app/homeassistant/setup.py”, line 196, in _async_setup_component
result = yield from component.async_setup(hass, processed_config)
File “/usr/local/lib/python3.6/asyncio/coroutines.py”, line 212, in coro
res = func(*args, **kw)
File “/config/custom_components/zigate/init.py”, line 43, in async_setup
from .zigate2hass import ZiGateProtocol, ZiGate2HASS
File “/config/custom_components/zigate/zigate2hass.py”, line 9, in
from pyzigate.zgt_parameters import *
how to fix the error ?
thanks
Hello,
No noob thingy here, we’re all learning
Seems you’re using docker so you need to give access the container to the /dev/ttyUSB0 device
Launch command needs to be updated :
docker run -d --name=“home-assistant” -v /home/toto/.homeassistant:/config -v /etc/localtime:/etc/localtime:ro --net=host –device=/dev/ttyUSB0:/dev/ttyUSB0 homeassistant/home-assistant
(obviously replace /home/toto/.homeassistant with your config path)
Or if you use docker-compose, add in your docker-compose.yaml (same level as network_mode :“host”) :
devices: - '/dev/ttyUSB0:/dev/ttyUSB0'
Just tested it with a fresh docker install … so it should work
Received my ZiGate this morning
I was way too impatient and started the setup. The steps you specified for the installation made it really easy. I wanted to thank you for these.
From there I wanted to pair it with one of my Philips Hue to dive a bit in it and see how it works. I read that you only have to call the service zigate.permit_join
in HA and then the device should show up on the Welcome Screen. The issue here is that there are no push buttons on the Philips Hue to start pairing. The Philips Hue light does not show up on the Welcome Screen and it doesn’t feel like it has been paired. The Philips Hue App is able to tell that the light is available for pairing.
Do you have any idea about this?
Don’t know if you speak French but this can help:
If not, I’ll provide a quick translation tonight
Yep, I do speak French. This article helped, and actually it seems that removing the lights from the Philips Hue App does the trick to unpair it, however I am still unable to pair with zigate.
As I did not know if it came from my setup or from anything else, I tried to setup this on a docker on my laptop. Everything was setup properly and I followed (once again) the steps to install your components in the config directory under custom_components, but still unable to pair the device.
I read from the site of Zigate the following statement:
Attention ! la plupart du temps vous observerez que le endpoint 0x01 est quasiment toujours utilisé mais certains constructeurs jouent avec cet adressage pour rendre plus propriétaire leur objet. (ex : Philips HUE utilise le endpoint 0x0B)
I did not have the time yet to dive into your code and check how it works and what it does, but I was wondering if it was possible in anyway that it could be one of the reasons it does not work?
Hi all, thanks eLRIC for the component. Just tried it but don’t manage to connect a device (xiaomi aqara button).
- I use the service to put zigate in join mode
- I long press to button to put device in discover mode
And nothing append, here is the only log I have for the zigate component :
2018-01-24 22:08:38 DEBUG (MainThread) [custom_components.zigate] ZIGATE : Starting
2018-01-24 22:08:38 DEBUG (MainThread) [custom_components.zigate.zigate2hass] ZIGATE : Transport initialized : SerialTransport(<_UnixSelectorEventLoop running=True closed=False debug=False>, <custom_components.zigate.zigate2hass.ZiGateProtocol object at 0x7fb04921ecc0>, Serial<id=0x7fb049229dd8, open=True>(port='/dev/ttyUSB0', baudrate=115200, bytesize=8, parity='N', stopbits=1, timeout=0, xonxoff=False, rtscts=False, dsrdtr=False))
Do I miss something ?
Thanks for the help !