mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 05:37:44 +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)
|
||||
device_class = state.attributes.get(ATTR_DEVICE_CLASS)
|
||||
|
||||
if device_class == DEVICE_CLASS_TEMPERATURE or unit == TEMP_CELSIUS \
|
||||
or unit == TEMP_FAHRENHEIT:
|
||||
if device_class == DEVICE_CLASS_TEMPERATURE or \
|
||||
unit in (TEMP_CELSIUS, TEMP_FAHRENHEIT):
|
||||
a_type = 'TemperatureSensor'
|
||||
elif device_class == DEVICE_CLASS_HUMIDITY or unit == '%':
|
||||
elif device_class == DEVICE_CLASS_HUMIDITY and unit == '%':
|
||||
a_type = 'HumiditySensor'
|
||||
elif device_class == DEVICE_CLASS_PM25 \
|
||||
or DEVICE_CLASS_PM25 in state.entity_id:
|
||||
@ -141,8 +141,7 @@ def get_accessory(hass, state, aid, config):
|
||||
unit == 'lux' or unit == 'lx':
|
||||
a_type = 'LightSensor'
|
||||
|
||||
elif state.domain == 'switch' or state.domain == 'remote' \
|
||||
or state.domain == 'input_boolean' or state.domain == 'script':
|
||||
elif state.domain in ('switch', 'remote', 'input_boolean', 'script'):
|
||||
a_type = 'Switch'
|
||||
|
||||
if a_type is None:
|
||||
|
@ -68,14 +68,8 @@ class TestGetAccessories(unittest.TestCase):
|
||||
"""Test humidity sensor with device class humidity."""
|
||||
with patch.dict(TYPES, {'HumiditySensor': self.mock_type}):
|
||||
state = State('sensor.humidity', '20',
|
||||
{ATTR_DEVICE_CLASS: 'humidity'})
|
||||
get_accessory(None, state, 2, {})
|
||||
|
||||
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: '%'})
|
||||
{ATTR_DEVICE_CLASS: 'humidity',
|
||||
ATTR_UNIT_OF_MEASUREMENT: '%'})
|
||||
get_accessory(None, state, 2, {})
|
||||
|
||||
def test_air_quality_sensor(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user