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