mirror of
https://github.com/home-assistant/core.git
synced 2025-11-08 18:39:30 +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
67 lines
2.1 KiB
Python
67 lines
2.1 KiB
Python
"""Test honeywell sensor."""
|
|
|
|
from aiosomecomfort.device import Device
|
|
from aiosomecomfort.location import Location
|
|
import pytest
|
|
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
from tests.common import MockConfigEntry
|
|
|
|
|
|
@pytest.mark.parametrize(("unit", "temp"), [("C", 5), ("F", -15)])
|
|
async def test_outdoor_sensor(
|
|
hass: HomeAssistant,
|
|
config_entry: MockConfigEntry,
|
|
location: Location,
|
|
device_with_outdoor_sensor: Device,
|
|
unit,
|
|
temp,
|
|
) -> None:
|
|
"""Test outdoor temperature sensor."""
|
|
device_with_outdoor_sensor.temperature_unit = unit
|
|
location.devices_by_id[device_with_outdoor_sensor.deviceid] = (
|
|
device_with_outdoor_sensor
|
|
)
|
|
config_entry.add_to_hass(hass)
|
|
await hass.config_entries.async_setup(config_entry.entry_id)
|
|
await hass.async_block_till_done()
|
|
|
|
temperature_state = hass.states.get("sensor.device3_outdoor_temperature")
|
|
humidity_state = hass.states.get("sensor.device3_outdoor_humidity")
|
|
|
|
assert temperature_state
|
|
assert humidity_state
|
|
assert float(temperature_state.state) == temp
|
|
assert float(humidity_state.state) == 25
|
|
|
|
|
|
@pytest.mark.parametrize(("unit", "temp"), [("C", 5), ("F", -15)])
|
|
async def test_indoor_sensor(
|
|
hass: HomeAssistant,
|
|
config_entry: MockConfigEntry,
|
|
location: Location,
|
|
device: Device,
|
|
unit,
|
|
temp,
|
|
) -> None:
|
|
"""Test indoor temperature sensor with no outdoor sensors."""
|
|
device.temperature_unit = unit
|
|
device.current_temperature = 5
|
|
device.current_humidity = 25
|
|
location.devices_by_id[device.deviceid] = device
|
|
config_entry.add_to_hass(hass)
|
|
await hass.config_entries.async_setup(config_entry.entry_id)
|
|
await hass.async_block_till_done()
|
|
|
|
assert hass.states.get("sensor.device1_outdoor_temperature") is None
|
|
assert hass.states.get("sensor.device1_outdoor_humidity") is None
|
|
|
|
temperature_state = hass.states.get("sensor.device1_temperature")
|
|
humidity_state = hass.states.get("sensor.device1_humidity")
|
|
|
|
assert temperature_state
|
|
assert humidity_state
|
|
assert float(temperature_state.state) == temp
|
|
assert humidity_state.state == "25"
|