New custom component : ZiGate


#162

Would someone be kind enough to provide me some working examples of using the zigate.raw_command to speak to and manipulate zigbee connected devices? I can’t quite figure out the exact syntax. I know I’ve read comments here of people who’ve used the raw command. An example where a bulb is controlled would be great but anything would be good. I’m unsure as to whether to use encoded or decoded in the cmd and data strings.

Thanks!


#163

You cand find bulb commands from: https://github.com/elric91/ZiGate/wiki/Ikea-Trådfri-commands
Json for service should look like
{
“cmd”: “0092”,
“data”: “026E8E010101”
}


#164

Thanks!

So in configuration.yaml, would this be the correct syntax?

light:
- service: zigate.raw_command
name: "Light"
cmd: "0092"
data: “026E8E010101”


#165

No show of illuminance but in the log i have :
“2018-03-08 14:49:52 DEBUG (MainThread) [zigate] --------------------------------------
2018-03-08 14:49:52 DEBUG (MainThread) [zigate] RESPONSE 8102 : Attribute Report / Response
2018-03-08 14:49:52 DEBUG (MainThread) [custom_components.zigate.zigate2hass] ZIGATE SIGNAL :
2018-03-08 14:49:52 DEBUG (MainThread) [custom_components.zigate.zigate2hass] - Signal : zgt_signal_update_b4b501
2018-03-08 14:49:52 DEBUG (MainThread) [custom_components.zigate.zigate2hass] - Property : last seen
2018-03-08 14:49:52 DEBUG (MainThread) [custom_components.zigate.zigate2hass] - Data : 2018-03-08 14:49:52
2018-03-08 14:49:52 INFO (MainThread) [zigate] FROM ADDRESS : b’b4b5’
2018-03-08 14:49:52 DEBUG (MainThread) [zigate] - Source EndPoint : b’01’
2018-03-08 14:49:52 DEBUG (MainThread) [zigate] - Cluster ID : b’0400’
2018-03-08 14:49:52 DEBUG (MainThread) [zigate] - Attribute ID : b’0000’
2018-03-08 14:49:52 DEBUG (MainThread) [zigate] - Attribute type : b’21’
2018-03-08 14:49:52 DEBUG (MainThread) [zigate] - Attribute size : 2
2018-03-08 14:49:52 DEBUG (MainThread) [zigate] - Attribute data : b’0051’
2018-03-08 14:49:52 DEBUG (MainThread) [zigate] # encoded : b’018102120210021fb271b4b502110214021002100210021021021002120210513903’
2018-03-08 14:49:52 DEBUG (MainThread) [zigate] # decoded : 0181 02 00 0F B2 71 B4 B5 01 04 00 00 00 00 21 00 02 00 51 3903
2018-03-08 14:49:52 DEBUG (MainThread) [zigate] (@timestamp : 14:49:52)
2018-03-08 14:49:52 DEBUG (MainThread) [zigate] --------------------------------------
2018-03-08 14:49:52 DEBUG (MainThread) [zigate] RESPONSE 8102 : Attribute Report / Response
2018-03-08 14:49:52 DEBUG (MainThread) [custom_components.zigate.zigate2hass] ZIGATE SIGNAL :
2018-03-08 14:49:52 DEBUG (MainThread) [custom_components.zigate.zigate2hass] - Signal : zgt_signal_update_b4b501
2018-03-08 14:49:52 DEBUG (MainThread) [custom_components.zigate.zigate2hass] - Property : last seen
2018-03-08 14:49:52 DEBUG (MainThread) [custom_components.zigate.zigate2hass] - Data : 2018-03-08 14:49:52
2018-03-08 14:49:52 DEBUG (MainThread) [custom_components.zigate.zigate2hass] ZIGATE SIGNAL :
2018-03-08 14:49:52 DEBUG (MainThread) [custom_components.zigate.zigate2hass] - Signal : zgt_signal_update_b4b501
2018-03-08 14:49:52 DEBUG (MainThread) [custom_components.zigate.zigate2hass] - Property : event
2018-03-08 14:49:52 DEBUG (MainThread) [custom_components.zigate.zigate2hass] - Data : presence detected
2018-03-08 14:49:52 DEBUG (MainThread) [zigate] * Presence detection
2018-03-08 14:49:52 INFO (MainThread) [zigate] FROM ADDRESS : b’b4b5’
2018-03-08 14:49:52 DEBUG (MainThread) [zigate] - Source EndPoint : b’01’
2018-03-08 14:49:52 DEBUG (MainThread) [zigate] - Cluster ID : b’0406’
2018-03-08 14:49:52 DEBUG (MainThread) [zigate] - Attribute ID : b’0000’
2018-03-08 14:49:52 DEBUG (MainThread) [zigate] - Attribute type : b’18’
2018-03-08 14:49:52 DEBUG (MainThread) [zigate] - Attribute size : 1
2018-03-08 14:49:52 DEBUG (MainThread) [zigate] - Attribute data : b’01’
2018-03-08 14:49:52 DEBUG (MainThread) [zigate] # encoded : b’018102120210021edc72b4b5021102140216021002100210180210021102113903’
2018-03-08 14:49:52 DEBUG (MainThread) [zigate] # decoded : 0181 02 00 0E DC 72 B4 B5 01 04 06 00 00 00 18 00 01 01 3903
2018-03-08 14:49:52 DEBUG (MainThread) [zigate] (@timestamp : 14:49:52)
2018-03-08 14:50:06 DEBUG (MainThread) [zigate] --------------------------------------
2018-03-08 14:50:06 DEBUG (MainThread) [zigate] RESPONSE 8102 : Attribute Report / Response

Cluster 0400 seems to be illuminance information => 51 (hexa) => 81 lux ?
I declared my detector as a switch ( to turn_on my yeelight ), Is it because is not declared as a sensor ?
Can you declare a zigate object as a sensor AND as a switch ?

thanks.
maxime


#166

no news ? :slight_smile:


#167

So I got illumantion to work:

sensor:
  - platform: zigate
    name: 'Motion Illumination'
    address: 028d01
    default_state: 'illuminance'
    default_unit: 'lx'

However, my automations using aqara switches do not seem to trigger. It seems that the state change from on-press to off-release is instantaneous and does not always trigger the automations.

Is it possible push the state changes to the home-assistant event stream?
i.e. with the original Xioami gateway I used to do these automations:

automation:
  - id: bedroom_toggle_lights_with_button
    alias: "Bedroom: Toggle lights with button"
    initial_state: true
    trigger:
    - event_data:
        click_type: single
        entity_id: binary_sensor.wall_switch_158d000xxxxxx
      event_type: click
      platform: event
    action:
    - service: homeassistant.toggle
      data:
        entity_id: light.bedroom_light

With zigate I am using now:

automation:
- id: light_trigger_hallway_light_upstairs
  alias: Light Trigger Hallway Light Upstairs
  initial_state: true
  trigger:
  - entity_id: sensor.hallway_upstairs_switch_left
    platform: state
  action:
  - data:
      entity_id: light.hallway_light_level
    service: homeassistant.toggle

So my question is does Zigate also publish events to the eventbus?

Edit: I am using the latest Zigate firmware (downloaded yesterday, 3.0d) and zigate from pip pyzigate==0.1.3.post1


#168

Update:

I added firing an event by adapting in sensors.py (I added a reference to self._hass = hass in the constructor):

    def update_attributes(self, property_id, property_data):
        self._attributes[property_id] = property_data
        self.schedule_update_ha_state()
        if property_id == self._default_attr:
            if self.entity_id is not None:
                self._hass.bus.fire('zigate', {
                    'entity_id': self.entity_id,
                    'state': property_data
                })

This seems to work as expected.
So then I can use again. This seems to work more reliable that tracking the state change.

automation:
- id: light_trigger_hallway_light_upstairs
  alias: Light Trigger Hallway Light Upstairs
  initial_state: true
  trigger:
    event_data:
      entity_id: sensor.hallway_upstairs_switch_left
      state: on-press
    platform: event
    event_type: zigate
  action:
  - data:
      entity_id: light.hallway_light_level
    service: homeassistant.toggle

#169

Illuminance seems not working for me :frowning:

  • platform: zigate
    name: 'illuminance 2’
    address: b4b501
    default_state: 'illuminance’
    default_unit: ‘lx’

I already add the motion sensor as a switch (in order to control yeeligh):

  • platform: zigate
    name: 'sensor2’
    address: b4b501
    default_state: 'event’
    type: ‘momentary’

Is it possible to declare the same product as switch and sensor ?
Thanks :slight_smile:

EDIT : i retrieve battery states on the switch and the sensor :
switch :
last seen: 2018-03-12 09:17:19
battery: 3.015
friendly_name: sensor1
event: presence detected

sensor :
last seen: 2018-03-12 03:57:32
battery: 3.015
unit_of_measurement: lx
friendly_name: illumination 1

EDIT 2 : Still no illuminance.
i redownloaded HEAD of plugging, pyzigate, restart, nothing working :frowning:


#170

Hi,

Don’t know if this should be considered off topic or not, but does anyone know how to get the multiple values in a single history graph? For example, my Xiaomi temperature sensor reports temperature, humidity and battery status…

But the history graph only displays one. I’m fairly new to HA and looked around the docs but couldn’t really find anything on this.


#171

I suppose you’ll get them displayed separately. As 3 badges or 3 entry in the interface.And depending on which value you click you’ll see one or the other graph.

It’s possible to display several graph in one, but it’s not a default behaviour.


#172

And that’s exactly what my question was… How do I do that? All three values belong to the same sensor.

When I click the sensor, I get the history graph with one value (temperature) and underneath it the current values for all three items.

Hiw do I get it to display all three values in the history graph?


#173

Then yes, it’s off topic ^^

But here you go, you can achieve that with grafana (not really simple though):


#174

I’m using influxDB and grafana, if someone need help i may help :slight_smile:

EDIT : after reinstalling evrything, still no illuminance. I continue to investigate :slight_smile:

EDIT 2 :
In my pyzigate folder ( 0.1.3.post1) i have illuminance information :

interface.py:            b'0400': 'Measurement: Illuminance',
zgt_parameters.py:ZGT_ILLUMINANCE_MEASUREMENT = 'illuminance'
attributes_helpers.py:        # Illuminance Measurement
attributes_helpers.py:                illuminance = int.from_bytes(attribute_data, 'big', signed=True)
attributes_helpers.py:                self.set_device_property(device_addr, endpoint, ZGT_ILLUMINANCE_MEASUREMENT, illuminance)

In my custom_component I use the good zigate library :

__init__.py:REQUIREMENTS = ['pyserial-asyncio==0.4', 'pyzigate==0.1.3.post1']

In my log i have information ( cf previous post )
In my switch.yaml ::

- platform: zigate
  name: 'sensor2'
  address: b4b501
  default_state: 'event'
  type: 'momentary' 

In the Web interface, no illuminance information :

switch.sensor2	off	last seen: 2018-03-12 15:35:52
                    event: presence detected
                    friendly_name: sensor2 

EDIT 3 :
I tried to remove the switch declaration in order to add it as a sensor : same issues …

Any idea ? :slight_smile:


#175

Just to be sure, which motion sensor are you using? The older one does not provide illumination information… Which Zigate firmware do you have installed on your stick?


#176

Hello
I’m using the last firmware 0d.
In home assistant, the motion detector is detected as “aq2” .

The brand “aquara” is written on the top of the detector.
According Gearbest it’s “V2”.


#177

Hi guys,

I have a problem. I’m trying to setup the zigate component by unzipping the files into custom_components under hassio/config/. After this, I add this to my configuration file:
#Enable ZiGate
zigate:

So far so good, but when I do the configuration validation it comes back with the following result:
Configuration invalid
Testing configuration at /config
Failed config
zigate:
- Invalid config for [zigate]: string value is None for dictionary value @ data[‘zigate’][‘host’]. Got None. (See ?, line ?). Please check the docs at https://home-assistant.io/components/zigate/
- cloud: ?
mode: production
config: ?
conversation: ?
discovery: ?
ignore: ?
frontend: ?
javascript_version: auto
group: ?
history: ?
exclude: ?
include: ?
use_include_order: False
http: [source /config/configuration.yaml:23]
api_password: mysecretpassword
base_url: https://mydomain.duckdns.org:8123
ssl_certificate: /ssl/fullchain.pem
ssl_key: /ssl/privkey.pem
logbook: ?
map: ?
script: ?
sun: ?
updater: ?
zigate: ?

Successful config (partial)
zigate:

What is going on and how can I solve this?? Thanks in advance!


#178

Hi guys! I have successfully paired Ikea Tradfri bulbs with ZiGate. However, whenever I try to turn off different groups of lights at the same time with automation script/google assistant, not all lights are switched off as expected. Some of them stay on, despite the fact that home assistant show’s status “off”. Can you help me out?


#179

Hmmm could it be that the range is limited by interference or something like that? The channels overlap somewhat with WiFi I believe. Also, I’m wondering if the Ikea bulbs act as repeaters or not.

I have Hue lights throughout the house that act as repeaters for at least each other. I also have Xiaomi stuff that’s working fine through two layers of concrete. I don’t think the Xiaomi stuff is repeated by the Hue bulbs though.


#180

The distance shouldn’t be an issue as all of my lights are pretty close to ZiGate… Is there anything I could do about lights interference with WiFi?
Also, I have an automation in which wardrobe lights must be switched off, when no motion is detected. I noticed that 1 particular light was always on, after automation to switch off closet lights was activated. So I added 1 additional line for this particular bulb and now it’s working just fine. However, I don’t think it’s right way to solve such issue :slight_smile:

  action:
    - service: homeassistant.turn_off
      entity_id: group.closetlights
    - service: homeassistant.turn_off
      entity_id: light.wardrobe1_3

#181

btw, i updated the githup to follow my issue :slight_smile: