Add configuration for extra Unifi device_tracker attributes#15711
Add configuration for extra Unifi device_tracker attributes#15711cgarwood wants to merge 2 commits intohome-assistant:devfrom
Conversation
| ctrl.get_clients.return_value = fake_clients | ||
| scanner = unifi.UnifiScanner(ctrl, DEFAULT_DETECTION_TIME, ssid_filter) | ||
| scanner = unifi.UnifiScanner(ctrl, DEFAULT_DETECTION_TIME, ssid_filter, | ||
| False) |
There was a problem hiding this comment.
continuation line under-indented for visual indent
awarecan
left a comment
There was a problem hiding this comment.
I prefer not to introduce breaking change by make extra_attributes default is True.
| client = self._clients.get(device, {}) | ||
| _LOGGER.debug("Device mac %s attributes %s", device, client) | ||
| return client | ||
| if (self._extra_attributes): |
There was a problem hiding this comment.
We prefer guard clause
if not self._extra_attributes:
return {}
bla bla
I debated on that for a bit myself. My thought is that 90% of people aren't going to use the extra attributes that were introduced, and for those people it's writing a ton of data to the database for no gain, and since a lot of people are on Pi's with SD cards, the less writes the better. Likewise, it would only be a breaking change for people who have written automations/templates utilizing those attributes. I can definitely change the default to true though, if that's what's preferred. |
|
Alright, let's see what others think. |
|
I think a breaking change is ok here. This should have been opt-in from the beginning |
|
Missing documentation PR in the OP. |
|
Docs added, should be good to go now. |
|
Thanks, @cgarwood! Removing the label. |
|
I also think that a breaking change is advisable here |
|
As suggested in the linked issue, I agree with a breaking change to exclude this extra data. There are likely others that simply haven’t noticed the negative storage effects yet. |
| cv.boolean, cv.isfile), | ||
| vol.Optional(CONF_DETECTION_TIME, default=DEFAULT_DETECTION_TIME): vol.All( | ||
| cv.time_period, cv.positive_timedelta), | ||
| vol.Optional(CONF_EXTRA_ATTRIBUTES, default=DEFAULT_EXTRA_ATTRIBUTES): |
There was a problem hiding this comment.
default=False is better then default=DEFAULT_EXTRA_ATTRIBUTES
There was a problem hiding this comment.
It would not be consistent we the remaining DEFAUT_*
|
Have you considered also making this accept a list of attributes you actually do want from Unifi? Then you can collect what you care about and discard the rest. This is similar to telling the darksky sensor what weather data you want. |
|
Created a new PR to use a monitored_conditions list instead. #15888 |
Description:
The Unifi device tracker adds a lot of extra attributes to devices, such as rx/tx rates, rx/tx bytes, signal strength, etc. which cause a lot of extra state changed events to be fired and logged in the database. This update adds a configuration option,
extra_attributes, defaulting to False (disabled). This is technically a breaking change since it defaults to false.This is my first time working with tests, so I'm not sure I updated the test_unify.py file correctly.
Related issue (if applicable): fixes #14745
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#5921
Example entry for
configuration.yaml(if applicable):Checklist:
tox. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed: