mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
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:
committed by
Paulus Schoutsen
parent
446f998759
commit
d13cc227cc
@@ -125,6 +125,15 @@ class Entity(object):
|
||||
"""Return True if unable to access real state of the entity."""
|
||||
return False
|
||||
|
||||
@property
|
||||
def force_update(self):
|
||||
"""Return True if state updates should be forced.
|
||||
|
||||
If True, a state change will be triggered anytime the state property is
|
||||
updated, not just when the value changes.
|
||||
"""
|
||||
return False
|
||||
|
||||
def update(self):
|
||||
"""Retrieve latest state."""
|
||||
pass
|
||||
@@ -190,7 +199,8 @@ class Entity(object):
|
||||
state, attr[ATTR_UNIT_OF_MEASUREMENT])
|
||||
state = str(state)
|
||||
|
||||
return self.hass.states.set(self.entity_id, state, attr)
|
||||
return self.hass.states.set(
|
||||
self.entity_id, state, attr, self.force_update)
|
||||
|
||||
def _attr_setter(self, name, typ, attr, attrs):
|
||||
"""Helper method to populate attributes based on properties."""
|
||||
|
||||
Reference in New Issue
Block a user