-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
Migrate to generic discovery method #2271
Conversation
2623775
to
4a31cfc
Compare
Going through it it looks good. Even added a tox test for load_platform. I never got to it and must say not sure I understand the mock calls yet. I was wondering if When I started out discovery through Some used The fact that EntityComponent, which is part of the core, is dependant on a homeassistant.component.discovery feels wrong. homeassistant.components adds functionality, but core functionality should not be dependant on homeassistant.components in my view |
4a31cfc
to
25b7611
Compare
You are so right. I will be moving all the discovery things to a discovery helper. The discovery component will solely exist to interface with netdisco and forward discoveries to the correct component/platform. |
25b7611
to
d00d0d7
Compare
Great, if you can please add qwikswitch.py import this should be good. Did a search its the only component that uses it atm. |
One extra bit that would be nice is a way to pass objects around, I know you said you only want it serializable on the event bus. I add the below code to some of my custom components (qwikswitch is only used since it can be imported, custom components not) and it then gives me a global variable -- there might be a better way? But with this custom component also have a way to pass objects around. (and so do some/lots of other components, without keeping their own globals) def push_obj(obj):
import homeassistant.components.qwikswitch as qwikswitch
if qwikswitch.QSUSB is None:
qwikswitch.QSUSB = {}
oid = id(obj)
qwikswitch.QSUSB[oid] = obj
return oid
def pop_obj(id):
import homeassistant.components.qwikswitch as qwikswitch
return qwikswitch.QSUSB.pop(id) I also based this on a weakref dictionary once, but could not find that code now. I think weakref mght be important, but not sure how solid my logic is there |
All events on the eventbus have to be serializable because they are also being sent over MQTT and HTTP. |
So the bit of code above still allows it to be serializable, since you only send the -The component |
Sorry, did not read your full comment because I was also watching a series 💃 I don't want to push objects over the event bus. Instead we should add some sort of global accessible objects to the hass instance. (captured in this pivotal story) |
farcy is always vigilant 👓 , even when you're watching series 😄 |
358e623
to
79874ab
Compare
The only thing that has changed… is everything.
@kellerza introduced a generic load platform discovery mechanism for the Entity Component a couple of releases ago. This makes our existing hardcoded platform discovery obsolete so this PR removes it.
This is my first pass at it. I bet I made some mistakes…