Skip to content

Commit

Permalink
#58 Use last_updated and not last_changed in restore state query
Browse files Browse the repository at this point in the history
  • Loading branch information
slashback100 committed Jun 7, 2022
1 parent a26a42f commit a4b535f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion custom_components/presence_simulation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def _restore_state_sync(previous_attribute):
_LOGGER.debug("In restore State Sync")

session = hass.data[DATA_INSTANCE].get_session()
result = session.query(States.state, StateAttributes.shared_attrs).filter(States.attributes_id == StateAttributes.attributes_id).filter(States.entity_id == SWITCH_PLATFORM+"."+SWITCH).order_by(States.last_changed.desc()).limit(1)
result = session.query(States.state, StateAttributes.shared_attrs).filter(States.attributes_id == StateAttributes.attributes_id).filter(States.entity_id == SWITCH_PLATFORM+"."+SWITCH).order_by(States.last_updated.desc()).limit(1)
if result.count() > 0 and result[0][0] == "on":
previous_attribute["was_running"] = True
_LOGGER.debug("Simulation was on before last shutdown, restarting it.")
Expand Down
2 changes: 1 addition & 1 deletion custom_components/presence_simulation/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"issue_tracker": "https://github.com/slashback100/presence_simulation/issues",
"dependencies": ["history", "recorder", "scene"],
"config_flow": true,
"version": "1.16",
"version": "1.17",
"codeowners": [
"@slashback100"
],
Expand Down

0 comments on commit a4b535f

Please sign in to comment.