Various light test improvements (#34131)

This commit is contained in:
Franck Nijhof 2020-04-13 15:33:04 +02:00 committed by GitHub
parent 4bcceb4078
commit 6d24a65313
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 418 additions and 259 deletions

View file

@ -319,11 +319,7 @@ class Entity(ABC):
else:
state = self.state
if state is None:
state = STATE_UNKNOWN
else:
state = str(state)
state = STATE_UNKNOWN if state is None else str(state)
attr.update(self.state_attributes or {})
attr.update(self.device_state_attributes or {})
@ -622,7 +618,7 @@ class ToggleEntity(Entity):
async def async_turn_on(self, **kwargs):
"""Turn the entity on."""
await self.hass.async_add_job(ft.partial(self.turn_on, **kwargs))
await self.hass.async_add_executor_job(ft.partial(self.turn_on, **kwargs))
def turn_off(self, **kwargs: Any) -> None:
"""Turn the entity off."""
@ -630,7 +626,7 @@ class ToggleEntity(Entity):
async def async_turn_off(self, **kwargs):
"""Turn the entity off."""
await self.hass.async_add_job(ft.partial(self.turn_off, **kwargs))
await self.hass.async_add_executor_job(ft.partial(self.turn_off, **kwargs))
def toggle(self, **kwargs: Any) -> None:
"""Toggle the entity."""