Skip to content
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

Raw zigate events #3

Open
SaWey opened this issue Feb 1, 2018 · 2 comments
Open

Raw zigate events #3

SaWey opened this issue Feb 1, 2018 · 2 comments

Comments

@SaWey
Copy link

SaWey commented Feb 1, 2018

When using the switches, it sometimes takes a lot of time (+10s) before an action is taken.

I currenlty added the raw event stream to be able to use the switches faster.

self.hass.bus.fire('{}_{}'.format(addrep, property_id), {'value' : property_data})

in zigate2hass.py:

    def set_device_property(self, addr, endpoint, property_id, property_data):
        # decoding the address to assign the proper signal (bytes --> str)
        if endpoint:
            addrep = ZGT_SIGNAL_UPDATE.format(addr.decode() + endpoint.decode())
        else:
            addrep = ZGT_SIGNAL_UPDATE.format(addr.decode())

        _LOGGER.debug('ZIGATE SIGNAL :')
        _LOGGER.debug('- Signal   : {}'.format(addrep))
        _LOGGER.debug('- Property : {}'.format(property_id))
        _LOGGER.debug('- Data     : {}'.format(property_data))

        self.hass.bus.fire('{}_{}'.format(addrep, property_id), {'value' : property_data})
        dispatcher_send(self.hass, addrep, property_id, property_data)

This allows me to add automations directly based on the events:

- alias: 'Button clicked 3 times'
  trigger:
    platform: event
    event_type: zgt_signal_update_189f01_state
    event_data:
      value: multi_3
  action: 
    service: switch.toggle
    entity_id: switch.location_name
@elric91
Copy link
Owner

elric91 commented Feb 1, 2018

Interesting. It may be interesting to replace the dispatcher_send / dispatcher_connect with hass.bus.listen & hass.bus.fire
Need to check it into detail ... I'll keep you posted

@max5962
Copy link
Contributor

max5962 commented Jun 16, 2018

@elric91 & @SaWey
Have you notice improvement using bus capability instead of dispatcher ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants