Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
from homeassistant.const import CONF_ENTITY_ID, STATE_OFF, STATE_ON | ||
from homeassistant.core import HomeAssistant | ||
from homeassistant.components.light import ColorMode, ATTR_BRIGHTNESS, ATTR_COLOR_MODE, ATTR_COLOR_TEMP | ||
from custom_components.test.light import MockLight | ||
|
||
from ...common import create_mock_light_entity | ||
|
||
from custom_components.powercalc.const import ( | ||
CONF_CUSTOM_MODEL_DIRECTORY, | ||
CONF_MANUFACTURER, | ||
CONF_MODEL, | ||
) | ||
from tests.common import get_test_profile_dir, run_powercalc_setup_yaml_config | ||
|
||
|
||
async def test_infrared_light(hass: HomeAssistant): | ||
""" | ||
Infrared capable light with several sub profiles | ||
""" | ||
power_sensor_id = "sensor.test_power" | ||
light_id = "light.test" | ||
|
||
light_mock = MockLight("test") | ||
light_mock.manufacturer = "LIFX" | ||
light_mock.model = "LIFX A19 Night Vision" | ||
light_mock.supported_color_modes = [ColorMode.HS, ColorMode.COLOR_TEMP] | ||
|
||
await create_mock_light_entity(hass, light_mock) | ||
|
||
await run_powercalc_setup_yaml_config( | ||
hass, | ||
{ | ||
CONF_ENTITY_ID: light_id, | ||
CONF_MANUFACTURER: light_mock.manufacturer, | ||
CONF_MODEL: light_mock.model, | ||
CONF_CUSTOM_MODEL_DIRECTORY: get_test_profile_dir("infrared_light"), | ||
}, | ||
) | ||
|
||
power_state = hass.states.get(power_sensor_id) | ||
assert power_state | ||
|
||
hass.states.async_set( | ||
light_id, | ||
STATE_ON, | ||
{ | ||
"infrared_brightness": "50%", | ||
ATTR_BRIGHTNESS: 11, | ||
ATTR_COLOR_MODE: ColorMode.COLOR_TEMP, | ||
ATTR_COLOR_TEMP: 601 | ||
} | ||
) | ||
await hass.async_block_till_done() | ||
|
||
assert hass.states.get(power_sensor_id).state == "4.37" | ||
|
||
hass.states.async_set( | ||
light_id, | ||
STATE_ON, | ||
{ | ||
"infrared_brightness": "25%", | ||
ATTR_BRIGHTNESS: 11, | ||
ATTR_COLOR_MODE: ColorMode.COLOR_TEMP, | ||
ATTR_COLOR_TEMP: 601 | ||
} | ||
) | ||
await hass.async_block_till_done() | ||
|
||
assert hass.states.get(power_sensor_id).state == "2.59" | ||
|
Binary file added
BIN
+9.94 KB
tests/testing_config/powercalc_profiles/infrared_light/infrared_100/color_temp.csv.gz
Binary file not shown.
Binary file added
BIN
+8.39 KB
tests/testing_config/powercalc_profiles/infrared_light/infrared_100/hs.csv.gz
Binary file not shown.
3 changes: 3 additions & 0 deletions
3
tests/testing_config/powercalc_profiles/infrared_light/infrared_100/model.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"standby_power": 8.37 | ||
} |
Binary file added
BIN
+10.2 KB
tests/testing_config/powercalc_profiles/infrared_light/infrared_25/color_temp.csv.gz
Binary file not shown.
Binary file added
BIN
+8.44 KB
tests/testing_config/powercalc_profiles/infrared_light/infrared_25/hs.csv.gz
Binary file not shown.
3 changes: 3 additions & 0 deletions
3
tests/testing_config/powercalc_profiles/infrared_light/infrared_25/model.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"standby_power": 2.38 | ||
} |
Binary file added
BIN
+10.2 KB
tests/testing_config/powercalc_profiles/infrared_light/infrared_50/color_temp.csv.gz
Binary file not shown.
Binary file added
BIN
+10.2 KB
tests/testing_config/powercalc_profiles/infrared_light/infrared_off/color_temp.csv.gz
Binary file not shown.