Home Assistant Unofficial Reference 2024.12.1
ipdb.py
Go to the documentation of this file.
1 """Utility methods for the Insteon platform."""
2 
3 from collections.abc import Iterable
4 
5 from pyinsteon.device_types.device_base import Device
6 from pyinsteon.device_types.ipdb import (
7  AccessControl_Morningstar,
8  ClimateControl_Thermostat,
9  ClimateControl_WirelessThermostat,
10  DimmableLightingControl,
11  DimmableLightingControl_Dial,
12  DimmableLightingControl_DinRail,
13  DimmableLightingControl_FanLinc,
14  DimmableLightingControl_I3_KeypadLinc_4,
15  DimmableLightingControl_InLineLinc01,
16  DimmableLightingControl_InLineLinc02,
17  DimmableLightingControl_KeypadLinc_6,
18  DimmableLightingControl_KeypadLinc_8,
19  DimmableLightingControl_LampLinc,
20  DimmableLightingControl_OutletLinc,
21  DimmableLightingControl_SwitchLinc01,
22  DimmableLightingControl_SwitchLinc02,
23  DimmableLightingControl_ToggleLinc,
24  EnergyManagement_LoadController,
25  SecurityHealthSafety_DoorSensor,
26  SecurityHealthSafety_LeakSensor,
27  SecurityHealthSafety_MotionSensor,
28  SecurityHealthSafety_OpenCloseSensor,
29  SecurityHealthSafety_Smokebridge,
30  SensorsActuators_IOLink,
31  SwitchedLightingControl,
32  SwitchedLightingControl_ApplianceLinc,
33  SwitchedLightingControl_DinRail,
34  SwitchedLightingControl_I3Outlet,
35  SwitchedLightingControl_InLineLinc01,
36  SwitchedLightingControl_InLineLinc02,
37  SwitchedLightingControl_KeypadLinc_6,
38  SwitchedLightingControl_KeypadLinc_8,
39  SwitchedLightingControl_OnOffOutlet,
40  SwitchedLightingControl_OutletLinc,
41  SwitchedLightingControl_SwitchLinc01,
42  SwitchedLightingControl_SwitchLinc02,
43  SwitchedLightingControl_ToggleLinc,
44  WindowCovering,
45  X10Dimmable,
46  X10OnOff,
47  X10OnOffSensor,
48 )
49 
50 from homeassistant.const import Platform
51 
52 DEVICE_PLATFORM: dict[Device, dict[Platform, Iterable[int]]] = {
53  AccessControl_Morningstar: {Platform.LOCK: [1]},
54  DimmableLightingControl: {Platform.LIGHT: [1]},
55  DimmableLightingControl_Dial: {Platform.LIGHT: [1]},
56  DimmableLightingControl_DinRail: {Platform.LIGHT: [1]},
57  DimmableLightingControl_FanLinc: {Platform.LIGHT: [1], Platform.FAN: [2]},
58  DimmableLightingControl_InLineLinc01: {Platform.LIGHT: [1]},
59  DimmableLightingControl_InLineLinc02: {Platform.LIGHT: [1]},
60  DimmableLightingControl_I3_KeypadLinc_4: {
61  Platform.LIGHT: [1, 2, 3, 4],
62  },
63  DimmableLightingControl_KeypadLinc_6: {
64  Platform.LIGHT: [1],
65  Platform.SWITCH: [3, 4, 5, 6],
66  },
67  DimmableLightingControl_KeypadLinc_8: {
68  Platform.LIGHT: [1],
69  Platform.SWITCH: range(2, 9),
70  },
71  DimmableLightingControl_LampLinc: {Platform.LIGHT: [1]},
72  DimmableLightingControl_OutletLinc: {Platform.LIGHT: [1]},
73  DimmableLightingControl_SwitchLinc01: {Platform.LIGHT: [1]},
74  DimmableLightingControl_SwitchLinc02: {Platform.LIGHT: [1]},
75  DimmableLightingControl_ToggleLinc: {Platform.LIGHT: [1]},
76  EnergyManagement_LoadController: {
77  Platform.SWITCH: [1],
78  Platform.BINARY_SENSOR: [2],
79  },
80  SecurityHealthSafety_DoorSensor: {Platform.BINARY_SENSOR: [1, 3, 4]},
81  SecurityHealthSafety_LeakSensor: {Platform.BINARY_SENSOR: [2, 4]},
82  SecurityHealthSafety_MotionSensor: {Platform.BINARY_SENSOR: [1, 2, 3]},
83  SecurityHealthSafety_OpenCloseSensor: {Platform.BINARY_SENSOR: [1]},
84  SecurityHealthSafety_Smokebridge: {Platform.BINARY_SENSOR: [1, 2, 3, 4, 6, 7]},
85  SensorsActuators_IOLink: {Platform.SWITCH: [1], Platform.BINARY_SENSOR: [2]},
86  SwitchedLightingControl: {Platform.SWITCH: [1]},
87  SwitchedLightingControl_ApplianceLinc: {Platform.SWITCH: [1]},
88  SwitchedLightingControl_DinRail: {Platform.SWITCH: [1]},
89  SwitchedLightingControl_I3Outlet: {Platform.SWITCH: [1, 2]},
90  SwitchedLightingControl_InLineLinc01: {Platform.SWITCH: [1]},
91  SwitchedLightingControl_InLineLinc02: {Platform.SWITCH: [1]},
92  SwitchedLightingControl_KeypadLinc_6: {
93  Platform.SWITCH: [1, 3, 4, 5, 6],
94  },
95  SwitchedLightingControl_KeypadLinc_8: {
96  Platform.SWITCH: range(1, 9),
97  },
98  SwitchedLightingControl_OnOffOutlet: {Platform.SWITCH: [1, 2]},
99  SwitchedLightingControl_OutletLinc: {Platform.SWITCH: [1]},
100  SwitchedLightingControl_SwitchLinc01: {Platform.SWITCH: [1]},
101  SwitchedLightingControl_SwitchLinc02: {Platform.SWITCH: [1]},
102  SwitchedLightingControl_ToggleLinc: {Platform.SWITCH: [1]},
103  ClimateControl_Thermostat: {Platform.CLIMATE: [1]},
104  ClimateControl_WirelessThermostat: {Platform.CLIMATE: [1]},
105  WindowCovering: {Platform.COVER: [1]},
106  X10Dimmable: {Platform.LIGHT: [1]},
107  X10OnOff: {Platform.SWITCH: [1]},
108  X10OnOffSensor: {Platform.BINARY_SENSOR: [1]},
109 }
110 
111 
112 def get_device_platforms(device) -> dict[Platform, Iterable[int]]:
113  """Return the HA platforms for a device type."""
114  return DEVICE_PLATFORM.get(type(device), {})
115 
116 
117 def get_device_platform_groups(device: Device, platform: Platform) -> Iterable[int]:
118  """Return the list of device groups for a platform."""
119  return get_device_platforms(device).get(platform, [])
web.Response get(self, web.Request request, str config_key)
Definition: view.py:88
dict[Platform, Iterable[int]] get_device_platforms(device)
Definition: ipdb.py:112
Iterable[int] get_device_platform_groups(Device device, Platform platform)
Definition: ipdb.py:117