mirror of
https://github.com/home-assistant/core.git
synced 2026-09-24 15:31:52 -05:00
Remove temperature conversion - mhz19 (#55164)
This commit is contained in:
@@ -86,13 +86,13 @@ async def aiohttp_client_update_good_read(mock_function):
|
||||
async def test_co2_sensor(mock_function, hass):
|
||||
"""Test CO2 sensor."""
|
||||
client = mhz19.MHZClient(co2sensor, "test.serial")
|
||||
sensor = mhz19.MHZ19Sensor(client, mhz19.SENSOR_CO2, None, "name")
|
||||
sensor = mhz19.MHZ19Sensor(client, mhz19.SENSOR_CO2, "name")
|
||||
sensor.hass = hass
|
||||
sensor.update()
|
||||
|
||||
assert sensor.name == "name: CO2"
|
||||
assert sensor.state == 1000
|
||||
assert sensor.unit_of_measurement == CONCENTRATION_PARTS_PER_MILLION
|
||||
assert sensor.native_unit_of_measurement == CONCENTRATION_PARTS_PER_MILLION
|
||||
assert sensor.should_poll
|
||||
assert sensor.extra_state_attributes == {"temperature": 24}
|
||||
|
||||
@@ -101,13 +101,13 @@ async def test_co2_sensor(mock_function, hass):
|
||||
async def test_temperature_sensor(mock_function, hass):
|
||||
"""Test temperature sensor."""
|
||||
client = mhz19.MHZClient(co2sensor, "test.serial")
|
||||
sensor = mhz19.MHZ19Sensor(client, mhz19.SENSOR_TEMPERATURE, None, "name")
|
||||
sensor = mhz19.MHZ19Sensor(client, mhz19.SENSOR_TEMPERATURE, "name")
|
||||
sensor.hass = hass
|
||||
sensor.update()
|
||||
|
||||
assert sensor.name == "name: Temperature"
|
||||
assert sensor.state == 24
|
||||
assert sensor.unit_of_measurement == TEMP_CELSIUS
|
||||
assert sensor.native_unit_of_measurement == TEMP_CELSIUS
|
||||
assert sensor.should_poll
|
||||
assert sensor.extra_state_attributes == {"co2_concentration": 1000}
|
||||
|
||||
@@ -115,11 +115,10 @@ async def test_temperature_sensor(mock_function, hass):
|
||||
@patch("pmsensor.co2sensor.read_mh_z19_with_temperature", return_value=(1000, 24))
|
||||
async def test_temperature_sensor_f(mock_function, hass):
|
||||
"""Test temperature sensor."""
|
||||
client = mhz19.MHZClient(co2sensor, "test.serial")
|
||||
sensor = mhz19.MHZ19Sensor(
|
||||
client, mhz19.SENSOR_TEMPERATURE, TEMP_FAHRENHEIT, "name"
|
||||
)
|
||||
sensor.hass = hass
|
||||
sensor.update()
|
||||
with patch.object(hass.config.units, "temperature_unit", TEMP_FAHRENHEIT):
|
||||
client = mhz19.MHZClient(co2sensor, "test.serial")
|
||||
sensor = mhz19.MHZ19Sensor(client, mhz19.SENSOR_TEMPERATURE, "name")
|
||||
sensor.hass = hass
|
||||
sensor.update()
|
||||
|
||||
assert sensor.state == 75.2
|
||||
assert sensor.state == "75"
|
||||
|
||||
Reference in New Issue
Block a user