Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 40 additions & 21 deletions tests/components/huisbaasje/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@

from homeassistant.components import huisbaasje
from homeassistant.components.huisbaasje.const import FLOW_CUBIC_METERS_PER_HOUR
from homeassistant.components.sensor import ATTR_STATE_CLASS, SensorStateClass
from homeassistant.components.sensor import (
ATTR_STATE_CLASS,
SensorDeviceClass,
SensorStateClass,
)
from homeassistant.const import (
ATTR_DEVICE_CLASS,
ATTR_ICON,
ATTR_UNIT_OF_MEASUREMENT,
CONF_ID,
CONF_PASSWORD,
CONF_USERNAME,
DEVICE_CLASS_ENERGY,
DEVICE_CLASS_GAS,
DEVICE_CLASS_POWER,
ENERGY_KILO_WATT_HOUR,
POWER_WATT,
VOLUME_CUBIC_METERS,
Expand Down Expand Up @@ -58,7 +59,9 @@ async def test_setup_entry(hass: HomeAssistant):
# Assert data is loaded
current_power = hass.states.get("sensor.huisbaasje_current_power")
assert current_power.state == "1012.0"
assert current_power.attributes.get(ATTR_DEVICE_CLASS) == DEVICE_CLASS_POWER
assert (
current_power.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.POWER
)
assert current_power.attributes.get(ATTR_ICON) == "mdi:lightning-bolt"
assert (
current_power.attributes.get(ATTR_STATE_CLASS)
Expand All @@ -68,7 +71,10 @@ async def test_setup_entry(hass: HomeAssistant):

current_power_in = hass.states.get("sensor.huisbaasje_current_power_in_peak")
assert current_power_in.state == "1012.0"
assert current_power_in.attributes.get(ATTR_DEVICE_CLASS) == DEVICE_CLASS_POWER
assert (
current_power_in.attributes.get(ATTR_DEVICE_CLASS)
== SensorDeviceClass.POWER
)
assert current_power_in.attributes.get(ATTR_ICON) == "mdi:lightning-bolt"
assert (
current_power_in.attributes.get(ATTR_STATE_CLASS)
Expand All @@ -81,7 +87,8 @@ async def test_setup_entry(hass: HomeAssistant):
)
assert current_power_in_low.state == "unknown"
assert (
current_power_in_low.attributes.get(ATTR_DEVICE_CLASS) == DEVICE_CLASS_POWER
current_power_in_low.attributes.get(ATTR_DEVICE_CLASS)
== SensorDeviceClass.POWER
)
assert current_power_in_low.attributes.get(ATTR_ICON) == "mdi:lightning-bolt"
assert (
Expand All @@ -94,7 +101,10 @@ async def test_setup_entry(hass: HomeAssistant):

current_power_out = hass.states.get("sensor.huisbaasje_current_power_out_peak")
assert current_power_out.state == "unknown"
assert current_power_out.attributes.get(ATTR_DEVICE_CLASS) == DEVICE_CLASS_POWER
assert (
current_power_out.attributes.get(ATTR_DEVICE_CLASS)
== SensorDeviceClass.POWER
)
assert current_power_out.attributes.get(ATTR_ICON) == "mdi:lightning-bolt"
assert (
current_power_out.attributes.get(ATTR_STATE_CLASS)
Expand All @@ -108,7 +118,7 @@ async def test_setup_entry(hass: HomeAssistant):
assert current_power_out_low.state == "unknown"
assert (
current_power_out_low.attributes.get(ATTR_DEVICE_CLASS)
== DEVICE_CLASS_POWER
== SensorDeviceClass.POWER
)
assert current_power_out_low.attributes.get(ATTR_ICON) == "mdi:lightning-bolt"
assert (
Expand All @@ -125,7 +135,7 @@ async def test_setup_entry(hass: HomeAssistant):
assert energy_consumption_peak_today.state == "2.67"
assert (
energy_consumption_peak_today.attributes.get(ATTR_DEVICE_CLASS)
== DEVICE_CLASS_ENERGY
== SensorDeviceClass.ENERGY
)
assert (
energy_consumption_peak_today.attributes.get(ATTR_ICON)
Expand All @@ -146,7 +156,7 @@ async def test_setup_entry(hass: HomeAssistant):
assert energy_consumption_off_peak_today.state == "0.627"
assert (
energy_consumption_off_peak_today.attributes.get(ATTR_DEVICE_CLASS)
== DEVICE_CLASS_ENERGY
== SensorDeviceClass.ENERGY
)
assert (
energy_consumption_off_peak_today.attributes.get(ATTR_ICON)
Expand All @@ -167,7 +177,7 @@ async def test_setup_entry(hass: HomeAssistant):
assert energy_production_peak_today.state == "1.512"
assert (
energy_production_peak_today.attributes.get(ATTR_DEVICE_CLASS)
== DEVICE_CLASS_ENERGY
== SensorDeviceClass.ENERGY
)
assert (
energy_production_peak_today.attributes.get(ATTR_ICON)
Expand All @@ -188,7 +198,7 @@ async def test_setup_entry(hass: HomeAssistant):
assert energy_production_off_peak_today.state == "1.093"
assert (
energy_production_off_peak_today.attributes.get(ATTR_DEVICE_CLASS)
== DEVICE_CLASS_ENERGY
== SensorDeviceClass.ENERGY
)
assert (
energy_production_off_peak_today.attributes.get(ATTR_ICON)
Expand All @@ -205,7 +215,9 @@ async def test_setup_entry(hass: HomeAssistant):

energy_today = hass.states.get("sensor.huisbaasje_energy_today")
assert energy_today.state == "3.3"
assert energy_today.attributes.get(ATTR_DEVICE_CLASS) == DEVICE_CLASS_ENERGY
assert (
energy_today.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.ENERGY
)
assert energy_today.attributes.get(ATTR_ICON) == "mdi:lightning-bolt"
assert (
energy_today.attributes.get(ATTR_STATE_CLASS)
Expand All @@ -218,7 +230,10 @@ async def test_setup_entry(hass: HomeAssistant):

energy_this_week = hass.states.get("sensor.huisbaasje_energy_this_week")
assert energy_this_week.state == "17.5"
assert energy_this_week.attributes.get(ATTR_DEVICE_CLASS) == DEVICE_CLASS_ENERGY
assert (
energy_this_week.attributes.get(ATTR_DEVICE_CLASS)
== SensorDeviceClass.ENERGY
)
assert energy_this_week.attributes.get(ATTR_ICON) == "mdi:lightning-bolt"
assert (
energy_this_week.attributes.get(ATTR_STATE_CLASS)
Expand All @@ -232,7 +247,8 @@ async def test_setup_entry(hass: HomeAssistant):
energy_this_month = hass.states.get("sensor.huisbaasje_energy_this_month")
assert energy_this_month.state == "103.3"
assert (
energy_this_month.attributes.get(ATTR_DEVICE_CLASS) == DEVICE_CLASS_ENERGY
energy_this_month.attributes.get(ATTR_DEVICE_CLASS)
== SensorDeviceClass.ENERGY
)
assert energy_this_month.attributes.get(ATTR_ICON) == "mdi:lightning-bolt"
assert (
Expand All @@ -246,7 +262,10 @@ async def test_setup_entry(hass: HomeAssistant):

energy_this_year = hass.states.get("sensor.huisbaasje_energy_this_year")
assert energy_this_year.state == "673.0"
assert energy_this_year.attributes.get(ATTR_DEVICE_CLASS) == DEVICE_CLASS_ENERGY
assert (
energy_this_year.attributes.get(ATTR_DEVICE_CLASS)
== SensorDeviceClass.ENERGY
)
assert energy_this_year.attributes.get(ATTR_ICON) == "mdi:lightning-bolt"
assert (
energy_this_year.attributes.get(ATTR_STATE_CLASS)
Expand All @@ -271,7 +290,7 @@ async def test_setup_entry(hass: HomeAssistant):

gas_today = hass.states.get("sensor.huisbaasje_gas_today")
assert gas_today.state == "1.1"
assert gas_today.attributes.get(ATTR_DEVICE_CLASS) == DEVICE_CLASS_GAS
assert gas_today.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.GAS
assert gas_today.attributes.get(ATTR_ICON) == "mdi:counter"
assert (
gas_today.attributes.get(ATTR_STATE_CLASS)
Expand All @@ -281,7 +300,7 @@ async def test_setup_entry(hass: HomeAssistant):

gas_this_week = hass.states.get("sensor.huisbaasje_gas_this_week")
assert gas_this_week.state == "5.6"
assert gas_this_week.attributes.get(ATTR_DEVICE_CLASS) == DEVICE_CLASS_GAS
assert gas_this_week.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.GAS
assert gas_this_week.attributes.get(ATTR_ICON) == "mdi:counter"
assert (
gas_this_week.attributes.get(ATTR_STATE_CLASS)
Expand All @@ -294,7 +313,7 @@ async def test_setup_entry(hass: HomeAssistant):

gas_this_month = hass.states.get("sensor.huisbaasje_gas_this_month")
assert gas_this_month.state == "39.1"
assert gas_this_month.attributes.get(ATTR_DEVICE_CLASS) == DEVICE_CLASS_GAS
assert gas_this_month.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.GAS
assert gas_this_month.attributes.get(ATTR_ICON) == "mdi:counter"
assert (
gas_this_month.attributes.get(ATTR_STATE_CLASS)
Expand All @@ -307,7 +326,7 @@ async def test_setup_entry(hass: HomeAssistant):

gas_this_year = hass.states.get("sensor.huisbaasje_gas_this_year")
assert gas_this_year.state == "116.7"
assert gas_this_year.attributes.get(ATTR_DEVICE_CLASS) == DEVICE_CLASS_GAS
assert gas_this_year.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.GAS
assert gas_this_year.attributes.get(ATTR_ICON) == "mdi:counter"
assert (
gas_this_year.attributes.get(ATTR_STATE_CLASS)
Expand Down