mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Use upstream constants when defining homekit service to platform mapping (#65272)
This commit is contained in:
parent
58f624a3da
commit
eb94fe1ca7
@ -494,7 +494,11 @@ class HKDevice:
|
||||
tasks = []
|
||||
for accessory in self.accessories:
|
||||
for service in accessory["services"]:
|
||||
stype = ServicesTypes.get_short(service["type"].upper())
|
||||
try:
|
||||
stype = ServicesTypes.get_short_uuid(service["type"].upper())
|
||||
except KeyError:
|
||||
stype = service["type"].upper()
|
||||
|
||||
if stype in HOMEKIT_ACCESSORY_DISPATCH:
|
||||
platform = HOMEKIT_ACCESSORY_DISPATCH[stype]
|
||||
if platform not in self.platforms:
|
||||
|
@ -2,6 +2,7 @@
|
||||
from typing import Final
|
||||
|
||||
from aiohomekit.model.characteristics import CharacteristicsTypes
|
||||
from aiohomekit.model.services import ServicesTypes
|
||||
|
||||
DOMAIN = "homekit_controller"
|
||||
|
||||
@ -20,33 +21,33 @@ IDENTIFIER_LEGACY_ACCESSORY_ID = "accessory-id"
|
||||
|
||||
# Mapping from Homekit type to component.
|
||||
HOMEKIT_ACCESSORY_DISPATCH = {
|
||||
"lightbulb": "light",
|
||||
"outlet": "switch",
|
||||
"switch": "switch",
|
||||
"thermostat": "climate",
|
||||
"heater-cooler": "climate",
|
||||
"security-system": "alarm_control_panel",
|
||||
"garage-door-opener": "cover",
|
||||
"window": "cover",
|
||||
"window-covering": "cover",
|
||||
"lock-mechanism": "lock",
|
||||
"contact": "binary_sensor",
|
||||
"motion": "binary_sensor",
|
||||
"carbon-dioxide": "sensor",
|
||||
"humidity": "sensor",
|
||||
"humidifier-dehumidifier": "humidifier",
|
||||
"light": "sensor",
|
||||
"temperature": "sensor",
|
||||
"battery": "sensor",
|
||||
"smoke": "binary_sensor",
|
||||
"carbon-monoxide": "binary_sensor",
|
||||
"leak": "binary_sensor",
|
||||
"fan": "fan",
|
||||
"fanv2": "fan",
|
||||
"occupancy": "binary_sensor",
|
||||
"television": "media_player",
|
||||
"valve": "switch",
|
||||
"camera-rtp-stream-management": "camera",
|
||||
ServicesTypes.LIGHTBULB: "light",
|
||||
ServicesTypes.OUTLET: "switch",
|
||||
ServicesTypes.SWITCH: "switch",
|
||||
ServicesTypes.THERMOSTAT: "climate",
|
||||
ServicesTypes.HEATER_COOLER: "climate",
|
||||
ServicesTypes.SECURITY_SYSTEM: "alarm_control_panel",
|
||||
ServicesTypes.GARAGE_DOOR_OPENER: "cover",
|
||||
ServicesTypes.WINDOW: "cover",
|
||||
ServicesTypes.WINDOW_COVERING: "cover",
|
||||
ServicesTypes.LOCK_MECHANISM: "lock",
|
||||
ServicesTypes.CONTACT_SENSOR: "binary_sensor",
|
||||
ServicesTypes.MOTION_SENSOR: "binary_sensor",
|
||||
ServicesTypes.CARBON_DIOXIDE_SENSOR: "sensor",
|
||||
ServicesTypes.HUMIDITY_SENSOR: "sensor",
|
||||
ServicesTypes.HUMIDIFIER_DEHUMIDIFIER: "humidifier",
|
||||
ServicesTypes.LIGHT_SENSOR: "sensor",
|
||||
ServicesTypes.TEMPERATURE_SENSOR: "sensor",
|
||||
ServicesTypes.BATTERY_SERVICE: "sensor",
|
||||
ServicesTypes.SMOKE_SENSOR: "binary_sensor",
|
||||
ServicesTypes.CARBON_MONOXIDE_SENSOR: "binary_sensor",
|
||||
ServicesTypes.LEAK_SENSOR: "binary_sensor",
|
||||
ServicesTypes.FAN: "fan",
|
||||
ServicesTypes.FAN_V2: "fan",
|
||||
ServicesTypes.OCCUPANCY_SENSOR: "binary_sensor",
|
||||
ServicesTypes.TELEVISION: "media_player",
|
||||
ServicesTypes.VALVE: "switch",
|
||||
ServicesTypes.CAMERA_RTP_STREAM_MANAGEMENT: "camera",
|
||||
}
|
||||
|
||||
CHARACTERISTIC_PLATFORMS = {
|
||||
|
@ -230,7 +230,7 @@ async def setup_test_component(hass, setup_accessory, capitalize=False, suffix=N
|
||||
|
||||
domain = None
|
||||
for service in accessory.services:
|
||||
service_name = ServicesTypes.get_short(service.type)
|
||||
service_name = ServicesTypes.get_short_uuid(service.type)
|
||||
if service_name in HOMEKIT_ACCESSORY_DISPATCH:
|
||||
domain = HOMEKIT_ACCESSORY_DISPATCH[service_name]
|
||||
break
|
||||
|
Loading…
x
Reference in New Issue
Block a user