コード例 #1
0
ファイル: test_light.py プロジェクト: rikroe/core
async def test_turn_on_off(hass: HomeAssistant):
    """Test support of the light.turn_on service."""
    client = ClientMock()
    client.state = False
    client.brightness = {"mode": "enabled", "value": 20}
    entity, _, _, _ = await _create_entries(hass, client)

    assert hass.states.get(entity.entity_id).state == "off"

    await hass.services.async_call(
        "light", "turn_on", service_data={"entity_id": entity.entity_id})
    await hass.async_block_till_done()

    state = hass.states.get(entity.entity_id)

    assert state.state == "on"
    assert state.attributes[ATTR_BRIGHTNESS] == 51
コード例 #2
0
async def test_turn_on(hass: HomeAssistant):
    """Test support of the light.turn_on service."""
    client = ClientMock()
    client.is_on = False
    client.brightness = 20
    entity, _, _ = await _create_entries(hass, client)

    assert hass.states.get(entity.entity_id).state == "off"

    await hass.services.async_call(
        "light", "turn_on", service_data={"entity_id": entity.entity_id})
    await hass.async_block_till_done()

    state = hass.states.get(entity.entity_id)

    assert state.state == "on"
    assert state.attributes["brightness"] == 51
コード例 #3
0
async def test_turn_on_with_brightness(opp: OpenPeerPower):
    """Test support of the light.turn_on service with a brightness parameter."""
    client = ClientMock()
    client.is_on = False
    client.brightness = 20
    entity, _, _ = await _create_entries(opp, client)

    assert opp.states.get(entity.entity_id).state == "off"

    await opp.services.async_call(
        "light",
        "turn_on",
        service_data={
            "entity_id": entity.entity_id,
            "brightness": 255
        },
    )
    await opp.async_block_till_done()

    state = opp.states.get(entity.entity_id)

    assert state.state == "on"
    assert state.attributes["brightness"] == 255
コード例 #4
0
ファイル: test_light.py プロジェクト: rikroe/core
async def test_turn_on_with_color_rgb(hass: HomeAssistant):
    """Test support of the light.turn_on service with a brightness parameter."""
    client = ClientMock()
    client.state = False
    client.device_info["led_profile"] = "RGB"
    client.brightness = {"mode": "enabled", "value": 255}
    entity, _, _, _ = await _create_entries(hass, client)

    assert hass.states.get(entity.entity_id).state == "off"

    await hass.services.async_call(
        "light",
        "turn_on",
        service_data={
            "entity_id": entity.entity_id,
            "rgb_color": (128, 64, 32)
        },
    )
    await hass.async_block_till_done()

    state = hass.states.get(entity.entity_id)

    assert state.state == "on"
    assert client.color == (128, 64, 32)