mirror of
https://github.com/home-assistant/core.git
synced 2025-11-09 10:59:40 +00:00
* Add default device class display precision for Sensor * Renaming, docstrings, cleanup * Simplify units list * Fix tests * Fix missing precision when suggested is specified * Update snapshots * Fix when unit of measurement is not valid * Fix tests * Fix deprecated unit usage * Fix goalzero tests The sensor native_value method was accessing the data dict and trowing, since the mock did not have any data for the sensors. Since now the precision is always specified (it was missing for those sensors), the throw was hitting async_update_entity_options in _update_suggested_precision. Previously, async_update_entity_options was not called since it had no precision. * Fix metoffice * Fix smartthings * Add default sensor data for Tesla Wall Connector tests * Update snapshots * Revert spaces * Update smartthings snapshots * Add missing sensor mock for tesla wall connector * Address review comments * Add doc comment * Add cap to doc comment * Update comment * Update snapshots * Update comment
137 lines
4.9 KiB
Python
137 lines
4.9 KiB
Python
"""The sensor tests for the nexia platform."""
|
|
|
|
from homeassistant.const import PERCENTAGE, UnitOfTemperature
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
from .util import async_init_integration
|
|
|
|
|
|
async def test_create_sensors(hass: HomeAssistant) -> None:
|
|
"""Test creation of sensors."""
|
|
|
|
await async_init_integration(hass)
|
|
|
|
state = hass.states.get("sensor.nick_office_temperature")
|
|
assert round(float(state.state)) == 23
|
|
|
|
expected_attributes = {
|
|
"attribution": "Data provided by Trane Technologies",
|
|
"device_class": "temperature",
|
|
"friendly_name": "Nick Office Temperature",
|
|
"unit_of_measurement": UnitOfTemperature.CELSIUS,
|
|
}
|
|
# Only test for a subset of attributes in case
|
|
# HA changes the implementation and a new one appears
|
|
assert all(
|
|
state.attributes[key] == value for key, value in expected_attributes.items()
|
|
)
|
|
|
|
state = hass.states.get("sensor.nick_office_zone_setpoint_status")
|
|
assert state.state == "Permanent Hold"
|
|
expected_attributes = {
|
|
"attribution": "Data provided by Trane Technologies",
|
|
"friendly_name": "Nick Office Zone setpoint status",
|
|
}
|
|
# Only test for a subset of attributes in case
|
|
# HA changes the implementation and a new one appears
|
|
assert all(
|
|
state.attributes[key] == value for key, value in expected_attributes.items()
|
|
)
|
|
|
|
state = hass.states.get("sensor.nick_office_zone_status")
|
|
assert state.state == "Relieving Air"
|
|
|
|
expected_attributes = {
|
|
"attribution": "Data provided by Trane Technologies",
|
|
"friendly_name": "Nick Office Zone status",
|
|
}
|
|
# Only test for a subset of attributes in case
|
|
# HA changes the implementation and a new one appears
|
|
assert all(
|
|
state.attributes[key] == value for key, value in expected_attributes.items()
|
|
)
|
|
|
|
state = hass.states.get("sensor.master_suite_air_cleaner_mode")
|
|
assert state.state == "auto"
|
|
|
|
expected_attributes = {
|
|
"attribution": "Data provided by Trane Technologies",
|
|
"friendly_name": "Master Suite Air cleaner mode",
|
|
}
|
|
# Only test for a subset of attributes in case
|
|
# HA changes the implementation and a new one appears
|
|
assert all(
|
|
state.attributes[key] == value for key, value in expected_attributes.items()
|
|
)
|
|
|
|
state = hass.states.get("sensor.master_suite_current_compressor_speed")
|
|
assert round(float(state.state)) == 69
|
|
|
|
expected_attributes = {
|
|
"attribution": "Data provided by Trane Technologies",
|
|
"friendly_name": "Master Suite Current compressor speed",
|
|
"unit_of_measurement": PERCENTAGE,
|
|
}
|
|
# Only test for a subset of attributes in case
|
|
# HA changes the implementation and a new one appears
|
|
assert all(
|
|
state.attributes[key] == value for key, value in expected_attributes.items()
|
|
)
|
|
|
|
state = hass.states.get("sensor.master_suite_outdoor_temperature")
|
|
assert round(float(state.state), 1) == 30.6
|
|
|
|
expected_attributes = {
|
|
"attribution": "Data provided by Trane Technologies",
|
|
"device_class": "temperature",
|
|
"friendly_name": "Master Suite Outdoor temperature",
|
|
"unit_of_measurement": UnitOfTemperature.CELSIUS,
|
|
}
|
|
# Only test for a subset of attributes in case
|
|
# HA changes the implementation and a new one appears
|
|
assert all(
|
|
state.attributes[key] == value for key, value in expected_attributes.items()
|
|
)
|
|
|
|
state = hass.states.get("sensor.master_suite_humidity")
|
|
assert state.state == "52.0"
|
|
|
|
expected_attributes = {
|
|
"attribution": "Data provided by Trane Technologies",
|
|
"device_class": "humidity",
|
|
"friendly_name": "Master Suite Humidity",
|
|
"unit_of_measurement": PERCENTAGE,
|
|
}
|
|
# Only test for a subset of attributes in case
|
|
# HA changes the implementation and a new one appears
|
|
assert all(
|
|
state.attributes[key] == value for key, value in expected_attributes.items()
|
|
)
|
|
|
|
state = hass.states.get("sensor.master_suite_requested_compressor_speed")
|
|
assert state.state == "69.0"
|
|
|
|
expected_attributes = {
|
|
"attribution": "Data provided by Trane Technologies",
|
|
"friendly_name": "Master Suite Requested compressor speed",
|
|
"unit_of_measurement": PERCENTAGE,
|
|
}
|
|
# Only test for a subset of attributes in case
|
|
# HA changes the implementation and a new one appears
|
|
assert all(
|
|
state.attributes[key] == value for key, value in expected_attributes.items()
|
|
)
|
|
|
|
state = hass.states.get("sensor.master_suite_system_status")
|
|
assert state.state == "Cooling"
|
|
|
|
expected_attributes = {
|
|
"attribution": "Data provided by Trane Technologies",
|
|
"friendly_name": "Master Suite System status",
|
|
}
|
|
# Only test for a subset of attributes in case
|
|
# HA changes the implementation and a new one appears
|
|
assert all(
|
|
state.attributes[key] == value for key, value in expected_attributes.items()
|
|
)
|