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

Huawei LTE sensor unique id improvements #25609

Merged
merged 7 commits into from Aug 1, 2019

Conversation

@scop
Copy link
Contributor

commented Jul 31, 2019

Description:

See code comments for more info. This paves way for future changes that will enable unauthenticated access to the routers in many cases. Such an access is good because there are session issues when using the same (only) user account on them from multiple sources, and it would enable also easier config, perhaps via discovery without further settings etc.

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the [development checklist][dev-checklist]
scop added 2 commits Jul 28, 2019

@project-bot project-bot bot added this to Needs review in Dev Jul 31, 2019

@ghost ghost assigned scop Jul 31, 2019

for entid, ent in entreg.entities.items():
if ent.platform == "huawei_lte":
for sensor in sensors:
if ent.unique_id.endswith("_%s" % ".".join(sensor.path)):

This comment has been minimized.

Copy link
@MartinHjelmare

MartinHjelmare Jul 31, 2019

Member

I guess we should start using f-strings now. Our old standard was new style string formatting, but f-strings are awesome.

At least we shouldn't use old style string formatting.

This comment has been minimized.

Copy link
@scop

scop Jul 31, 2019

Author Contributor

Agreed on f-strings in general, not sure in this particular case but... meh, changed.

(Disagreed on old style formatting vs .format, in general but that's moot now here.)

# *_d.e.v.i.c.e._.s.i.g.n.a.l...s.i.n.r
entreg = await entity_registry.async_get_registry(hass)
for entid, ent in entreg.entities.items():
if ent.platform == "huawei_lte":

This comment has been minimized.

Copy link
@MartinHjelmare

MartinHjelmare Jul 31, 2019

Member

Maybe invert the check and continue if true to save indentation?

This comment has been minimized.

Copy link
@scop

scop Jul 31, 2019

Author Contributor

Done

@MartinHjelmare
Copy link
Member

left a comment

Looks good!

Dev automation moved this from Needs review to Reviewer approved Jul 31, 2019

scop added 3 commits Aug 1, 2019
@@ -101,7 +102,7 @@
)


def setup_platform(hass, config, add_entities, discovery_info):
async def async_setup_platform(hass, config, async_add_entities, discovery_info):

This comment has been minimized.

Copy link
@MartinHjelmare

MartinHjelmare Aug 1, 2019

Member

discovery_info should be optional and default to None in the signature.

@pvizeli
Copy link
Member

left a comment

I don't think that is a good idea. As system administrator, MAC are only unique on same subnet. So if you run HA on a different subnet, all MACs are from gateway and not from device.

@scop

This comment has been minimized.

Copy link
Contributor Author

commented Aug 1, 2019

The use of mac address this way was already discussed in #24601 . Quoting Paulus from there:

Using Mac will help the 99% of the users that do not have a separate subnet for IoT. We should however only rely on it if we cannot get any other unique ID from the API.

See also my reply there.

@scop scop merged commit c2556d9 into home-assistant:dev Aug 1, 2019

11 checks passed

CI Build #20190801.83 succeeded
Details
CI (FullCheck Mypy) FullCheck Mypy succeeded
Details
CI (FullCheck Pylint) FullCheck Pylint succeeded
Details
CI (Overview CheckFormat) Overview CheckFormat succeeded
Details
CI (Overview Lint) Overview Lint succeeded
Details
CI (Overview Validate) Overview Validate succeeded
Details
CI (Tests PyTest Python36) Tests PyTest Python36 succeeded
Details
CI (Tests PyTest Python37) Tests PyTest Python37 succeeded
Details
cla-bot Everyone involved has signed the CLA
codecov/patch Coverage not affected when comparing 3bd7b15...94b4a73
Details
codecov/project 94% (target 90%)
Details

Dev automation moved this from Reviewer approved to Done Aug 1, 2019

@scop scop deleted the scop:huawei-lte-uniq-fix branch Aug 1, 2019

@lock lock bot locked and limited conversation to collaborators Aug 2, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
4 participants
You can’t perform that action at this time.