forked from platypush/platypush
Sanity check to prevent empty objects from being propagated to sensor.transform_entities
This commit is contained in:
parent
3f3726c50a
commit
99572f9731
1 changed files with 8 additions and 0 deletions
|
@ -335,6 +335,14 @@ class SensorPlugin(RunnablePlugin, SensorEntityManager, ABC):
|
||||||
def publish_entities(
|
def publish_entities(
|
||||||
self, entities: SensorDataType, *args, **kwargs
|
self, entities: SensorDataType, *args, **kwargs
|
||||||
) -> Collection[Entity]:
|
) -> Collection[Entity]:
|
||||||
|
# Skip empty data
|
||||||
|
if (
|
||||||
|
entities is None
|
||||||
|
or (isinstance(entities, dict) and not entities)
|
||||||
|
or (isinstance(entities, (list, tuple)) and not entities)
|
||||||
|
):
|
||||||
|
return []
|
||||||
|
|
||||||
return super().publish_entities(entities, *args, **kwargs) # type: ignore
|
return super().publish_entities(entities, *args, **kwargs) # type: ignore
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
|
|
Loading…
Reference in a new issue