mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Refactor recorder tests to use recorder history API (#89565)
This commit is contained in:
parent
50c31a5355
commit
1c57339ec3
@ -12,11 +12,11 @@ from homeassistant.components.automation import (
|
|||||||
CONF_ID,
|
CONF_ID,
|
||||||
)
|
)
|
||||||
from homeassistant.components.recorder import Recorder
|
from homeassistant.components.recorder import Recorder
|
||||||
from homeassistant.components.recorder.db_schema import StateAttributes, States
|
from homeassistant.components.recorder.history import get_significant_states
|
||||||
from homeassistant.components.recorder.util import session_scope
|
|
||||||
from homeassistant.const import ATTR_ENTITY_ID, ATTR_FRIENDLY_NAME
|
from homeassistant.const import ATTR_ENTITY_ID, ATTR_FRIENDLY_NAME
|
||||||
from homeassistant.core import HomeAssistant, State
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
from tests.common import async_mock_service
|
from tests.common import async_mock_service
|
||||||
from tests.components.recorder.common import async_wait_recording_done
|
from tests.components.recorder.common import async_wait_recording_done
|
||||||
@ -32,6 +32,7 @@ async def test_exclude_attributes(
|
|||||||
recorder_mock: Recorder, hass: HomeAssistant, calls
|
recorder_mock: Recorder, hass: HomeAssistant, calls
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test automation registered attributes to be excluded."""
|
"""Test automation registered attributes to be excluded."""
|
||||||
|
now = dt_util.utcnow()
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
hass,
|
hass,
|
||||||
automation.DOMAIN,
|
automation.DOMAIN,
|
||||||
@ -49,25 +50,13 @@ async def test_exclude_attributes(
|
|||||||
assert ["hello.world"] == calls[0].data.get(ATTR_ENTITY_ID)
|
assert ["hello.world"] == calls[0].data.get(ATTR_ENTITY_ID)
|
||||||
await async_wait_recording_done(hass)
|
await async_wait_recording_done(hass)
|
||||||
|
|
||||||
def _fetch_states() -> list[State]:
|
states = await hass.async_add_executor_job(get_significant_states, hass, now)
|
||||||
with session_scope(hass=hass) as session:
|
assert len(states) == 1
|
||||||
native_states = []
|
for entity_states in states.values():
|
||||||
for db_state, db_state_attributes in session.query(
|
for state in entity_states:
|
||||||
States, StateAttributes
|
assert ATTR_LAST_TRIGGERED not in state.attributes
|
||||||
).outerjoin(
|
assert ATTR_MODE not in state.attributes
|
||||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
assert ATTR_CUR not in state.attributes
|
||||||
):
|
assert CONF_ID not in state.attributes
|
||||||
state = db_state.to_native()
|
assert ATTR_MAX not in state.attributes
|
||||||
state.attributes = db_state_attributes.to_native()
|
assert ATTR_FRIENDLY_NAME in state.attributes
|
||||||
native_states.append(state)
|
|
||||||
return native_states
|
|
||||||
|
|
||||||
states: list[State] = await hass.async_add_executor_job(_fetch_states)
|
|
||||||
assert len(states) > 1
|
|
||||||
for state in states:
|
|
||||||
assert ATTR_LAST_TRIGGERED not in state.attributes
|
|
||||||
assert ATTR_MODE not in state.attributes
|
|
||||||
assert ATTR_CUR not in state.attributes
|
|
||||||
assert CONF_ID not in state.attributes
|
|
||||||
assert ATTR_MAX not in state.attributes
|
|
||||||
assert ATTR_FRIENDLY_NAME in state.attributes
|
|
||||||
|
@ -2,10 +2,9 @@
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
from homeassistant.components.recorder import Recorder
|
from homeassistant.components.recorder import Recorder
|
||||||
from homeassistant.components.recorder.db_schema import StateAttributes, States
|
from homeassistant.components.recorder.history import get_significant_states
|
||||||
from homeassistant.components.recorder.util import session_scope
|
|
||||||
from homeassistant.const import ATTR_FRIENDLY_NAME
|
from homeassistant.const import ATTR_FRIENDLY_NAME
|
||||||
from homeassistant.core import HomeAssistant, State
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
@ -15,6 +14,7 @@ from tests.components.recorder.common import async_wait_recording_done
|
|||||||
|
|
||||||
async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
||||||
"""Test sensor attributes to be excluded."""
|
"""Test sensor attributes to be excluded."""
|
||||||
|
now = dt_util.utcnow()
|
||||||
await async_setup_component(hass, "calendar", {"calendar": {"platform": "demo"}})
|
await async_setup_component(hass, "calendar", {"calendar": {"platform": "demo"}})
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
@ -28,21 +28,9 @@ async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant)
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
await async_wait_recording_done(hass)
|
await async_wait_recording_done(hass)
|
||||||
|
|
||||||
def _fetch_states() -> list[State]:
|
states = await hass.async_add_executor_job(get_significant_states, hass, now)
|
||||||
with session_scope(hass=hass) as session:
|
|
||||||
native_states = []
|
|
||||||
for db_state, db_state_attributes in session.query(
|
|
||||||
States, StateAttributes
|
|
||||||
).outerjoin(
|
|
||||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
|
||||||
):
|
|
||||||
state = db_state.to_native()
|
|
||||||
state.attributes = db_state_attributes.to_native()
|
|
||||||
native_states.append(state)
|
|
||||||
return native_states
|
|
||||||
|
|
||||||
states: list[State] = await hass.async_add_executor_job(_fetch_states)
|
|
||||||
assert len(states) > 1
|
assert len(states) > 1
|
||||||
for state in states:
|
for entity_states in states.values():
|
||||||
assert ATTR_FRIENDLY_NAME in state.attributes
|
for state in entity_states:
|
||||||
assert "description" not in state.attributes
|
assert ATTR_FRIENDLY_NAME in state.attributes
|
||||||
|
assert "description" not in state.attributes
|
||||||
|
@ -5,15 +5,14 @@ from datetime import timedelta
|
|||||||
|
|
||||||
from homeassistant.components import camera
|
from homeassistant.components import camera
|
||||||
from homeassistant.components.recorder import Recorder
|
from homeassistant.components.recorder import Recorder
|
||||||
from homeassistant.components.recorder.db_schema import StateAttributes, States
|
from homeassistant.components.recorder.history import get_significant_states
|
||||||
from homeassistant.components.recorder.util import session_scope
|
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ATTRIBUTION,
|
ATTR_ATTRIBUTION,
|
||||||
ATTR_ENTITY_PICTURE,
|
ATTR_ENTITY_PICTURE,
|
||||||
ATTR_FRIENDLY_NAME,
|
ATTR_FRIENDLY_NAME,
|
||||||
ATTR_SUPPORTED_FEATURES,
|
ATTR_SUPPORTED_FEATURES,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant, State
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
@ -23,6 +22,7 @@ from tests.components.recorder.common import async_wait_recording_done
|
|||||||
|
|
||||||
async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
||||||
"""Test camera registered attributes to be excluded."""
|
"""Test camera registered attributes to be excluded."""
|
||||||
|
now = dt_util.utcnow()
|
||||||
await async_setup_component(
|
await async_setup_component(
|
||||||
hass, camera.DOMAIN, {camera.DOMAIN: {"platform": "demo"}}
|
hass, camera.DOMAIN, {camera.DOMAIN: {"platform": "demo"}}
|
||||||
)
|
)
|
||||||
@ -31,24 +31,12 @@ async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant)
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
await async_wait_recording_done(hass)
|
await async_wait_recording_done(hass)
|
||||||
|
|
||||||
def _fetch_camera_states() -> list[State]:
|
states = await hass.async_add_executor_job(get_significant_states, hass, now)
|
||||||
with session_scope(hass=hass) as session:
|
|
||||||
native_states = []
|
|
||||||
for db_state, db_state_attributes in session.query(
|
|
||||||
States, StateAttributes
|
|
||||||
).outerjoin(
|
|
||||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
|
||||||
):
|
|
||||||
state = db_state.to_native()
|
|
||||||
state.attributes = db_state_attributes.to_native()
|
|
||||||
native_states.append(state)
|
|
||||||
return native_states
|
|
||||||
|
|
||||||
states: list[State] = await hass.async_add_executor_job(_fetch_camera_states)
|
|
||||||
assert len(states) > 1
|
assert len(states) > 1
|
||||||
for state in states:
|
for entity_states in states.values():
|
||||||
assert "access_token" not in state.attributes
|
for state in entity_states:
|
||||||
assert ATTR_ENTITY_PICTURE not in state.attributes
|
assert "access_token" not in state.attributes
|
||||||
assert ATTR_ATTRIBUTION not in state.attributes
|
assert ATTR_ENTITY_PICTURE not in state.attributes
|
||||||
assert ATTR_SUPPORTED_FEATURES not in state.attributes
|
assert ATTR_ATTRIBUTION not in state.attributes
|
||||||
assert ATTR_FRIENDLY_NAME in state.attributes
|
assert ATTR_SUPPORTED_FEATURES not in state.attributes
|
||||||
|
assert ATTR_FRIENDLY_NAME in state.attributes
|
||||||
|
@ -16,10 +16,9 @@ from homeassistant.components.climate import (
|
|||||||
ATTR_TARGET_TEMP_STEP,
|
ATTR_TARGET_TEMP_STEP,
|
||||||
)
|
)
|
||||||
from homeassistant.components.recorder import Recorder
|
from homeassistant.components.recorder import Recorder
|
||||||
from homeassistant.components.recorder.db_schema import StateAttributes, States
|
from homeassistant.components.recorder.history import get_significant_states
|
||||||
from homeassistant.components.recorder.util import session_scope
|
|
||||||
from homeassistant.const import ATTR_FRIENDLY_NAME
|
from homeassistant.const import ATTR_FRIENDLY_NAME
|
||||||
from homeassistant.core import HomeAssistant, State
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
@ -29,6 +28,7 @@ from tests.components.recorder.common import async_wait_recording_done
|
|||||||
|
|
||||||
async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
||||||
"""Test climate registered attributes to be excluded."""
|
"""Test climate registered attributes to be excluded."""
|
||||||
|
now = dt_util.utcnow()
|
||||||
await async_setup_component(
|
await async_setup_component(
|
||||||
hass, climate.DOMAIN, {climate.DOMAIN: {"platform": "demo"}}
|
hass, climate.DOMAIN, {climate.DOMAIN: {"platform": "demo"}}
|
||||||
)
|
)
|
||||||
@ -37,29 +37,17 @@ async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant)
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
await async_wait_recording_done(hass)
|
await async_wait_recording_done(hass)
|
||||||
|
|
||||||
def _fetch_states() -> list[State]:
|
states = await hass.async_add_executor_job(get_significant_states, hass, now)
|
||||||
with session_scope(hass=hass) as session:
|
|
||||||
native_states = []
|
|
||||||
for db_state, db_state_attributes in session.query(
|
|
||||||
States, StateAttributes
|
|
||||||
).outerjoin(
|
|
||||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
|
||||||
):
|
|
||||||
state = db_state.to_native()
|
|
||||||
state.attributes = db_state_attributes.to_native()
|
|
||||||
native_states.append(state)
|
|
||||||
return native_states
|
|
||||||
|
|
||||||
states: list[State] = await hass.async_add_executor_job(_fetch_states)
|
|
||||||
assert len(states) > 1
|
assert len(states) > 1
|
||||||
for state in states:
|
for entity_states in states.values():
|
||||||
assert ATTR_PRESET_MODES not in state.attributes
|
for state in entity_states:
|
||||||
assert ATTR_HVAC_MODES not in state.attributes
|
assert ATTR_PRESET_MODES not in state.attributes
|
||||||
assert ATTR_FAN_MODES not in state.attributes
|
assert ATTR_HVAC_MODES not in state.attributes
|
||||||
assert ATTR_SWING_MODES not in state.attributes
|
assert ATTR_FAN_MODES not in state.attributes
|
||||||
assert ATTR_MIN_TEMP not in state.attributes
|
assert ATTR_SWING_MODES not in state.attributes
|
||||||
assert ATTR_MAX_TEMP not in state.attributes
|
assert ATTR_MIN_TEMP not in state.attributes
|
||||||
assert ATTR_MIN_HUMIDITY not in state.attributes
|
assert ATTR_MAX_TEMP not in state.attributes
|
||||||
assert ATTR_MAX_HUMIDITY not in state.attributes
|
assert ATTR_MIN_HUMIDITY not in state.attributes
|
||||||
assert ATTR_TARGET_TEMP_STEP not in state.attributes
|
assert ATTR_MAX_HUMIDITY not in state.attributes
|
||||||
assert ATTR_FRIENDLY_NAME in state.attributes
|
assert ATTR_TARGET_TEMP_STEP not in state.attributes
|
||||||
|
assert ATTR_FRIENDLY_NAME in state.attributes
|
||||||
|
@ -6,10 +6,9 @@ from datetime import timedelta
|
|||||||
from homeassistant.components import fan
|
from homeassistant.components import fan
|
||||||
from homeassistant.components.fan import ATTR_PRESET_MODES
|
from homeassistant.components.fan import ATTR_PRESET_MODES
|
||||||
from homeassistant.components.recorder import Recorder
|
from homeassistant.components.recorder import Recorder
|
||||||
from homeassistant.components.recorder.db_schema import StateAttributes, States
|
from homeassistant.components.recorder.history import get_significant_states
|
||||||
from homeassistant.components.recorder.util import session_scope
|
|
||||||
from homeassistant.const import ATTR_FRIENDLY_NAME
|
from homeassistant.const import ATTR_FRIENDLY_NAME
|
||||||
from homeassistant.core import HomeAssistant, State
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
@ -19,27 +18,16 @@ from tests.components.recorder.common import async_wait_recording_done
|
|||||||
|
|
||||||
async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
||||||
"""Test fan registered attributes to be excluded."""
|
"""Test fan registered attributes to be excluded."""
|
||||||
|
now = dt_util.utcnow()
|
||||||
await async_setup_component(hass, fan.DOMAIN, {fan.DOMAIN: {"platform": "demo"}})
|
await async_setup_component(hass, fan.DOMAIN, {fan.DOMAIN: {"platform": "demo"}})
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
async_fire_time_changed(hass, dt_util.utcnow() + timedelta(minutes=5))
|
async_fire_time_changed(hass, dt_util.utcnow() + timedelta(minutes=5))
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
await async_wait_recording_done(hass)
|
await async_wait_recording_done(hass)
|
||||||
|
|
||||||
def _fetch_states() -> list[State]:
|
states = await hass.async_add_executor_job(get_significant_states, hass, now)
|
||||||
with session_scope(hass=hass) as session:
|
|
||||||
native_states = []
|
|
||||||
for db_state, db_state_attributes in session.query(
|
|
||||||
States, StateAttributes
|
|
||||||
).outerjoin(
|
|
||||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
|
||||||
):
|
|
||||||
state = db_state.to_native()
|
|
||||||
state.attributes = db_state_attributes.to_native()
|
|
||||||
native_states.append(state)
|
|
||||||
return native_states
|
|
||||||
|
|
||||||
states: list[State] = await hass.async_add_executor_job(_fetch_states)
|
|
||||||
assert len(states) > 1
|
assert len(states) > 1
|
||||||
for state in states:
|
for entity_states in states.values():
|
||||||
assert ATTR_PRESET_MODES not in state.attributes
|
for state in entity_states:
|
||||||
assert ATTR_FRIENDLY_NAME in state.attributes
|
assert ATTR_PRESET_MODES not in state.attributes
|
||||||
|
assert ATTR_FRIENDLY_NAME in state.attributes
|
||||||
|
@ -6,10 +6,9 @@ from datetime import timedelta
|
|||||||
from homeassistant.components import group
|
from homeassistant.components import group
|
||||||
from homeassistant.components.group import ATTR_AUTO, ATTR_ENTITY_ID, ATTR_ORDER
|
from homeassistant.components.group import ATTR_AUTO, ATTR_ENTITY_ID, ATTR_ORDER
|
||||||
from homeassistant.components.recorder import Recorder
|
from homeassistant.components.recorder import Recorder
|
||||||
from homeassistant.components.recorder.db_schema import StateAttributes, States
|
from homeassistant.components.recorder.history import get_significant_states
|
||||||
from homeassistant.components.recorder.util import session_scope
|
|
||||||
from homeassistant.const import ATTR_FRIENDLY_NAME, STATE_ON
|
from homeassistant.const import ATTR_FRIENDLY_NAME, STATE_ON
|
||||||
from homeassistant.core import HomeAssistant, State
|
from homeassistant.core import HomeAssistant, split_entity_id
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
@ -19,6 +18,7 @@ from tests.components.recorder.common import async_wait_recording_done
|
|||||||
|
|
||||||
async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
||||||
"""Test number registered attributes to be excluded."""
|
"""Test number registered attributes to be excluded."""
|
||||||
|
now = dt_util.utcnow()
|
||||||
hass.states.async_set("light.bowl", STATE_ON)
|
hass.states.async_set("light.bowl", STATE_ON)
|
||||||
|
|
||||||
assert await async_setup_component(hass, "light", {})
|
assert await async_setup_component(hass, "light", {})
|
||||||
@ -38,27 +38,12 @@ async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant)
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
await async_wait_recording_done(hass)
|
await async_wait_recording_done(hass)
|
||||||
|
|
||||||
def _fetch_states() -> list[State]:
|
states = await hass.async_add_executor_job(get_significant_states, hass, now)
|
||||||
with session_scope(hass=hass) as session:
|
|
||||||
native_states = []
|
|
||||||
attr_ids = {}
|
|
||||||
for db_state_attributes in session.query(StateAttributes):
|
|
||||||
attr_ids[
|
|
||||||
db_state_attributes.attributes_id
|
|
||||||
] = db_state_attributes.to_native()
|
|
||||||
for db_state, _ in session.query(States, StateAttributes).outerjoin(
|
|
||||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
|
||||||
):
|
|
||||||
state = db_state.to_native()
|
|
||||||
state.attributes = attr_ids[db_state.attributes_id]
|
|
||||||
native_states.append(state)
|
|
||||||
return native_states
|
|
||||||
|
|
||||||
states: list[State] = await hass.async_add_executor_job(_fetch_states)
|
|
||||||
assert len(states) > 1
|
assert len(states) > 1
|
||||||
for state in states:
|
for entity_states in states.values():
|
||||||
if state.domain == group.DOMAIN:
|
for state in entity_states:
|
||||||
assert ATTR_AUTO not in state.attributes
|
if split_entity_id(state.entity_id)[0] == group.DOMAIN:
|
||||||
assert ATTR_ENTITY_ID not in state.attributes
|
assert ATTR_AUTO not in state.attributes
|
||||||
assert ATTR_ORDER not in state.attributes
|
assert ATTR_ENTITY_ID not in state.attributes
|
||||||
assert ATTR_FRIENDLY_NAME in state.attributes
|
assert ATTR_ORDER not in state.attributes
|
||||||
|
assert ATTR_FRIENDLY_NAME in state.attributes
|
||||||
|
@ -10,10 +10,9 @@ from homeassistant.components.humidifier import (
|
|||||||
ATTR_MIN_HUMIDITY,
|
ATTR_MIN_HUMIDITY,
|
||||||
)
|
)
|
||||||
from homeassistant.components.recorder import Recorder
|
from homeassistant.components.recorder import Recorder
|
||||||
from homeassistant.components.recorder.db_schema import StateAttributes, States
|
from homeassistant.components.recorder.history import get_significant_states
|
||||||
from homeassistant.components.recorder.util import session_scope
|
|
||||||
from homeassistant.const import ATTR_FRIENDLY_NAME
|
from homeassistant.const import ATTR_FRIENDLY_NAME
|
||||||
from homeassistant.core import HomeAssistant, State
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
@ -23,6 +22,7 @@ from tests.components.recorder.common import async_wait_recording_done
|
|||||||
|
|
||||||
async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
||||||
"""Test humidifier registered attributes to be excluded."""
|
"""Test humidifier registered attributes to be excluded."""
|
||||||
|
now = dt_util.utcnow()
|
||||||
await async_setup_component(
|
await async_setup_component(
|
||||||
hass, humidifier.DOMAIN, {humidifier.DOMAIN: {"platform": "demo"}}
|
hass, humidifier.DOMAIN, {humidifier.DOMAIN: {"platform": "demo"}}
|
||||||
)
|
)
|
||||||
@ -31,23 +31,11 @@ async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant)
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
await async_wait_recording_done(hass)
|
await async_wait_recording_done(hass)
|
||||||
|
|
||||||
def _fetch_states() -> list[State]:
|
states = await hass.async_add_executor_job(get_significant_states, hass, now)
|
||||||
with session_scope(hass=hass) as session:
|
|
||||||
native_states = []
|
|
||||||
for db_state, db_state_attributes in session.query(
|
|
||||||
States, StateAttributes
|
|
||||||
).outerjoin(
|
|
||||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
|
||||||
):
|
|
||||||
state = db_state.to_native()
|
|
||||||
state.attributes = db_state_attributes.to_native()
|
|
||||||
native_states.append(state)
|
|
||||||
return native_states
|
|
||||||
|
|
||||||
states: list[State] = await hass.async_add_executor_job(_fetch_states)
|
|
||||||
assert len(states) > 1
|
assert len(states) > 1
|
||||||
for state in states:
|
for entity_states in states.values():
|
||||||
assert ATTR_MIN_HUMIDITY not in state.attributes
|
for state in entity_states:
|
||||||
assert ATTR_MAX_HUMIDITY not in state.attributes
|
assert ATTR_MIN_HUMIDITY not in state.attributes
|
||||||
assert ATTR_AVAILABLE_MODES not in state.attributes
|
assert ATTR_MAX_HUMIDITY not in state.attributes
|
||||||
assert ATTR_FRIENDLY_NAME in state.attributes
|
assert ATTR_AVAILABLE_MODES not in state.attributes
|
||||||
|
assert ATTR_FRIENDLY_NAME in state.attributes
|
||||||
|
@ -5,10 +5,9 @@ from datetime import timedelta
|
|||||||
|
|
||||||
from homeassistant.components.input_boolean import DOMAIN
|
from homeassistant.components.input_boolean import DOMAIN
|
||||||
from homeassistant.components.recorder import Recorder
|
from homeassistant.components.recorder import Recorder
|
||||||
from homeassistant.components.recorder.db_schema import StateAttributes, States
|
from homeassistant.components.recorder.history import get_significant_states
|
||||||
from homeassistant.components.recorder.util import session_scope
|
|
||||||
from homeassistant.const import ATTR_EDITABLE
|
from homeassistant.const import ATTR_EDITABLE
|
||||||
from homeassistant.core import HomeAssistant, State
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
@ -20,6 +19,7 @@ async def test_exclude_attributes(
|
|||||||
recorder_mock: Recorder, hass: HomeAssistant, enable_custom_integrations: None
|
recorder_mock: Recorder, hass: HomeAssistant, enable_custom_integrations: None
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test attributes to be excluded."""
|
"""Test attributes to be excluded."""
|
||||||
|
now = dt_util.utcnow()
|
||||||
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {"test": {}}})
|
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {"test": {}}})
|
||||||
|
|
||||||
state = hass.states.get("input_boolean.test")
|
state = hass.states.get("input_boolean.test")
|
||||||
@ -30,20 +30,8 @@ async def test_exclude_attributes(
|
|||||||
async_fire_time_changed(hass, dt_util.utcnow() + timedelta(minutes=5))
|
async_fire_time_changed(hass, dt_util.utcnow() + timedelta(minutes=5))
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
await async_wait_recording_done(hass)
|
await async_wait_recording_done(hass)
|
||||||
|
states = await hass.async_add_executor_job(get_significant_states, hass, now)
|
||||||
def _fetch_states() -> list[State]:
|
assert len(states) >= 1
|
||||||
with session_scope(hass=hass) as session:
|
for entity_states in states.values():
|
||||||
native_states = []
|
for state in entity_states:
|
||||||
for db_state, db_state_attributes in session.query(
|
assert ATTR_EDITABLE not in state.attributes
|
||||||
States, StateAttributes
|
|
||||||
).outerjoin(
|
|
||||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
|
||||||
):
|
|
||||||
state = db_state.to_native()
|
|
||||||
state.attributes = db_state_attributes.to_native()
|
|
||||||
native_states.append(state)
|
|
||||||
return native_states
|
|
||||||
|
|
||||||
states: list[State] = await hass.async_add_executor_job(_fetch_states)
|
|
||||||
assert len(states) == 1
|
|
||||||
assert ATTR_EDITABLE not in states[0].attributes
|
|
||||||
|
@ -5,10 +5,9 @@ from datetime import timedelta
|
|||||||
|
|
||||||
from homeassistant.components.input_button import DOMAIN
|
from homeassistant.components.input_button import DOMAIN
|
||||||
from homeassistant.components.recorder import Recorder
|
from homeassistant.components.recorder import Recorder
|
||||||
from homeassistant.components.recorder.db_schema import StateAttributes, States
|
from homeassistant.components.recorder.history import get_significant_states
|
||||||
from homeassistant.components.recorder.util import session_scope
|
|
||||||
from homeassistant.const import ATTR_EDITABLE
|
from homeassistant.const import ATTR_EDITABLE
|
||||||
from homeassistant.core import HomeAssistant, State
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
@ -20,6 +19,7 @@ async def test_exclude_attributes(
|
|||||||
recorder_mock: Recorder, hass: HomeAssistant, enable_custom_integrations: None
|
recorder_mock: Recorder, hass: HomeAssistant, enable_custom_integrations: None
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test attributes to be excluded."""
|
"""Test attributes to be excluded."""
|
||||||
|
now = dt_util.utcnow()
|
||||||
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {"test": {}}})
|
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {"test": {}}})
|
||||||
|
|
||||||
state = hass.states.get("input_button.test")
|
state = hass.states.get("input_button.test")
|
||||||
@ -31,19 +31,8 @@ async def test_exclude_attributes(
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
await async_wait_recording_done(hass)
|
await async_wait_recording_done(hass)
|
||||||
|
|
||||||
def _fetch_states() -> list[State]:
|
states = await hass.async_add_executor_job(get_significant_states, hass, now)
|
||||||
with session_scope(hass=hass) as session:
|
assert len(states) >= 1
|
||||||
native_states = []
|
for entity_states in states.values():
|
||||||
for db_state, db_state_attributes in session.query(
|
for state in entity_states:
|
||||||
States, StateAttributes
|
assert ATTR_EDITABLE not in state.attributes
|
||||||
).outerjoin(
|
|
||||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
|
||||||
):
|
|
||||||
state = db_state.to_native()
|
|
||||||
state.attributes = db_state_attributes.to_native()
|
|
||||||
native_states.append(state)
|
|
||||||
return native_states
|
|
||||||
|
|
||||||
states: list[State] = await hass.async_add_executor_job(_fetch_states)
|
|
||||||
assert len(states) == 1
|
|
||||||
assert ATTR_EDITABLE not in states[0].attributes
|
|
||||||
|
@ -5,10 +5,9 @@ from datetime import timedelta
|
|||||||
|
|
||||||
from homeassistant.components.input_datetime import CONF_HAS_DATE, CONF_HAS_TIME, DOMAIN
|
from homeassistant.components.input_datetime import CONF_HAS_DATE, CONF_HAS_TIME, DOMAIN
|
||||||
from homeassistant.components.recorder import Recorder
|
from homeassistant.components.recorder import Recorder
|
||||||
from homeassistant.components.recorder.db_schema import StateAttributes, States
|
from homeassistant.components.recorder.history import get_significant_states
|
||||||
from homeassistant.components.recorder.util import session_scope
|
|
||||||
from homeassistant.const import ATTR_EDITABLE
|
from homeassistant.const import ATTR_EDITABLE
|
||||||
from homeassistant.core import HomeAssistant, State
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
@ -20,6 +19,7 @@ async def test_exclude_attributes(
|
|||||||
recorder_mock: Recorder, hass: HomeAssistant, enable_custom_integrations: None
|
recorder_mock: Recorder, hass: HomeAssistant, enable_custom_integrations: None
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test attributes to be excluded."""
|
"""Test attributes to be excluded."""
|
||||||
|
now = dt_util.utcnow()
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
hass, DOMAIN, {DOMAIN: {"test": {CONF_HAS_TIME: True}}}
|
hass, DOMAIN, {DOMAIN: {"test": {CONF_HAS_TIME: True}}}
|
||||||
)
|
)
|
||||||
@ -35,21 +35,10 @@ async def test_exclude_attributes(
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
await async_wait_recording_done(hass)
|
await async_wait_recording_done(hass)
|
||||||
|
|
||||||
def _fetch_states() -> list[State]:
|
states = await hass.async_add_executor_job(get_significant_states, hass, now)
|
||||||
with session_scope(hass=hass) as session:
|
assert len(states) >= 1
|
||||||
native_states = []
|
for entity_states in states.values():
|
||||||
for db_state, db_state_attributes in session.query(
|
for state in entity_states:
|
||||||
States, StateAttributes
|
assert ATTR_EDITABLE not in state.attributes
|
||||||
).outerjoin(
|
assert CONF_HAS_DATE not in state.attributes
|
||||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
assert CONF_HAS_TIME not in state.attributes
|
||||||
):
|
|
||||||
state = db_state.to_native()
|
|
||||||
state.attributes = db_state_attributes.to_native()
|
|
||||||
native_states.append(state)
|
|
||||||
return native_states
|
|
||||||
|
|
||||||
states: list[State] = await hass.async_add_executor_job(_fetch_states)
|
|
||||||
assert len(states) == 1
|
|
||||||
assert ATTR_EDITABLE not in states[0].attributes
|
|
||||||
assert CONF_HAS_DATE not in states[0].attributes
|
|
||||||
assert CONF_HAS_TIME not in states[0].attributes
|
|
||||||
|
@ -11,10 +11,9 @@ from homeassistant.components.input_number import (
|
|||||||
DOMAIN,
|
DOMAIN,
|
||||||
)
|
)
|
||||||
from homeassistant.components.recorder import Recorder
|
from homeassistant.components.recorder import Recorder
|
||||||
from homeassistant.components.recorder.db_schema import StateAttributes, States
|
from homeassistant.components.recorder.history import get_significant_states
|
||||||
from homeassistant.components.recorder.util import session_scope
|
|
||||||
from homeassistant.const import ATTR_EDITABLE
|
from homeassistant.const import ATTR_EDITABLE
|
||||||
from homeassistant.core import HomeAssistant, State
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
@ -26,6 +25,7 @@ async def test_exclude_attributes(
|
|||||||
recorder_mock: Recorder, hass: HomeAssistant, enable_custom_integrations: None
|
recorder_mock: Recorder, hass: HomeAssistant, enable_custom_integrations: None
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test attributes to be excluded."""
|
"""Test attributes to be excluded."""
|
||||||
|
now = dt_util.utcnow()
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
hass, DOMAIN, {DOMAIN: {"test": {"min": 0, "max": 100}}}
|
hass, DOMAIN, {DOMAIN: {"test": {"min": 0, "max": 100}}}
|
||||||
)
|
)
|
||||||
@ -43,23 +43,12 @@ async def test_exclude_attributes(
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
await async_wait_recording_done(hass)
|
await async_wait_recording_done(hass)
|
||||||
|
|
||||||
def _fetch_states() -> list[State]:
|
states = await hass.async_add_executor_job(get_significant_states, hass, now)
|
||||||
with session_scope(hass=hass) as session:
|
assert len(states) >= 1
|
||||||
native_states = []
|
for entity_states in states.values():
|
||||||
for db_state, db_state_attributes in session.query(
|
for state in entity_states:
|
||||||
States, StateAttributes
|
assert ATTR_EDITABLE not in state.attributes
|
||||||
).outerjoin(
|
assert ATTR_MIN not in state.attributes
|
||||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
assert ATTR_MAX not in state.attributes
|
||||||
):
|
assert ATTR_STEP not in state.attributes
|
||||||
state = db_state.to_native()
|
assert ATTR_MODE not in state.attributes
|
||||||
state.attributes = db_state_attributes.to_native()
|
|
||||||
native_states.append(state)
|
|
||||||
return native_states
|
|
||||||
|
|
||||||
states: list[State] = await hass.async_add_executor_job(_fetch_states)
|
|
||||||
assert len(states) == 1
|
|
||||||
assert ATTR_EDITABLE not in states[0].attributes
|
|
||||||
assert ATTR_MIN not in states[0].attributes
|
|
||||||
assert ATTR_MAX not in states[0].attributes
|
|
||||||
assert ATTR_STEP not in states[0].attributes
|
|
||||||
assert ATTR_MODE not in states[0].attributes
|
|
||||||
|
@ -5,10 +5,9 @@ from datetime import timedelta
|
|||||||
|
|
||||||
from homeassistant.components.input_select import ATTR_OPTIONS, DOMAIN
|
from homeassistant.components.input_select import ATTR_OPTIONS, DOMAIN
|
||||||
from homeassistant.components.recorder import Recorder
|
from homeassistant.components.recorder import Recorder
|
||||||
from homeassistant.components.recorder.db_schema import StateAttributes, States
|
from homeassistant.components.recorder.history import get_significant_states
|
||||||
from homeassistant.components.recorder.util import session_scope
|
|
||||||
from homeassistant.const import ATTR_EDITABLE
|
from homeassistant.const import ATTR_EDITABLE
|
||||||
from homeassistant.core import HomeAssistant, State
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
@ -20,6 +19,7 @@ async def test_exclude_attributes(
|
|||||||
recorder_mock: Recorder, hass: HomeAssistant, enable_custom_integrations: None
|
recorder_mock: Recorder, hass: HomeAssistant, enable_custom_integrations: None
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test attributes to be excluded."""
|
"""Test attributes to be excluded."""
|
||||||
|
now = dt_util.utcnow()
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
hass,
|
hass,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
@ -42,20 +42,9 @@ async def test_exclude_attributes(
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
await async_wait_recording_done(hass)
|
await async_wait_recording_done(hass)
|
||||||
|
|
||||||
def _fetch_states() -> list[State]:
|
states = await hass.async_add_executor_job(get_significant_states, hass, now)
|
||||||
with session_scope(hass=hass) as session:
|
assert len(states) >= 1
|
||||||
native_states = []
|
for entity_states in states.values():
|
||||||
for db_state, db_state_attributes in session.query(
|
for state in entity_states:
|
||||||
States, StateAttributes
|
assert ATTR_EDITABLE not in state.attributes
|
||||||
).outerjoin(
|
assert ATTR_OPTIONS in state.attributes
|
||||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
|
||||||
):
|
|
||||||
state = db_state.to_native()
|
|
||||||
state.attributes = db_state_attributes.to_native()
|
|
||||||
native_states.append(state)
|
|
||||||
return native_states
|
|
||||||
|
|
||||||
states: list[State] = await hass.async_add_executor_job(_fetch_states)
|
|
||||||
assert len(states) == 1
|
|
||||||
assert ATTR_EDITABLE not in states[0].attributes
|
|
||||||
assert ATTR_OPTIONS in states[0].attributes
|
|
||||||
|
@ -12,10 +12,9 @@ from homeassistant.components.input_text import (
|
|||||||
MODE_TEXT,
|
MODE_TEXT,
|
||||||
)
|
)
|
||||||
from homeassistant.components.recorder import Recorder
|
from homeassistant.components.recorder import Recorder
|
||||||
from homeassistant.components.recorder.db_schema import StateAttributes, States
|
from homeassistant.components.recorder.history import get_significant_states
|
||||||
from homeassistant.components.recorder.util import session_scope
|
|
||||||
from homeassistant.const import ATTR_EDITABLE
|
from homeassistant.const import ATTR_EDITABLE
|
||||||
from homeassistant.core import HomeAssistant, State
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
@ -27,6 +26,7 @@ async def test_exclude_attributes(
|
|||||||
recorder_mock: Recorder, hass: HomeAssistant, enable_custom_integrations: None
|
recorder_mock: Recorder, hass: HomeAssistant, enable_custom_integrations: None
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test attributes to be excluded."""
|
"""Test attributes to be excluded."""
|
||||||
|
now = dt_util.utcnow()
|
||||||
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {"test": {}}})
|
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {"test": {}}})
|
||||||
|
|
||||||
state = hass.states.get("input_text.test")
|
state = hass.states.get("input_text.test")
|
||||||
@ -42,23 +42,12 @@ async def test_exclude_attributes(
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
await async_wait_recording_done(hass)
|
await async_wait_recording_done(hass)
|
||||||
|
|
||||||
def _fetch_states() -> list[State]:
|
states = await hass.async_add_executor_job(get_significant_states, hass, now)
|
||||||
with session_scope(hass=hass) as session:
|
assert len(states) >= 1
|
||||||
native_states = []
|
for entity_states in states.values():
|
||||||
for db_state, db_state_attributes in session.query(
|
for state in entity_states:
|
||||||
States, StateAttributes
|
assert ATTR_EDITABLE not in state.attributes
|
||||||
).outerjoin(
|
assert ATTR_MAX not in state.attributes
|
||||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
assert ATTR_MIN not in state.attributes
|
||||||
):
|
assert ATTR_MODE not in state.attributes
|
||||||
state = db_state.to_native()
|
assert ATTR_PATTERN not in state.attributes
|
||||||
state.attributes = db_state_attributes.to_native()
|
|
||||||
native_states.append(state)
|
|
||||||
return native_states
|
|
||||||
|
|
||||||
states: list[State] = await hass.async_add_executor_job(_fetch_states)
|
|
||||||
assert len(states) == 1
|
|
||||||
assert ATTR_EDITABLE not in states[0].attributes
|
|
||||||
assert ATTR_MAX not in states[0].attributes
|
|
||||||
assert ATTR_MIN not in states[0].attributes
|
|
||||||
assert ATTR_MODE not in states[0].attributes
|
|
||||||
assert ATTR_PATTERN not in states[0].attributes
|
|
||||||
|
@ -13,10 +13,9 @@ from homeassistant.components.light import (
|
|||||||
ATTR_SUPPORTED_COLOR_MODES,
|
ATTR_SUPPORTED_COLOR_MODES,
|
||||||
)
|
)
|
||||||
from homeassistant.components.recorder import Recorder
|
from homeassistant.components.recorder import Recorder
|
||||||
from homeassistant.components.recorder.db_schema import StateAttributes, States
|
from homeassistant.components.recorder.history import get_significant_states
|
||||||
from homeassistant.components.recorder.util import session_scope
|
|
||||||
from homeassistant.const import ATTR_FRIENDLY_NAME
|
from homeassistant.const import ATTR_FRIENDLY_NAME
|
||||||
from homeassistant.core import HomeAssistant, State
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
@ -26,6 +25,7 @@ from tests.components.recorder.common import async_wait_recording_done
|
|||||||
|
|
||||||
async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
||||||
"""Test light registered attributes to be excluded."""
|
"""Test light registered attributes to be excluded."""
|
||||||
|
now = dt_util.utcnow()
|
||||||
await async_setup_component(
|
await async_setup_component(
|
||||||
hass, light.DOMAIN, {light.DOMAIN: {"platform": "demo"}}
|
hass, light.DOMAIN, {light.DOMAIN: {"platform": "demo"}}
|
||||||
)
|
)
|
||||||
@ -34,26 +34,14 @@ async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant)
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
await async_wait_recording_done(hass)
|
await async_wait_recording_done(hass)
|
||||||
|
|
||||||
def _fetch_states() -> list[State]:
|
states = await hass.async_add_executor_job(get_significant_states, hass, now)
|
||||||
with session_scope(hass=hass) as session:
|
assert len(states) >= 1
|
||||||
native_states = []
|
for entity_states in states.values():
|
||||||
for db_state, db_state_attributes in session.query(
|
for state in entity_states:
|
||||||
States, StateAttributes
|
assert ATTR_MIN_MIREDS not in state.attributes
|
||||||
).outerjoin(
|
assert ATTR_MAX_MIREDS not in state.attributes
|
||||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
assert ATTR_SUPPORTED_COLOR_MODES not in state.attributes
|
||||||
):
|
assert ATTR_EFFECT not in state.attributes
|
||||||
state = db_state.to_native()
|
assert ATTR_FRIENDLY_NAME in state.attributes
|
||||||
state.attributes = db_state_attributes.to_native()
|
assert ATTR_MAX_COLOR_TEMP_KELVIN not in state.attributes
|
||||||
native_states.append(state)
|
assert ATTR_MIN_COLOR_TEMP_KELVIN not in state.attributes
|
||||||
return native_states
|
|
||||||
|
|
||||||
states: list[State] = await hass.async_add_executor_job(_fetch_states)
|
|
||||||
assert len(states) > 1
|
|
||||||
for state in states:
|
|
||||||
assert ATTR_MIN_MIREDS not in state.attributes
|
|
||||||
assert ATTR_MAX_MIREDS not in state.attributes
|
|
||||||
assert ATTR_SUPPORTED_COLOR_MODES not in state.attributes
|
|
||||||
assert ATTR_EFFECT not in state.attributes
|
|
||||||
assert ATTR_FRIENDLY_NAME in state.attributes
|
|
||||||
assert ATTR_MAX_COLOR_TEMP_KELVIN not in state.attributes
|
|
||||||
assert ATTR_MIN_COLOR_TEMP_KELVIN not in state.attributes
|
|
||||||
|
@ -12,10 +12,9 @@ from homeassistant.components.media_player import (
|
|||||||
ATTR_SOUND_MODE_LIST,
|
ATTR_SOUND_MODE_LIST,
|
||||||
)
|
)
|
||||||
from homeassistant.components.recorder import Recorder
|
from homeassistant.components.recorder import Recorder
|
||||||
from homeassistant.components.recorder.db_schema import StateAttributes, States
|
from homeassistant.components.recorder.history import get_significant_states
|
||||||
from homeassistant.components.recorder.util import session_scope
|
|
||||||
from homeassistant.const import ATTR_ENTITY_PICTURE, ATTR_FRIENDLY_NAME
|
from homeassistant.const import ATTR_ENTITY_PICTURE, ATTR_FRIENDLY_NAME
|
||||||
from homeassistant.core import HomeAssistant, State
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
@ -25,6 +24,7 @@ from tests.components.recorder.common import async_wait_recording_done
|
|||||||
|
|
||||||
async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
||||||
"""Test media_player registered attributes to be excluded."""
|
"""Test media_player registered attributes to be excluded."""
|
||||||
|
now = dt_util.utcnow()
|
||||||
await async_setup_component(
|
await async_setup_component(
|
||||||
hass, media_player.DOMAIN, {media_player.DOMAIN: {"platform": "demo"}}
|
hass, media_player.DOMAIN, {media_player.DOMAIN: {"platform": "demo"}}
|
||||||
)
|
)
|
||||||
@ -33,26 +33,14 @@ async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant)
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
await async_wait_recording_done(hass)
|
await async_wait_recording_done(hass)
|
||||||
|
|
||||||
def _fetch_states() -> list[State]:
|
states = await hass.async_add_executor_job(get_significant_states, hass, now)
|
||||||
with session_scope(hass=hass) as session:
|
assert len(states) >= 1
|
||||||
native_states = []
|
for entity_states in states.values():
|
||||||
for db_state, db_state_attributes in session.query(
|
for state in entity_states:
|
||||||
States, StateAttributes
|
assert ATTR_ENTITY_PICTURE not in state.attributes
|
||||||
).outerjoin(
|
assert ATTR_ENTITY_PICTURE_LOCAL not in state.attributes
|
||||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
assert ATTR_FRIENDLY_NAME in state.attributes
|
||||||
):
|
assert ATTR_INPUT_SOURCE_LIST not in state.attributes
|
||||||
state = db_state.to_native()
|
assert ATTR_MEDIA_POSITION not in state.attributes
|
||||||
state.attributes = db_state_attributes.to_native()
|
assert ATTR_MEDIA_POSITION_UPDATED_AT not in state.attributes
|
||||||
native_states.append(state)
|
assert ATTR_SOUND_MODE_LIST not in state.attributes
|
||||||
return native_states
|
|
||||||
|
|
||||||
states: list[State] = await hass.async_add_executor_job(_fetch_states)
|
|
||||||
assert len(states) > 1
|
|
||||||
for state in states:
|
|
||||||
assert ATTR_ENTITY_PICTURE not in state.attributes
|
|
||||||
assert ATTR_ENTITY_PICTURE_LOCAL not in state.attributes
|
|
||||||
assert ATTR_FRIENDLY_NAME in state.attributes
|
|
||||||
assert ATTR_INPUT_SOURCE_LIST not in state.attributes
|
|
||||||
assert ATTR_MEDIA_POSITION not in state.attributes
|
|
||||||
assert ATTR_MEDIA_POSITION_UPDATED_AT not in state.attributes
|
|
||||||
assert ATTR_SOUND_MODE_LIST not in state.attributes
|
|
||||||
|
@ -6,10 +6,9 @@ from datetime import timedelta
|
|||||||
from homeassistant.components import number
|
from homeassistant.components import number
|
||||||
from homeassistant.components.number import ATTR_MAX, ATTR_MIN, ATTR_MODE, ATTR_STEP
|
from homeassistant.components.number import ATTR_MAX, ATTR_MIN, ATTR_MODE, ATTR_STEP
|
||||||
from homeassistant.components.recorder import Recorder
|
from homeassistant.components.recorder import Recorder
|
||||||
from homeassistant.components.recorder.db_schema import StateAttributes, States
|
from homeassistant.components.recorder.history import get_significant_states
|
||||||
from homeassistant.components.recorder.util import session_scope
|
|
||||||
from homeassistant.const import ATTR_FRIENDLY_NAME
|
from homeassistant.const import ATTR_FRIENDLY_NAME
|
||||||
from homeassistant.core import HomeAssistant, State
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
@ -23,28 +22,17 @@ async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant)
|
|||||||
hass, number.DOMAIN, {number.DOMAIN: {"platform": "demo"}}
|
hass, number.DOMAIN, {number.DOMAIN: {"platform": "demo"}}
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
async_fire_time_changed(hass, dt_util.utcnow() + timedelta(minutes=5))
|
now = dt_util.utcnow()
|
||||||
|
async_fire_time_changed(hass, now + timedelta(minutes=5))
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
await async_wait_recording_done(hass)
|
await async_wait_recording_done(hass)
|
||||||
|
|
||||||
def _fetch_states() -> list[State]:
|
states = await hass.async_add_executor_job(get_significant_states, hass, now)
|
||||||
with session_scope(hass=hass) as session:
|
|
||||||
native_states = []
|
|
||||||
for db_state, db_state_attributes in session.query(
|
|
||||||
States, StateAttributes
|
|
||||||
).outerjoin(
|
|
||||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
|
||||||
):
|
|
||||||
state = db_state.to_native()
|
|
||||||
state.attributes = db_state_attributes.to_native()
|
|
||||||
native_states.append(state)
|
|
||||||
return native_states
|
|
||||||
|
|
||||||
states: list[State] = await hass.async_add_executor_job(_fetch_states)
|
|
||||||
assert len(states) > 1
|
assert len(states) > 1
|
||||||
for state in states:
|
for entity_states in states.values():
|
||||||
assert ATTR_MIN not in state.attributes
|
for state in entity_states:
|
||||||
assert ATTR_MAX not in state.attributes
|
assert ATTR_MIN not in state.attributes
|
||||||
assert ATTR_STEP not in state.attributes
|
assert ATTR_MAX not in state.attributes
|
||||||
assert ATTR_MODE not in state.attributes
|
assert ATTR_STEP not in state.attributes
|
||||||
assert ATTR_FRIENDLY_NAME in state.attributes
|
assert ATTR_MODE not in state.attributes
|
||||||
|
assert ATTR_FRIENDLY_NAME in state.attributes
|
||||||
|
@ -4,11 +4,10 @@ from __future__ import annotations
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
from homeassistant.components.recorder import Recorder
|
from homeassistant.components.recorder import Recorder
|
||||||
from homeassistant.components.recorder.db_schema import StateAttributes, States
|
from homeassistant.components.recorder.history import get_significant_states
|
||||||
from homeassistant.components.recorder.util import session_scope
|
|
||||||
from homeassistant.components.schedule.const import ATTR_NEXT_EVENT, DOMAIN
|
from homeassistant.components.schedule.const import ATTR_NEXT_EVENT, DOMAIN
|
||||||
from homeassistant.const import ATTR_EDITABLE, ATTR_FRIENDLY_NAME, ATTR_ICON
|
from homeassistant.const import ATTR_EDITABLE, ATTR_FRIENDLY_NAME, ATTR_ICON
|
||||||
from homeassistant.core import HomeAssistant, State
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
@ -22,6 +21,7 @@ async def test_exclude_attributes(
|
|||||||
enable_custom_integrations: None,
|
enable_custom_integrations: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test attributes to be excluded."""
|
"""Test attributes to be excluded."""
|
||||||
|
now = dt_util.utcnow()
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
hass,
|
hass,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
@ -54,22 +54,11 @@ async def test_exclude_attributes(
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
await async_wait_recording_done(hass)
|
await async_wait_recording_done(hass)
|
||||||
|
|
||||||
def _fetch_states() -> list[State]:
|
states = await hass.async_add_executor_job(get_significant_states, hass, now)
|
||||||
with session_scope(hass=hass) as session:
|
assert len(states) >= 1
|
||||||
native_states = []
|
for entity_states in states.values():
|
||||||
for db_state, db_state_attributes in session.query(
|
for state in entity_states:
|
||||||
States, StateAttributes
|
assert ATTR_EDITABLE not in state.attributes
|
||||||
).outerjoin(
|
assert ATTR_FRIENDLY_NAME in state.attributes
|
||||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
assert ATTR_ICON in state.attributes
|
||||||
):
|
assert ATTR_NEXT_EVENT not in state.attributes
|
||||||
state = db_state.to_native()
|
|
||||||
state.attributes = db_state_attributes.to_native()
|
|
||||||
native_states.append(state)
|
|
||||||
return native_states
|
|
||||||
|
|
||||||
states: list[State] = await hass.async_add_executor_job(_fetch_states)
|
|
||||||
assert len(states) == 1
|
|
||||||
assert ATTR_EDITABLE not in states[0].attributes
|
|
||||||
assert ATTR_FRIENDLY_NAME in states[0].attributes
|
|
||||||
assert ATTR_ICON in states[0].attributes
|
|
||||||
assert ATTR_NEXT_EVENT not in states[0].attributes
|
|
||||||
|
@ -5,8 +5,7 @@ import pytest
|
|||||||
|
|
||||||
from homeassistant.components import script
|
from homeassistant.components import script
|
||||||
from homeassistant.components.recorder import Recorder
|
from homeassistant.components.recorder import Recorder
|
||||||
from homeassistant.components.recorder.db_schema import StateAttributes, States
|
from homeassistant.components.recorder.history import get_significant_states
|
||||||
from homeassistant.components.recorder.util import session_scope
|
|
||||||
from homeassistant.components.script import (
|
from homeassistant.components.script import (
|
||||||
ATTR_CUR,
|
ATTR_CUR,
|
||||||
ATTR_LAST_ACTION,
|
ATTR_LAST_ACTION,
|
||||||
@ -15,8 +14,9 @@ from homeassistant.components.script import (
|
|||||||
ATTR_MODE,
|
ATTR_MODE,
|
||||||
)
|
)
|
||||||
from homeassistant.const import ATTR_FRIENDLY_NAME
|
from homeassistant.const import ATTR_FRIENDLY_NAME
|
||||||
from homeassistant.core import Context, HomeAssistant, State, callback
|
from homeassistant.core import Context, HomeAssistant, callback
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
from tests.common import async_mock_service
|
from tests.common import async_mock_service
|
||||||
from tests.components.recorder.common import async_wait_recording_done
|
from tests.components.recorder.common import async_wait_recording_done
|
||||||
@ -32,6 +32,7 @@ async def test_exclude_attributes(
|
|||||||
recorder_mock: Recorder, hass: HomeAssistant, calls
|
recorder_mock: Recorder, hass: HomeAssistant, calls
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test automation registered attributes to be excluded."""
|
"""Test automation registered attributes to be excluded."""
|
||||||
|
now = dt_util.utcnow()
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
calls = []
|
calls = []
|
||||||
context = Context()
|
context = Context()
|
||||||
@ -65,25 +66,13 @@ async def test_exclude_attributes(
|
|||||||
await async_wait_recording_done(hass)
|
await async_wait_recording_done(hass)
|
||||||
assert len(calls) == 1
|
assert len(calls) == 1
|
||||||
|
|
||||||
def _fetch_states() -> list[State]:
|
states = await hass.async_add_executor_job(get_significant_states, hass, now)
|
||||||
with session_scope(hass=hass) as session:
|
assert len(states) >= 1
|
||||||
native_states = []
|
for entity_states in states.values():
|
||||||
for db_state, db_state_attributes in session.query(
|
for state in entity_states:
|
||||||
States, StateAttributes
|
assert ATTR_LAST_TRIGGERED not in state.attributes
|
||||||
).outerjoin(
|
assert ATTR_MODE not in state.attributes
|
||||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
assert ATTR_CUR not in state.attributes
|
||||||
):
|
assert ATTR_LAST_ACTION not in state.attributes
|
||||||
state = db_state.to_native()
|
assert ATTR_MAX not in state.attributes
|
||||||
state.attributes = db_state_attributes.to_native()
|
assert ATTR_FRIENDLY_NAME in state.attributes
|
||||||
native_states.append(state)
|
|
||||||
return native_states
|
|
||||||
|
|
||||||
states: list[State] = await hass.async_add_executor_job(_fetch_states)
|
|
||||||
assert len(states) > 1
|
|
||||||
for state in states:
|
|
||||||
assert ATTR_LAST_TRIGGERED not in state.attributes
|
|
||||||
assert ATTR_MODE not in state.attributes
|
|
||||||
assert ATTR_CUR not in state.attributes
|
|
||||||
assert ATTR_LAST_ACTION not in state.attributes
|
|
||||||
assert ATTR_MAX not in state.attributes
|
|
||||||
assert ATTR_FRIENDLY_NAME in state.attributes
|
|
||||||
|
@ -5,11 +5,10 @@ from datetime import timedelta
|
|||||||
|
|
||||||
from homeassistant.components import select
|
from homeassistant.components import select
|
||||||
from homeassistant.components.recorder import Recorder
|
from homeassistant.components.recorder import Recorder
|
||||||
from homeassistant.components.recorder.db_schema import StateAttributes, States
|
from homeassistant.components.recorder.history import get_significant_states
|
||||||
from homeassistant.components.recorder.util import session_scope
|
|
||||||
from homeassistant.components.select import ATTR_OPTIONS
|
from homeassistant.components.select import ATTR_OPTIONS
|
||||||
from homeassistant.const import ATTR_FRIENDLY_NAME
|
from homeassistant.const import ATTR_FRIENDLY_NAME
|
||||||
from homeassistant.core import HomeAssistant, State
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
@ -19,6 +18,7 @@ from tests.components.recorder.common import async_wait_recording_done
|
|||||||
|
|
||||||
async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
||||||
"""Test select registered attributes to be excluded."""
|
"""Test select registered attributes to be excluded."""
|
||||||
|
now = dt_util.utcnow()
|
||||||
await async_setup_component(
|
await async_setup_component(
|
||||||
hass, select.DOMAIN, {select.DOMAIN: {"platform": "demo"}}
|
hass, select.DOMAIN, {select.DOMAIN: {"platform": "demo"}}
|
||||||
)
|
)
|
||||||
@ -27,21 +27,9 @@ async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant)
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
await async_wait_recording_done(hass)
|
await async_wait_recording_done(hass)
|
||||||
|
|
||||||
def _fetch_states() -> list[State]:
|
states = await hass.async_add_executor_job(get_significant_states, hass, now)
|
||||||
with session_scope(hass=hass) as session:
|
assert len(states) >= 1
|
||||||
native_states = []
|
for entity_states in states.values():
|
||||||
for db_state, db_state_attributes in session.query(
|
for state in entity_states:
|
||||||
States, StateAttributes
|
assert ATTR_OPTIONS not in state.attributes
|
||||||
).outerjoin(
|
assert ATTR_FRIENDLY_NAME in state.attributes
|
||||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
|
||||||
):
|
|
||||||
state = db_state.to_native()
|
|
||||||
state.attributes = db_state_attributes.to_native()
|
|
||||||
native_states.append(state)
|
|
||||||
return native_states
|
|
||||||
|
|
||||||
states: list[State] = await hass.async_add_executor_job(_fetch_states)
|
|
||||||
assert len(states) > 1
|
|
||||||
for state in states:
|
|
||||||
assert ATTR_OPTIONS not in state.attributes
|
|
||||||
assert ATTR_FRIENDLY_NAME in state.attributes
|
|
||||||
|
@ -5,11 +5,10 @@ from datetime import timedelta
|
|||||||
|
|
||||||
from homeassistant.components import siren
|
from homeassistant.components import siren
|
||||||
from homeassistant.components.recorder import Recorder
|
from homeassistant.components.recorder import Recorder
|
||||||
from homeassistant.components.recorder.db_schema import StateAttributes, States
|
from homeassistant.components.recorder.history import get_significant_states
|
||||||
from homeassistant.components.recorder.util import session_scope
|
|
||||||
from homeassistant.components.siren import ATTR_AVAILABLE_TONES
|
from homeassistant.components.siren import ATTR_AVAILABLE_TONES
|
||||||
from homeassistant.const import ATTR_FRIENDLY_NAME
|
from homeassistant.const import ATTR_FRIENDLY_NAME
|
||||||
from homeassistant.core import HomeAssistant, State
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
@ -19,6 +18,7 @@ from tests.components.recorder.common import async_wait_recording_done
|
|||||||
|
|
||||||
async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
||||||
"""Test siren registered attributes to be excluded."""
|
"""Test siren registered attributes to be excluded."""
|
||||||
|
now = dt_util.utcnow()
|
||||||
await async_setup_component(
|
await async_setup_component(
|
||||||
hass, siren.DOMAIN, {siren.DOMAIN: {"platform": "demo"}}
|
hass, siren.DOMAIN, {siren.DOMAIN: {"platform": "demo"}}
|
||||||
)
|
)
|
||||||
@ -27,21 +27,9 @@ async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant)
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
await async_wait_recording_done(hass)
|
await async_wait_recording_done(hass)
|
||||||
|
|
||||||
def _fetch_states() -> list[State]:
|
states = await hass.async_add_executor_job(get_significant_states, hass, now)
|
||||||
with session_scope(hass=hass) as session:
|
assert len(states) >= 1
|
||||||
native_states = []
|
for entity_states in states.values():
|
||||||
for db_state, db_state_attributes in session.query(
|
for state in entity_states:
|
||||||
States, StateAttributes
|
assert ATTR_AVAILABLE_TONES not in state.attributes
|
||||||
).outerjoin(
|
assert ATTR_FRIENDLY_NAME in state.attributes
|
||||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
|
||||||
):
|
|
||||||
state = db_state.to_native()
|
|
||||||
state.attributes = db_state_attributes.to_native()
|
|
||||||
native_states.append(state)
|
|
||||||
return native_states
|
|
||||||
|
|
||||||
states: list[State] = await hass.async_add_executor_job(_fetch_states)
|
|
||||||
assert len(states) > 1
|
|
||||||
for state in states:
|
|
||||||
assert ATTR_AVAILABLE_TONES not in state.attributes
|
|
||||||
assert ATTR_FRIENDLY_NAME in state.attributes
|
|
||||||
|
@ -4,8 +4,7 @@ from __future__ import annotations
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
from homeassistant.components.recorder import Recorder
|
from homeassistant.components.recorder import Recorder
|
||||||
from homeassistant.components.recorder.db_schema import StateAttributes, States
|
from homeassistant.components.recorder.history import get_significant_states
|
||||||
from homeassistant.components.recorder.util import session_scope
|
|
||||||
from homeassistant.components.sun import (
|
from homeassistant.components.sun import (
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
STATE_ATTR_AZIMUTH,
|
STATE_ATTR_AZIMUTH,
|
||||||
@ -19,7 +18,7 @@ from homeassistant.components.sun import (
|
|||||||
STATE_ATTR_RISING,
|
STATE_ATTR_RISING,
|
||||||
)
|
)
|
||||||
from homeassistant.const import ATTR_FRIENDLY_NAME
|
from homeassistant.const import ATTR_FRIENDLY_NAME
|
||||||
from homeassistant.core import HomeAssistant, State
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
@ -29,35 +28,24 @@ from tests.components.recorder.common import async_wait_recording_done
|
|||||||
|
|
||||||
async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
||||||
"""Test sun attributes to be excluded."""
|
"""Test sun attributes to be excluded."""
|
||||||
|
now = dt_util.utcnow()
|
||||||
await async_setup_component(hass, DOMAIN, {})
|
await async_setup_component(hass, DOMAIN, {})
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
async_fire_time_changed(hass, dt_util.utcnow() + timedelta(minutes=5))
|
async_fire_time_changed(hass, dt_util.utcnow() + timedelta(minutes=5))
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
await async_wait_recording_done(hass)
|
await async_wait_recording_done(hass)
|
||||||
|
|
||||||
def _fetch_sun_states() -> list[State]:
|
states = await hass.async_add_executor_job(get_significant_states, hass, now)
|
||||||
with session_scope(hass=hass) as session:
|
assert len(states) >= 1
|
||||||
native_states = []
|
for entity_states in states.values():
|
||||||
for db_state, db_state_attributes in session.query(
|
for state in entity_states:
|
||||||
States, StateAttributes
|
assert STATE_ATTR_AZIMUTH not in state.attributes
|
||||||
).outerjoin(
|
assert STATE_ATTR_ELEVATION not in state.attributes
|
||||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
assert STATE_ATTR_NEXT_DAWN not in state.attributes
|
||||||
):
|
assert STATE_ATTR_NEXT_DUSK not in state.attributes
|
||||||
state = db_state.to_native()
|
assert STATE_ATTR_NEXT_MIDNIGHT not in state.attributes
|
||||||
state.attributes = db_state_attributes.to_native()
|
assert STATE_ATTR_NEXT_NOON not in state.attributes
|
||||||
native_states.append(state)
|
assert STATE_ATTR_NEXT_RISING not in state.attributes
|
||||||
return native_states
|
assert STATE_ATTR_NEXT_SETTING not in state.attributes
|
||||||
|
assert STATE_ATTR_RISING not in state.attributes
|
||||||
states: list[State] = await hass.async_add_executor_job(_fetch_sun_states)
|
assert ATTR_FRIENDLY_NAME in state.attributes
|
||||||
assert len(states) > 1
|
|
||||||
for state in states:
|
|
||||||
assert STATE_ATTR_AZIMUTH not in state.attributes
|
|
||||||
assert STATE_ATTR_ELEVATION not in state.attributes
|
|
||||||
assert STATE_ATTR_NEXT_DAWN not in state.attributes
|
|
||||||
assert STATE_ATTR_NEXT_DUSK not in state.attributes
|
|
||||||
assert STATE_ATTR_NEXT_MIDNIGHT not in state.attributes
|
|
||||||
assert STATE_ATTR_NEXT_NOON not in state.attributes
|
|
||||||
assert STATE_ATTR_NEXT_RISING not in state.attributes
|
|
||||||
assert STATE_ATTR_NEXT_SETTING not in state.attributes
|
|
||||||
assert STATE_ATTR_RISING not in state.attributes
|
|
||||||
assert ATTR_FRIENDLY_NAME in state.attributes
|
|
||||||
|
@ -5,11 +5,10 @@ from datetime import timedelta
|
|||||||
|
|
||||||
from homeassistant.components import text
|
from homeassistant.components import text
|
||||||
from homeassistant.components.recorder import Recorder
|
from homeassistant.components.recorder import Recorder
|
||||||
from homeassistant.components.recorder.db_schema import StateAttributes, States
|
from homeassistant.components.recorder.history import get_significant_states
|
||||||
from homeassistant.components.recorder.util import session_scope
|
|
||||||
from homeassistant.components.text import ATTR_MAX, ATTR_MIN, ATTR_MODE, ATTR_PATTERN
|
from homeassistant.components.text import ATTR_MAX, ATTR_MIN, ATTR_MODE, ATTR_PATTERN
|
||||||
from homeassistant.const import ATTR_FRIENDLY_NAME
|
from homeassistant.const import ATTR_FRIENDLY_NAME
|
||||||
from homeassistant.core import HomeAssistant, State
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
@ -19,28 +18,17 @@ from tests.components.recorder.common import async_wait_recording_done
|
|||||||
|
|
||||||
async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
||||||
"""Test siren registered attributes to be excluded."""
|
"""Test siren registered attributes to be excluded."""
|
||||||
|
now = dt_util.utcnow()
|
||||||
await async_setup_component(hass, text.DOMAIN, {text.DOMAIN: {"platform": "demo"}})
|
await async_setup_component(hass, text.DOMAIN, {text.DOMAIN: {"platform": "demo"}})
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
async_fire_time_changed(hass, dt_util.utcnow() + timedelta(minutes=5))
|
async_fire_time_changed(hass, dt_util.utcnow() + timedelta(minutes=5))
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
await async_wait_recording_done(hass)
|
await async_wait_recording_done(hass)
|
||||||
|
|
||||||
def _fetch_states() -> list[State]:
|
states = await hass.async_add_executor_job(get_significant_states, hass, now)
|
||||||
with session_scope(hass=hass) as session:
|
assert len(states) >= 1
|
||||||
native_states = []
|
for entity_states in states.values():
|
||||||
for db_state, db_state_attributes in session.query(
|
for state in entity_states:
|
||||||
States, StateAttributes
|
for attr in (ATTR_MAX, ATTR_MIN, ATTR_MODE, ATTR_PATTERN):
|
||||||
).outerjoin(
|
assert attr not in state.attributes
|
||||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
assert ATTR_FRIENDLY_NAME in state.attributes
|
||||||
):
|
|
||||||
state = db_state.to_native()
|
|
||||||
state.attributes = db_state_attributes.to_native()
|
|
||||||
native_states.append(state)
|
|
||||||
return native_states
|
|
||||||
|
|
||||||
states: list[State] = await hass.async_add_executor_job(_fetch_states)
|
|
||||||
assert len(states) > 1
|
|
||||||
for state in states:
|
|
||||||
for attr in (ATTR_MAX, ATTR_MIN, ATTR_MODE, ATTR_PATTERN):
|
|
||||||
assert attr not in state.attributes
|
|
||||||
assert ATTR_FRIENDLY_NAME in state.attributes
|
|
||||||
|
@ -7,8 +7,7 @@ from unittest.mock import Mock
|
|||||||
from pyunifiprotect.data import Camera, Event, EventType
|
from pyunifiprotect.data import Camera, Event, EventType
|
||||||
|
|
||||||
from homeassistant.components.recorder import Recorder
|
from homeassistant.components.recorder import Recorder
|
||||||
from homeassistant.components.recorder.db_schema import StateAttributes, States
|
from homeassistant.components.recorder.history import get_significant_states
|
||||||
from homeassistant.components.recorder.util import session_scope
|
|
||||||
from homeassistant.components.unifiprotect.binary_sensor import EVENT_SENSORS
|
from homeassistant.components.unifiprotect.binary_sensor import EVENT_SENSORS
|
||||||
from homeassistant.components.unifiprotect.const import (
|
from homeassistant.components.unifiprotect.const import (
|
||||||
ATTR_EVENT_ID,
|
ATTR_EVENT_ID,
|
||||||
@ -16,7 +15,7 @@ from homeassistant.components.unifiprotect.const import (
|
|||||||
DEFAULT_ATTRIBUTION,
|
DEFAULT_ATTRIBUTION,
|
||||||
)
|
)
|
||||||
from homeassistant.const import ATTR_ATTRIBUTION, ATTR_FRIENDLY_NAME, STATE_ON, Platform
|
from homeassistant.const import ATTR_ATTRIBUTION, ATTR_FRIENDLY_NAME, STATE_ON, Platform
|
||||||
from homeassistant.core import HomeAssistant, State
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from .utils import MockUFPFixture, ids_from_device_description, init_entry
|
from .utils import MockUFPFixture, ids_from_device_description, init_entry
|
||||||
|
|
||||||
@ -32,7 +31,7 @@ async def test_exclude_attributes(
|
|||||||
fixed_now: datetime,
|
fixed_now: datetime,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test binary_sensor has event_id and event_score excluded from recording."""
|
"""Test binary_sensor has event_id and event_score excluded from recording."""
|
||||||
|
now = fixed_now
|
||||||
await init_entry(hass, ufp, [doorbell, unadopted_camera])
|
await init_entry(hass, ufp, [doorbell, unadopted_camera])
|
||||||
|
|
||||||
_, entity_id = ids_from_device_description(
|
_, entity_id = ids_from_device_description(
|
||||||
@ -70,22 +69,10 @@ async def test_exclude_attributes(
|
|||||||
assert state.attributes[ATTR_EVENT_SCORE] == 100
|
assert state.attributes[ATTR_EVENT_SCORE] == 100
|
||||||
await async_wait_recording_done(hass)
|
await async_wait_recording_done(hass)
|
||||||
|
|
||||||
def _fetch_states() -> list[State]:
|
states = await hass.async_add_executor_job(get_significant_states, hass, now)
|
||||||
with session_scope(hass=hass) as session:
|
assert len(states) >= 1
|
||||||
native_states = []
|
for entity_states in states.values():
|
||||||
for db_state, db_state_attributes in session.query(
|
for state in entity_states:
|
||||||
States, StateAttributes
|
assert ATTR_EVENT_SCORE not in state.attributes
|
||||||
).outerjoin(
|
assert ATTR_EVENT_ID not in state.attributes
|
||||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
assert ATTR_FRIENDLY_NAME in state.attributes
|
||||||
):
|
|
||||||
state = db_state.to_native()
|
|
||||||
state.attributes = db_state_attributes.to_native()
|
|
||||||
native_states.append(state)
|
|
||||||
return native_states
|
|
||||||
|
|
||||||
states: list[State] = await hass.async_add_executor_job(_fetch_states)
|
|
||||||
assert len(states) > 1
|
|
||||||
for state in states:
|
|
||||||
assert ATTR_EVENT_SCORE not in state.attributes
|
|
||||||
assert ATTR_EVENT_ID not in state.attributes
|
|
||||||
assert ATTR_FRIENDLY_NAME in state.attributes
|
|
||||||
|
@ -4,8 +4,7 @@ from __future__ import annotations
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
from homeassistant.components.recorder import Recorder
|
from homeassistant.components.recorder import Recorder
|
||||||
from homeassistant.components.recorder.db_schema import StateAttributes, States
|
from homeassistant.components.recorder.history import get_significant_states
|
||||||
from homeassistant.components.recorder.util import session_scope
|
|
||||||
from homeassistant.components.update.const import (
|
from homeassistant.components.update.const import (
|
||||||
ATTR_IN_PROGRESS,
|
ATTR_IN_PROGRESS,
|
||||||
ATTR_INSTALLED_VERSION,
|
ATTR_INSTALLED_VERSION,
|
||||||
@ -13,7 +12,7 @@ from homeassistant.components.update.const import (
|
|||||||
DOMAIN,
|
DOMAIN,
|
||||||
)
|
)
|
||||||
from homeassistant.const import ATTR_ENTITY_PICTURE, CONF_PLATFORM
|
from homeassistant.const import ATTR_ENTITY_PICTURE, CONF_PLATFORM
|
||||||
from homeassistant.core import HomeAssistant, State
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
@ -25,6 +24,7 @@ async def test_exclude_attributes(
|
|||||||
recorder_mock: Recorder, hass: HomeAssistant, enable_custom_integrations: None
|
recorder_mock: Recorder, hass: HomeAssistant, enable_custom_integrations: None
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update attributes to be excluded."""
|
"""Test update attributes to be excluded."""
|
||||||
|
now = dt_util.utcnow()
|
||||||
platform = getattr(hass.components, f"test.{DOMAIN}")
|
platform = getattr(hass.components, f"test.{DOMAIN}")
|
||||||
platform.init()
|
platform.init()
|
||||||
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
|
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
|
||||||
@ -42,23 +42,11 @@ async def test_exclude_attributes(
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
await async_wait_recording_done(hass)
|
await async_wait_recording_done(hass)
|
||||||
|
|
||||||
def _fetch_states() -> list[State]:
|
states = await hass.async_add_executor_job(get_significant_states, hass, now)
|
||||||
with session_scope(hass=hass) as session:
|
assert len(states) >= 1
|
||||||
native_states = []
|
for entity_states in states.values():
|
||||||
for db_state, db_state_attributes in session.query(
|
for state in entity_states:
|
||||||
States, StateAttributes
|
assert ATTR_ENTITY_PICTURE not in state.attributes
|
||||||
).outerjoin(
|
assert ATTR_IN_PROGRESS not in state.attributes
|
||||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
assert ATTR_RELEASE_SUMMARY not in state.attributes
|
||||||
):
|
assert ATTR_INSTALLED_VERSION in state.attributes
|
||||||
state = db_state.to_native()
|
|
||||||
state.attributes = db_state_attributes.to_native()
|
|
||||||
native_states.append(state)
|
|
||||||
return native_states
|
|
||||||
|
|
||||||
states: list[State] = await hass.async_add_executor_job(_fetch_states)
|
|
||||||
assert len(states) > 1
|
|
||||||
for state in states:
|
|
||||||
assert ATTR_ENTITY_PICTURE not in state.attributes
|
|
||||||
assert ATTR_IN_PROGRESS not in state.attributes
|
|
||||||
assert ATTR_RELEASE_SUMMARY not in state.attributes
|
|
||||||
assert ATTR_INSTALLED_VERSION in state.attributes
|
|
||||||
|
@ -5,11 +5,10 @@ from datetime import timedelta
|
|||||||
|
|
||||||
from homeassistant.components import vacuum
|
from homeassistant.components import vacuum
|
||||||
from homeassistant.components.recorder import Recorder
|
from homeassistant.components.recorder import Recorder
|
||||||
from homeassistant.components.recorder.db_schema import StateAttributes, States
|
from homeassistant.components.recorder.history import get_significant_states
|
||||||
from homeassistant.components.recorder.util import session_scope
|
|
||||||
from homeassistant.components.vacuum import ATTR_FAN_SPEED_LIST
|
from homeassistant.components.vacuum import ATTR_FAN_SPEED_LIST
|
||||||
from homeassistant.const import ATTR_FRIENDLY_NAME
|
from homeassistant.const import ATTR_FRIENDLY_NAME
|
||||||
from homeassistant.core import HomeAssistant, State
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
@ -19,6 +18,7 @@ from tests.components.recorder.common import async_wait_recording_done
|
|||||||
|
|
||||||
async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
||||||
"""Test vacuum registered attributes to be excluded."""
|
"""Test vacuum registered attributes to be excluded."""
|
||||||
|
now = dt_util.utcnow()
|
||||||
await async_setup_component(
|
await async_setup_component(
|
||||||
hass, vacuum.DOMAIN, {vacuum.DOMAIN: {"platform": "demo"}}
|
hass, vacuum.DOMAIN, {vacuum.DOMAIN: {"platform": "demo"}}
|
||||||
)
|
)
|
||||||
@ -27,21 +27,9 @@ async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant)
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
await async_wait_recording_done(hass)
|
await async_wait_recording_done(hass)
|
||||||
|
|
||||||
def _fetch_states() -> list[State]:
|
states = await hass.async_add_executor_job(get_significant_states, hass, now)
|
||||||
with session_scope(hass=hass) as session:
|
assert len(states) >= 1
|
||||||
native_states = []
|
for entity_states in states.values():
|
||||||
for db_state, db_state_attributes in session.query(
|
for state in entity_states:
|
||||||
States, StateAttributes
|
assert ATTR_FAN_SPEED_LIST not in state.attributes
|
||||||
).outerjoin(
|
assert ATTR_FRIENDLY_NAME in state.attributes
|
||||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
|
||||||
):
|
|
||||||
state = db_state.to_native()
|
|
||||||
state.attributes = db_state_attributes.to_native()
|
|
||||||
native_states.append(state)
|
|
||||||
return native_states
|
|
||||||
|
|
||||||
states: list[State] = await hass.async_add_executor_job(_fetch_states)
|
|
||||||
assert len(states) > 1
|
|
||||||
for state in states:
|
|
||||||
assert ATTR_FAN_SPEED_LIST not in state.attributes
|
|
||||||
assert ATTR_FRIENDLY_NAME in state.attributes
|
|
||||||
|
@ -5,15 +5,14 @@ from datetime import timedelta
|
|||||||
|
|
||||||
from homeassistant.components import water_heater
|
from homeassistant.components import water_heater
|
||||||
from homeassistant.components.recorder import Recorder
|
from homeassistant.components.recorder import Recorder
|
||||||
from homeassistant.components.recorder.db_schema import StateAttributes, States
|
from homeassistant.components.recorder.history import get_significant_states
|
||||||
from homeassistant.components.recorder.util import session_scope
|
|
||||||
from homeassistant.components.water_heater import (
|
from homeassistant.components.water_heater import (
|
||||||
ATTR_MAX_TEMP,
|
ATTR_MAX_TEMP,
|
||||||
ATTR_MIN_TEMP,
|
ATTR_MIN_TEMP,
|
||||||
ATTR_OPERATION_LIST,
|
ATTR_OPERATION_LIST,
|
||||||
)
|
)
|
||||||
from homeassistant.const import ATTR_FRIENDLY_NAME
|
from homeassistant.const import ATTR_FRIENDLY_NAME
|
||||||
from homeassistant.core import HomeAssistant, State
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
@ -23,6 +22,7 @@ from tests.components.recorder.common import async_wait_recording_done
|
|||||||
|
|
||||||
async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
||||||
"""Test water_heater registered attributes to be excluded."""
|
"""Test water_heater registered attributes to be excluded."""
|
||||||
|
now = dt_util.utcnow()
|
||||||
await async_setup_component(
|
await async_setup_component(
|
||||||
hass, water_heater.DOMAIN, {water_heater.DOMAIN: {"platform": "demo"}}
|
hass, water_heater.DOMAIN, {water_heater.DOMAIN: {"platform": "demo"}}
|
||||||
)
|
)
|
||||||
@ -31,23 +31,11 @@ async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant)
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
await async_wait_recording_done(hass)
|
await async_wait_recording_done(hass)
|
||||||
|
|
||||||
def _fetch_states() -> list[State]:
|
states = await hass.async_add_executor_job(get_significant_states, hass, now)
|
||||||
with session_scope(hass=hass) as session:
|
assert len(states) >= 1
|
||||||
native_states = []
|
for entity_states in states.values():
|
||||||
for db_state, db_state_attributes in session.query(
|
for state in entity_states:
|
||||||
States, StateAttributes
|
assert ATTR_OPERATION_LIST not in state.attributes
|
||||||
).outerjoin(
|
assert ATTR_MIN_TEMP not in state.attributes
|
||||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
assert ATTR_MAX_TEMP not in state.attributes
|
||||||
):
|
assert ATTR_FRIENDLY_NAME in state.attributes
|
||||||
state = db_state.to_native()
|
|
||||||
state.attributes = db_state_attributes.to_native()
|
|
||||||
native_states.append(state)
|
|
||||||
return native_states
|
|
||||||
|
|
||||||
states: list[State] = await hass.async_add_executor_job(_fetch_states)
|
|
||||||
assert len(states) > 1
|
|
||||||
for state in states:
|
|
||||||
assert ATTR_OPERATION_LIST not in state.attributes
|
|
||||||
assert ATTR_MIN_TEMP not in state.attributes
|
|
||||||
assert ATTR_MAX_TEMP not in state.attributes
|
|
||||||
assert ATTR_FRIENDLY_NAME in state.attributes
|
|
||||||
|
@ -4,10 +4,9 @@ from __future__ import annotations
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
from homeassistant.components.recorder import Recorder
|
from homeassistant.components.recorder import Recorder
|
||||||
from homeassistant.components.recorder.db_schema import StateAttributes, States
|
from homeassistant.components.recorder.history import get_significant_states
|
||||||
from homeassistant.components.recorder.util import session_scope
|
|
||||||
from homeassistant.components.weather import ATTR_FORECAST, DOMAIN
|
from homeassistant.components.weather import ATTR_FORECAST, DOMAIN
|
||||||
from homeassistant.core import HomeAssistant, State
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
from homeassistant.util.unit_system import METRIC_SYSTEM
|
from homeassistant.util.unit_system import METRIC_SYSTEM
|
||||||
@ -18,6 +17,7 @@ from tests.components.recorder.common import async_wait_recording_done
|
|||||||
|
|
||||||
async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
||||||
"""Test weather attributes to be excluded."""
|
"""Test weather attributes to be excluded."""
|
||||||
|
now = dt_util.utcnow()
|
||||||
await async_setup_component(hass, DOMAIN, {DOMAIN: {"platform": "demo"}})
|
await async_setup_component(hass, DOMAIN, {DOMAIN: {"platform": "demo"}})
|
||||||
hass.config.units = METRIC_SYSTEM
|
hass.config.units = METRIC_SYSTEM
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
@ -30,20 +30,8 @@ async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant)
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
await async_wait_recording_done(hass)
|
await async_wait_recording_done(hass)
|
||||||
|
|
||||||
def _fetch_states() -> list[State]:
|
states = await hass.async_add_executor_job(get_significant_states, hass, now)
|
||||||
with session_scope(hass=hass) as session:
|
assert len(states) >= 1
|
||||||
native_states = []
|
for entity_states in states.values():
|
||||||
for db_state, db_state_attributes in session.query(
|
for state in entity_states:
|
||||||
States, StateAttributes
|
assert ATTR_FORECAST not in state.attributes
|
||||||
).outerjoin(
|
|
||||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
|
||||||
):
|
|
||||||
state = db_state.to_native()
|
|
||||||
state.attributes = db_state_attributes.to_native()
|
|
||||||
native_states.append(state)
|
|
||||||
return native_states
|
|
||||||
|
|
||||||
states: list[State] = await hass.async_add_executor_job(_fetch_states)
|
|
||||||
assert len(states) > 1
|
|
||||||
for state in states:
|
|
||||||
assert ATTR_FORECAST not in state.attributes
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user