Skip to content

Restore for automation entities#6254

Merged
balloob merged 4 commits into
home-assistant:devfrom
kellerza:restore_automation
Mar 4, 2017
Merged

Restore for automation entities#6254
balloob merged 4 commits into
home-assistant:devfrom
kellerza:restore_automation

Conversation

@kellerza
Copy link
Copy Markdown
Member

Description:

Restore for automation entities #4614

Example entry for configuration.yaml (if applicable):

recorder:

automation:

Checklist:

If the code does not interact with devices:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • Tests have been added to verify that the new code works.

@mention-bot
Copy link
Copy Markdown

@kellerza, thanks for your PR! By analyzing the history of the files in this pull request, we identified @balloob, @fabaff and @lwis to be potential reviewers.

Copy link
Copy Markdown
Member

@balloob balloob left a comment

Choose a reason for hiding this comment

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

Can you also extend your test to actually fire an event to make sure that not just the state in the state machine is correct but also the handlers are enabled/disabled.

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 check booleans with !=.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

too many blank lines (2)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

So why would this pass?

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.

I see also strange thing with assert in last time... I don't trust assert anymore

@pvizeli
Copy link
Copy Markdown
Member

pvizeli commented Mar 1, 2017

Need to be rebased. I change the handling a bit with new async bootstrap.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not very important, but it would be cool to pull in last_triggered here as well.


hass.bus.fire('test_event_hello')
yield from hass.async_block_till_done()
assert len(calls) == 1
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This seems to fail for py3.5 & 3.6, but always passes on 3.4

@pvizeli any ideas?

Comment thread tests/common.py

# pylint: disable=unnecessary-lambda
hass.services.register(domain, service, mock_service)
if hass.loop.__dict__.get("_thread_ident", 0) == threading.get_ident():
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.

I prefer if we make an async_mock_service and have mock_service call that

@balloob
Copy link
Copy Markdown
Member

balloob commented Mar 3, 2017

I think the test is failing because the automation is not properly enabled: there is no log entry that the automation was triggered.

ps, the sleep would never have worked because the event loop is 1 thread. So you just postponed executing all the further tasks, no race conditions could be resolved.

I would take a look but I don't have time right now

@balloob
Copy link
Copy Markdown
Member

balloob commented Mar 3, 2017

We should make sure that there is a test that enabling it works when there is no state to restore. (there might already be one)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

comparison to False should be 'if cond is False:' or 'if not cond:'

@kellerza kellerza force-pushed the restore_automation branch from d4ce06f to 06ca47e Compare March 3, 2017 16:29
@kellerza
Copy link
Copy Markdown
Member Author

kellerza commented Mar 3, 2017

💥 🐬 🎉

@balloob
Copy link
Copy Markdown
Member

balloob commented Mar 4, 2017

Very cool 🐬

@balloob balloob merged commit 1522e67 into home-assistant:dev Mar 4, 2017
@home-assistant home-assistant locked and limited conversation to collaborators Jul 17, 2017
@kellerza kellerza deleted the restore_automation branch March 18, 2018 20:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants