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

ZHA - Event foundation #19095

Merged
merged 5 commits into from
Dec 10, 2018
Merged

Conversation

dmulcahey
Copy link
Contributor

Description:

Adds a foundation that allows ZHA entities to fire events in HA

@ghost ghost added the in progress label Dec 7, 2018
@dmulcahey dmulcahey changed the title event foundation ZHA - Event foundation Dec 7, 2018
@dmulcahey dmulcahey closed this Dec 7, 2018
@ghost ghost removed the in progress label Dec 7, 2018
@dmulcahey dmulcahey reopened this Dec 7, 2018
@ghost ghost added the in progress label Dec 7, 2018
@callback
def zha_send_event(self, cluster, command, args):
"""Relay entity events to hass."""
self.hass.bus.async_fire(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Entities shouldn't fire custom events. They already spawn state changed events. Devices that need to fire events should not be entities and the events should be fired from the zha component.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See DeconzEvent in the deconz package for an example.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had it like that at first... may I ask why this is the case? I can do that but all it does is artificially increase the number of objects being managed. These entities are going to exist anyway and there will be a platform level event object for each one as well. I thought this was a much cleaner implementation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you mean platform level event?

Entities provide states, and should not fire other types of events.

If entities are not providing states, they should not be entities. What's the case here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some do both... in the case of the Aqara Qube for instance. The entity tracks the last motion of the cube but it fires events for things like slide, knock, rotate etc. The entities aren’t all or always firing events... this just adds a hook there to allow them to fire events in the case where an event makes more sense

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reworked this. Let me know what you think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes pushed

@dmulcahey dmulcahey closed this Dec 9, 2018
@ghost ghost removed the in progress label Dec 9, 2018
@dmulcahey dmulcahey changed the title ZHA - Event foundation WIP - ZHA - Event foundation Dec 10, 2018
@dmulcahey dmulcahey reopened this Dec 10, 2018
@ghost ghost added the in progress label Dec 10, 2018
homeassistant/components/zha/event.py Outdated Show resolved Hide resolved
homeassistant/components/zha/event.py Outdated Show resolved Hide resolved
homeassistant/components/zha/event.py Outdated Show resolved Hide resolved
homeassistant/components/zha/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/zha/event.py Outdated Show resolved Hide resolved
homeassistant/components/zha/event.py Show resolved Hide resolved
Copy link
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@dmulcahey dmulcahey changed the title WIP - ZHA - Event foundation ZHA - Event foundation Dec 10, 2018
@cgarwood cgarwood merged commit f4f4217 into home-assistant:dev Dec 10, 2018
@ghost ghost removed the in progress label Dec 10, 2018
@dmulcahey dmulcahey deleted the dm/zha-event-foundation branch December 26, 2018 12:10
@balloob balloob mentioned this pull request Jan 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants