mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 15:17:35 +00:00
Homekit: Changed device_class requirement Humidity Sensor (#14277)
This commit is contained in:
parent
7900ba30bf
commit
bb76ba67f3
@ -126,10 +126,10 @@ def get_accessory(hass, state, aid, config):
|
|||||||
unit = state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
unit = state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
||||||
device_class = state.attributes.get(ATTR_DEVICE_CLASS)
|
device_class = state.attributes.get(ATTR_DEVICE_CLASS)
|
||||||
|
|
||||||
if device_class == DEVICE_CLASS_TEMPERATURE or unit == TEMP_CELSIUS \
|
if device_class == DEVICE_CLASS_TEMPERATURE or \
|
||||||
or unit == TEMP_FAHRENHEIT:
|
unit in (TEMP_CELSIUS, TEMP_FAHRENHEIT):
|
||||||
a_type = 'TemperatureSensor'
|
a_type = 'TemperatureSensor'
|
||||||
elif device_class == DEVICE_CLASS_HUMIDITY or unit == '%':
|
elif device_class == DEVICE_CLASS_HUMIDITY and unit == '%':
|
||||||
a_type = 'HumiditySensor'
|
a_type = 'HumiditySensor'
|
||||||
elif device_class == DEVICE_CLASS_PM25 \
|
elif device_class == DEVICE_CLASS_PM25 \
|
||||||
or DEVICE_CLASS_PM25 in state.entity_id:
|
or DEVICE_CLASS_PM25 in state.entity_id:
|
||||||
@ -141,8 +141,7 @@ def get_accessory(hass, state, aid, config):
|
|||||||
unit == 'lux' or unit == 'lx':
|
unit == 'lux' or unit == 'lx':
|
||||||
a_type = 'LightSensor'
|
a_type = 'LightSensor'
|
||||||
|
|
||||||
elif state.domain == 'switch' or state.domain == 'remote' \
|
elif state.domain in ('switch', 'remote', 'input_boolean', 'script'):
|
||||||
or state.domain == 'input_boolean' or state.domain == 'script':
|
|
||||||
a_type = 'Switch'
|
a_type = 'Switch'
|
||||||
|
|
||||||
if a_type is None:
|
if a_type is None:
|
||||||
|
@ -68,14 +68,8 @@ class TestGetAccessories(unittest.TestCase):
|
|||||||
"""Test humidity sensor with device class humidity."""
|
"""Test humidity sensor with device class humidity."""
|
||||||
with patch.dict(TYPES, {'HumiditySensor': self.mock_type}):
|
with patch.dict(TYPES, {'HumiditySensor': self.mock_type}):
|
||||||
state = State('sensor.humidity', '20',
|
state = State('sensor.humidity', '20',
|
||||||
{ATTR_DEVICE_CLASS: 'humidity'})
|
{ATTR_DEVICE_CLASS: 'humidity',
|
||||||
get_accessory(None, state, 2, {})
|
ATTR_UNIT_OF_MEASUREMENT: '%'})
|
||||||
|
|
||||||
def test_sensor_humidity_unit(self):
|
|
||||||
"""Test humidity sensor with % as unit."""
|
|
||||||
with patch.dict(TYPES, {'HumiditySensor': self.mock_type}):
|
|
||||||
state = State('sensor.humidity', '20',
|
|
||||||
{ATTR_UNIT_OF_MEASUREMENT: '%'})
|
|
||||||
get_accessory(None, state, 2, {})
|
get_accessory(None, state, 2, {})
|
||||||
|
|
||||||
def test_air_quality_sensor(self):
|
def test_air_quality_sensor(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user