Пример #1
0
def test_light_state_to_dict_value_with_brightness_and_empty_color_states():
    assert LightState("light.foo", "on", [], 25, None).to_dict_value() == {
        "light.foo": {
            "state": "on",
            "brightness": 25
        }
    }
Пример #2
0
def test_light_state_create_light_state():
    state_data = {"entity_id": "light.foo", "state": "on", "attributes": {}}
    assert LightState.create_light_state(state_data).to_dict_value() == {
        "light.foo": {
            "state": "on"
        }
    }
Пример #3
0
def test_light_state_to_dict_value_with_brightness_and_color_temp():
    assert LightState("light.foo", "on", [], 25, 100).to_dict_value() == {
        "light.foo": {
            "state": "on",
            "brightness": 25,
            "color_temp": 100
        }
    }
Пример #4
0
def test_light_state_create_light_state_with_color_state_and_brightness():
    state_data = {
        "entity_id": "light.foo",
        "state": "on",
        "attributes": {
            "xy_color": [0.01, 0.15],
            "brightness": 125
        }
    }
    assert LightState.create_light_state(state_data).to_dict_value() == {
        "light.foo": {
            "state": "on",
            "xy_color": [0.01, 0.15],
            "brightness": 125
        }
    }
Пример #5
0
def test_light_scene_to_dict():
    firstLightState = LightState(
        "light.foo", "on",
        [RGBColorState(200, 100, 200),
         XYColorState(0.01, 0.15)], None, None)
    secondLightState = LightState("light.foo2", "on", [], 25, 100)

    actual_scene_dict = LightScene(
        "Test Scene", "Living Room",
        [firstLightState, secondLightState]).to_dict()
    expected_scene_dict = {"name": "Living Room Test Scene", "entities": {}}
    expected_scene_dict["entities"].update(firstLightState.to_dict_value())
    expected_scene_dict["entities"].update(secondLightState.to_dict_value())

    assert actual_scene_dict == expected_scene_dict
Пример #6
0
def test_light_state_to_dict_value_with_no_brightness_and_None_color_states():
    assert LightState("light.foo", "on", None, None, None).to_dict_value() == {
        "light.foo": {
            "state": "on"
        }
    }
Пример #7
0
def test_light_state_to_dict_value_with_no_brightness():
    assert LightState("light.foo", "on", [RGBColorState(200, 100, 200)], None, None).to_dict_value() \
        == {"light.foo": {"state": "on", "rgb_color": [200, 100, 200]}}
Пример #8
0
def test_light_state_to_dict_value():
    assert LightState("light.foo", "on", [RGBColorState(200, 100, 200), XYColorState(0.01, 0.15)], None, None).to_dict_value() \
        == {"light.foo": {"state": "on", "rgb_color": [200, 100, 200], "xy_color": [0.01, 0.15]}}