Provide entity_id to avoid sensor mixup (fixes #7636). Use async_dispatcher. Provide icon.#7946
Conversation
There was a problem hiding this comment.
This is not a good fix. You can also not use DOMAIN from component in a sensor namespace. Please change this and don't use the same name twice:
https://github.com/molobrakos/home-assistant/blob/3081853ee45aabf0ec3d9a160b54a46e6211198b/homeassistant/components/volvooncall.py#L35-L36
Other points that you should a bit cleanup on your code in a later PR 😅 :
- https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/volvooncall.py#L71-L76 your are the first Person they do that in hass. Can you export this data class on root of your component, please.
- https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/volvooncall.py#L169 we use format string normaly
- https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/device_tracker/volvooncall.py#L33 It is not good designe to forward the callback into
hass.data. Please use dispatcher fromhelper/dispatcher. - Don't use
DOMAINforhass.data, it overwrite the localDOMAINconstante and can make problem in future changes of core. Some people use aDATA_*constante for that
|
3081853 to
1c0a608
Compare
a96f293 to
1c0a608
Compare
1c0a608 to
f48ff4d
Compare
f48ff4d to
73250ec
Compare
There was a problem hiding this comment.
line too long (85 > 79 characters)
73250ec to
536f273
Compare
536f273 to
de9b546
Compare
There was a problem hiding this comment.
It was not the idea to do the cleanup with this PR, but good work. Only the point of DOMAIN is a bit missunderstand. I hope with my last Change request you understand it now. You can use DOMAIN inside your component for hass.data but you should not Import DOMAIN as DOMAIN in a platform they have a other domain like device_tracker or sensor.
There was a problem hiding this comment.
Move this into sensor/volvooncall entity and import the domain from sensor. Now you see why you should not import the DOMAIN as DOMAIN inside a platform from a other component then volvooncall.
There was a problem hiding this comment.
Thank you for feedback - do I understand correctly that everything is fine if it is kept as it is, i.e. entity_id is specified in class VolvoEntity, which is defined in components/volvooncall?
There was a problem hiding this comment.
Also, do you still prefer that I just rename the sensors instead of providing unique entity_id:s? (I still prefer the latter)
There was a problem hiding this comment.
Yes. You can move the property into entity class inside sensor/volvooncall.py and use the DOMAIN from sensor/__init__.py or you remove the entity_id property and use a unique Name that generate a unique entity_id inside core. All other is perfect.
There was a problem hiding this comment.
Please help me understand why you think it is wrong to keep it in the VolvoEntity base class (base class for both the implementation within sensor/ and binary_sensor/)?
de9b546 to
74ebd95
Compare
74ebd95 to
c21f85e
Compare
c21f85e to
c1f6a89
Compare
There was a problem hiding this comment.
line too long (85 > 79 characters)
There was a problem hiding this comment.
'homeassistant.util.slugify' imported but unused
c1f6a89 to
b0396a4
Compare
b0396a4 to
b4ee484
Compare
b4ee484 to
6684af0
Compare
6684af0 to
6f0279f
Compare
…s some smaller fixes.
6f0279f to
c6492d3
Compare
Description:
Related issue (if applicable): fixes #
#7636
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.github.io#<home-assistant.github.io PR number goes here>
Example entry for
configuration.yaml(if applicable):Checklist:
If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
toxrun successfully. Your PR cannot be merged unless tests passREQUIREMENTSvariable (example).requirements_all.txtby runningscript/gen_requirements_all.py..coveragerc.If the code does not interact with devices:
toxrun successfully. Your PR cannot be merged unless tests pass