Clean up async_update_entity helper usage (#68641)

This commit is contained in:
Franck Nijhof 2022-03-25 23:22:58 +01:00 committed by GitHub
parent 53245c6523
commit d645e80ccd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 87 additions and 103 deletions

View file

@ -19,6 +19,7 @@ from homeassistant.const import (
)
from homeassistant.core import Context, CoreState, callback
from homeassistant.helpers import entity_registry
from homeassistant.helpers.entity_component import async_update_entity
from homeassistant.helpers.template import Template
from homeassistant.setup import ATTR_COMPONENT, async_setup_component
import homeassistant.util.dt as dt_util
@ -407,7 +408,7 @@ async def test_invalid_attribute_template(hass, caplog, start_ha, caplog_setup_t
hass.bus.async_fire(EVENT_HOMEASSISTANT_START)
await hass.async_block_till_done()
await hass.helpers.entity_component.async_update_entity("sensor.invalid_template")
await async_update_entity(hass, "sensor.invalid_template")
assert "TemplateError" in caplog_setup_text
assert "test_attribute" in caplog.text
@ -506,15 +507,11 @@ async def test_no_template_match_all(hass, caplog):
assert hass.states.get("sensor.invalid_friendly_name").state == "hello"
assert hass.states.get("sensor.invalid_attribute").state == "hello"
await hass.helpers.entity_component.async_update_entity("sensor.invalid_state")
await hass.helpers.entity_component.async_update_entity("sensor.invalid_icon")
await hass.helpers.entity_component.async_update_entity(
"sensor.invalid_entity_picture"
)
await hass.helpers.entity_component.async_update_entity(
"sensor.invalid_friendly_name"
)
await hass.helpers.entity_component.async_update_entity("sensor.invalid_attribute")
await async_update_entity(hass, "sensor.invalid_state")
await async_update_entity(hass, "sensor.invalid_icon")
await async_update_entity(hass, "sensor.invalid_entity_picture")
await async_update_entity(hass, "sensor.invalid_friendly_name")
await async_update_entity(hass, "sensor.invalid_attribute")
assert hass.states.get("sensor.invalid_state").state == "2"
assert hass.states.get("sensor.invalid_icon").state == "hello"