mirror of
https://github.com/home-assistant/core.git
synced 2025-08-04 13:15:18 +02:00
MySensors: Fewer comments in const.py
This commit is contained in:
@@ -44,23 +44,24 @@ UPDATE_DELAY: float = 0.1
|
||||
SERVICE_SEND_IR_CODE: str = "send_ir_code"
|
||||
|
||||
SensorType = str
|
||||
"""S_DOOR, S_MOTION, S_SMOKE, ..."""
|
||||
# S_DOOR, S_MOTION, S_SMOKE, ...
|
||||
|
||||
ValueType = str
|
||||
"""V_TRIPPED, V_ARMED, V_STATUS, V_PERCENTAGE, ..."""
|
||||
# V_TRIPPED, V_ARMED, V_STATUS, V_PERCENTAGE, ...
|
||||
|
||||
GatewayId = str
|
||||
"""a unique id generated by config_flow.py and stored in the ConfigEntry as the entry id.
|
||||
# a unique id generated by config_flow.py and stored in the ConfigEntry as the entry id.
|
||||
#
|
||||
# Gateway may be fetched by giving the gateway id to get_mysensors_gateway()
|
||||
|
||||
Gateway may be fetched by giving the gateway id to get_mysensors_gateway()
|
||||
"""
|
||||
DevId = Tuple[GatewayId, int, int, int]
|
||||
"""describes the backend of a hass entity. Contents are: GatewayId, node_id, child_id, v_type as int
|
||||
|
||||
The string version of v_type can be looked up in the enum gateway.const.SetReq of the appropriate BaseAsyncGateway
|
||||
Home Assistant Entities are quite limited and only ever do one thing.
|
||||
MySensors Nodes have multiple child_ids each with a s_type several associated v_types
|
||||
The MySensors integration brings these together by creating an entity for every v_type of every child_id of every node.
|
||||
The DevId tuple perfectly captures this.
|
||||
"""
|
||||
# describes the backend of a hass entity. Contents are: GatewayId, node_id, child_id, v_type as int
|
||||
#
|
||||
# The string version of v_type can be looked up in the enum gateway.const.SetReq of the appropriate BaseAsyncGateway
|
||||
# Home Assistant Entities are quite limited and only ever do one thing.
|
||||
# MySensors Nodes have multiple child_ids each with a s_type several associated v_types
|
||||
# The MySensors integration brings these together by creating an entity for every v_type of every child_id of every node.
|
||||
# The DevId tuple perfectly captures this.
|
||||
|
||||
BINARY_SENSOR_TYPES: Dict[SensorType, Set[ValueType]] = {
|
||||
"S_DOOR": {"V_TRIPPED"},
|
||||
@@ -144,20 +145,15 @@ PLATFORM_TYPES: Dict[str, Dict[SensorType, Set[ValueType]]] = {
|
||||
"sensor": SENSOR_TYPES,
|
||||
"switch": SWITCH_TYPES,
|
||||
}
|
||||
"""dict mapping hass platform name to dict that maps mysensors s_type to set of mysensors v_type"""
|
||||
|
||||
FLAT_PLATFORM_TYPES: Dict[Tuple[str, SensorType], Set[ValueType]] = {
|
||||
(platform, s_type_name): v_type_name
|
||||
for platform, platform_types in PLATFORM_TYPES.items()
|
||||
for s_type_name, v_type_name in platform_types.items()
|
||||
}
|
||||
"""flatter version of PLATFORM_TYPES
|
||||
|
||||
dict mapping tuples of hass platform name and mysensors s_type to mysensors v_type
|
||||
"""
|
||||
|
||||
TYPE_TO_PLATFORMS: Dict[SensorType, List[str]] = defaultdict(list)
|
||||
"""dict mapping mysensors s_type to list of hass platform name"""
|
||||
|
||||
for platform, platform_types in PLATFORM_TYPES.items():
|
||||
for s_type_name in platform_types:
|
||||
TYPE_TO_PLATFORMS[s_type_name].append(platform)
|
||||
|
Reference in New Issue
Block a user