Skip to content

Inconsistent entity_id when multiple sensors#16205

Merged
balloob merged 3 commits intohome-assistant:devfrom
grea09:patch-2
Aug 26, 2018
Merged

Inconsistent entity_id when multiple sensors#16205
balloob merged 3 commits intohome-assistant:devfrom
grea09:patch-2

Conversation

@grea09
Copy link
Copy Markdown
Contributor

@grea09 grea09 commented Aug 26, 2018

I am submitting a change to fix a bug for when there are several sensors for the same hostname.

Description:

For example I want to track my IPv4 and IPv6 address. It creates two entities that regularly switch ids based on the order they get initialized.

To fix this I comform to the way other componnents have addressed the issue by adding an optional name attribute.

Related issue (if applicable): fixes #16204

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):

sensor:
  - platform: dnsip
    name: ipv4_pub
  - platform: dnsip
    name: ipv6_pub
    ipv6: true

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New or updated dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

I am submitting a change to fix a [bug](home-assistant#16204) for when there are several sensors for the same hostname. For example I want to track my IPv4 and IPv6 address. It creates two entities that regularly switch ids based on the order they get initialized.

To fix this I comform to the way other componnents have addressed the issue by adding an optional `name` attribute.
@ghost ghost added the in progress label Aug 26, 2018
def async_update(self):
"""Get the current DNS IP address for hostname."""
response = yield from self.resolver.query(self._name, self.querytype)
response = yield from self.resolver.query(self.hostname, self.querytype)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

line too long (80 > 79 characters)

grea09 added a commit to grea09/home-assistant.github.io that referenced this pull request Aug 26, 2018
In order to fix a [bug](home-assistant/core#16204) a new field needs to be introduced.

Pull request : home-assistant/core#16205
def async_update(self):
"""Get the current DNS IP address for hostname."""
response = yield from self.resolver.query(self._name, self.querytype)
response = yield from self.resolver.query(self.hostname,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

trailing whitespace

@balloob
Copy link
Copy Markdown
Member

balloob commented Aug 26, 2018

Great!

@balloob balloob merged commit 3032de1 into home-assistant:dev Aug 26, 2018
@ghost ghost removed the in progress label Aug 26, 2018
girlpunk pushed a commit to girlpunk/home-assistant that referenced this pull request Sep 4, 2018
* Inconsistent entity_id when multiple sensors

I am submitting a change to fix a [bug](home-assistant#16204) for when there are several sensors for the same hostname. For example I want to track my IPv4 and IPv6 address. It creates two entities that regularly switch ids based on the order they get initialized.

To fix this I comform to the way other componnents have addressed the issue by adding an optional `name` attribute.

* Line too long

* Removing trailing whitespace
@balloob balloob mentioned this pull request Sep 17, 2018
@Martinvdm
Copy link
Copy Markdown

This is a breaking change. my sensor was named sensor.myipopendnscom
but is now named sensor.myip. docs should be updated.

grea09 added a commit to grea09/home-assistant.github.io that referenced this pull request Sep 25, 2018
Adressing [comment](home-assistant/core#16205 (comment)) to reflect actual behaviour.
fabaff pushed a commit to home-assistant/home-assistant.io that referenced this pull request Sep 25, 2018
Adressing [comment](home-assistant/core#16205 (comment)) to reflect actual behaviour.
@home-assistant home-assistant locked and limited conversation to collaborators Feb 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DNS IP component prone to inconsistent entity_id

5 participants