Push State (#2365)

* Add ability to push state changes

* Add tests for push state changes

* Fix style issues

* Use better name to force an update
This commit is contained in:
Philip Lundrigan 2016-06-26 01:33:23 -06:00 committed by Paulus Schoutsen
parent 446f998759
commit d13cc227cc
7 changed files with 72 additions and 9 deletions

View file

@ -204,11 +204,12 @@ class APIEntityStateView(HomeAssistantView):
return self.json_message('No state specified', HTTP_BAD_REQUEST)
attributes = request.json.get('attributes')
force_update = request.json.get('force_update', False)
is_new_state = self.hass.states.get(entity_id) is None
# Write state
self.hass.states.set(entity_id, new_state, attributes)
self.hass.states.set(entity_id, new_state, attributes, force_update)
# Read the state back for our response
resp = self.json(self.hass.states.get(entity_id))