Ejemplo n.º 1
0
async def test_temperature_sensor_f(mock_function):
    """Test temperature sensor."""
    client = mhz19.MHZClient(co2sensor, "test.serial")
    sensor = mhz19.MHZ19Sensor(client, mhz19.SENSOR_TEMPERATURE,
                               TEMP_FAHRENHEIT, "name")
    sensor.update()

    assert sensor.state == 75.2
Ejemplo n.º 2
0
async def test_temperature_sensor_f(mock_function, hass):
    """Test temperature sensor."""
    with patch.object(hass.config.units, "temperature_unit", TEMP_FAHRENHEIT):
        client = mhz19.MHZClient(co2sensor, "test.serial")
        sensor = mhz19.MHZ19Sensor(client, "name", mhz19.SENSOR_TYPES[0])
        sensor.hass = hass
        sensor.update()

        assert sensor.state == 75
Ejemplo n.º 3
0
    def test_temperature_sensor_f(self, mock_function):
        """Test temperature sensor."""
        from pmsensor import co2sensor

        client = mhz19.MHZClient(co2sensor, "test.serial")
        sensor = mhz19.MHZ19Sensor(client, mhz19.SENSOR_TEMPERATURE,
                                   TEMP_FAHRENHEIT, "name")
        sensor.update()

        assert 75.2 == sensor.state
Ejemplo n.º 4
0
async def test_temperature_sensor(mock_function):
    """Test temperature sensor."""
    client = mhz19.MHZClient(co2sensor, "test.serial")
    sensor = mhz19.MHZ19Sensor(client, mhz19.SENSOR_TEMPERATURE, None, "name")
    sensor.update()

    assert sensor.name == "name: Temperature"
    assert sensor.state == 24
    assert sensor.unit_of_measurement == TEMP_CELSIUS
    assert sensor.should_poll
    assert sensor.device_state_attributes == {"co2_concentration": 1000}
Ejemplo n.º 5
0
async def test_co2_sensor(mock_function):
    """Test CO2 sensor."""
    client = mhz19.MHZClient(co2sensor, "test.serial")
    sensor = mhz19.MHZ19Sensor(client, mhz19.SENSOR_CO2, None, "name")
    sensor.update()

    assert sensor.name == "name: CO2"
    assert sensor.state == 1000
    assert sensor.unit_of_measurement == CONCENTRATION_PARTS_PER_MILLION
    assert sensor.should_poll
    assert sensor.device_state_attributes == {"temperature": 24}
Ejemplo n.º 6
0
async def test_co2_sensor(mock_function, hass):
    """Test CO2 sensor."""
    client = mhz19.MHZClient(co2sensor, "test.serial")
    sensor = mhz19.MHZ19Sensor(client, "name", mhz19.SENSOR_TYPES[1])
    sensor.hass = hass
    sensor.update()

    assert sensor.name == "name: CO2"
    assert sensor.state == 1000
    assert sensor.native_unit_of_measurement == CONCENTRATION_PARTS_PER_MILLION
    assert sensor.should_poll
    assert sensor.extra_state_attributes == {"temperature": 24}
Ejemplo n.º 7
0
async def test_temperature_sensor(mock_function, hass):
    """Test temperature sensor."""
    client = mhz19.MHZClient(co2sensor, "test.serial")
    sensor = mhz19.MHZ19Sensor(client, "name", mhz19.SENSOR_TYPES[0])
    sensor.hass = hass
    sensor.update()

    assert sensor.name == "name: Temperature"
    assert sensor.state == 24
    assert sensor.native_unit_of_measurement == TEMP_CELSIUS
    assert sensor.should_poll
    assert sensor.extra_state_attributes == {"co2_concentration": 1000}
Ejemplo n.º 8
0
    def test_co2_sensor(self, mock_function):
        """Test CO2 sensor."""
        from pmsensor import co2sensor

        client = mhz19.MHZClient(co2sensor, "test.serial")
        sensor = mhz19.MHZ19Sensor(client, mhz19.SENSOR_CO2, None, "name")
        sensor.update()

        assert "name: CO2" == sensor.name
        assert 1000 == sensor.state
        assert "ppm" == sensor.unit_of_measurement
        assert sensor.should_poll
        assert {"temperature": 24} == sensor.device_state_attributes
Ejemplo n.º 9
0
    def test_temperature_sensor(self, mock_function):
        """Test temperature sensor."""
        from pmsensor import co2sensor

        client = mhz19.MHZClient(co2sensor, "test.serial")
        sensor = mhz19.MHZ19Sensor(client, mhz19.SENSOR_TEMPERATURE, None,
                                   "name")
        sensor.update()

        assert "name: Temperature" == sensor.name
        assert 24 == sensor.state
        assert "°C" == sensor.unit_of_measurement
        assert sensor.should_poll
        assert {"co2_concentration": 1000} == sensor.device_state_attributes