Skip to content

Update reading when device is added#15548

Merged
balloob merged 1 commit intohome-assistant:devfrom
quthla:patch-1
Jul 18, 2018
Merged

Update reading when device is added#15548
balloob merged 1 commit intohome-assistant:devfrom
quthla:patch-1

Conversation

@quthla
Copy link
Copy Markdown
Contributor

@quthla quthla commented Jul 18, 2018

Description:

Without this the first reading is received after scan_interval which is quite annoying in case scan interval is 300 seconds for example.

Related issue (if applicable): fixes #

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:

  • 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.

pass

async_add_devices(dev)
async_add_devices(dev, True)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please remove the call to update from the BME280Handler constructor.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Line 129?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if it's not needed to signal the underlying library the first reading.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

update is our method. Adding True as second argument will make sure that Home Assistant calls update before adding to the state machine. So yes remove line 129.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Resolved in chat. Update in constructor is not for an entity

@balloob balloob merged commit 22d961d into home-assistant:dev Jul 18, 2018
@ghost ghost removed the in progress label Jul 18, 2018
@quthla quthla deleted the patch-1 branch July 19, 2018 23:24
michaeldavie pushed a commit to michaeldavie/home-assistant that referenced this pull request Jul 31, 2018
@balloob balloob mentioned this pull request Aug 3, 2018
girlpunk pushed a commit to girlpunk/home-assistant that referenced this pull request Sep 4, 2018
@home-assistant home-assistant locked and limited conversation to collaborators Dec 10, 2018
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.

3 participants