Do not include unavailable entities in Google Assistant SYNC (#13358)
This commit is contained in:
1 parent
852eef8046
commit
cfb0b00c0c
3 files changed
+38
-2
No files matched your search
@@ -94,9 +94,16 @@ class _GoogleEntity:
|
||||
|
||||
https://developers.google.com/actions/smarthome/create-app#actiondevicessync
|
||||
"""
|
||||
traits = self.traits()
|
||||
state = self.state
|
||||
|
||||
# When a state is unavailable, the attributes that describe
|
||||
# capabilities will be stripped. For example, a light entity will miss
|
||||
# the min/max mireds. Therefore they will be excluded from a sync.
|
||||
if state.state == STATE_UNAVAILABLE:
|
||||
return None
|
||||
|
||||
traits = self.traits()
|
||||
|
||||
# Found no supported traits for this entity
|
||||
if not traits:
|
||||
return None
|
||||
|
||||
@@ -52,6 +52,7 @@ class DemoLight(Light):
|
||||
self._white = white
|
||||
self._effect_list = effect_list
|
||||
self._effect = effect
|
||||
self._available = True
|
||||
|
||||
@property
|
||||
def should_poll(self) -> bool:
|
||||
@@ -73,7 +74,7 @@ class DemoLight(Light):
|
||||
"""Return availability."""
|
||||
# This demo light is always available, but well-behaving components
|
||||
# should implement this to inform Home Assistant accordingly.
|
||||
return True
|
||||
return self._available
|
||||
|
||||
@property
|
||||
def brightness(self) -> int:
|
||||
|
||||
Reference in new issue
Block a user