Beispiel #1
0
async def test_sensor_does_not_exist_before_monitor_connected(
        hass: HomeAssistant, monitors: AsyncMock) -> None:
    """Test that a sensor does not exist before its monitor is connected."""
    # The sensor base class handles connecting the monitor, so we test this with a single voltage sensor for ease
    await setup_greeneye_monitor_component_with_config(
        hass, SINGLE_MONITOR_CONFIG_VOLTAGE_SENSORS)

    entity_registry = get_entity_registry(hass)
    assert entity_registry.async_get("sensor.voltage_1") is None
Beispiel #2
0
def assert_sensor_registered(
    hass: HomeAssistant,
    serial_number: int,
    sensor_type: str,
    number: int,
    name: str,
) -> RegistryEntry:
    """Assert that a sensor entity of a given type was registered properly."""
    registry = get_entity_registry(hass)
    unique_id = f"{serial_number}-{sensor_type}-{number}"

    entity_id = registry.async_get_entity_id("sensor", DOMAIN, unique_id)
    assert entity_id is not None

    sensor = registry.async_get(entity_id)
    assert sensor
    assert sensor.unique_id == unique_id
    assert sensor.original_name == name

    return sensor
Beispiel #3
0
async def disable_entity(hass: HomeAssistant, entity_id: str) -> None:
    """Disable the given entity."""
    entity_registry = get_entity_registry(hass)
    entity_registry.async_update_entity(entity_id,
                                        disabled_by=RegistryEntryDisabler.USER)
    await hass.async_block_till_done()