Реле и розетки¶
RelayEntity¶
Реле: switch, script, button (on/off управление).
Sber Relay entity -- maps HA switch/script/button to Sber relay category.
RELAY_CATEGORY
module-attribute
¶
Sber device category for relay/switch entities.
RelayEntity
¶
RelayEntity(entity_data, category=RELAY_CATEGORY)
Bases: OnOffEntity
Sber relay entity for on/off control devices.
Maps HA switch, script, and button entities to the Sber 'relay' category.
Supports basic on/off toggling via the on_off Sber feature.
Initialize relay entity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity_data
|
dict
|
HA entity registry dict containing entity metadata. |
required |
category
|
str
|
Sber device category (override in subclasses). |
RELAY_CATEGORY
|
Source code in custom_components/sber_mqtt_bridge/devices/relay.py
process_cmd
¶
Process Sber on/off command and produce HA service calls.
Handles the on_off key to generate turn_on/turn_off (or
press for button domain) service calls.
State is NOT mutated here — it will be updated when HA fires a
state_changed event that is handled by fill_by_ha_state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cmd_data
|
dict
|
Sber command dict with 'states' list. |
required |
Returns:
| Type | Description |
|---|---|
list[dict]
|
List of HA service call dicts to execute. |
Source code in custom_components/sber_mqtt_bridge/devices/relay.py
SocketEntity¶
Умная розетка.
Sber Socket entity -- maps HA outlet switches to Sber socket category.
SOCKET_CATEGORY
module-attribute
¶
Sber device category for smart socket/outlet entities.
SocketEntity
¶
Bases: RelayEntity
Sber socket entity for smart outlet/plug devices.
Inherits all relay behavior (on/off control) but registers under the Sber 'socket' category instead of 'relay'.
Initialize socket entity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity_data
|
dict
|
HA entity registry dict containing entity metadata. |
required |
Source code in custom_components/sber_mqtt_bridge/devices/socket_entity.py
ValveEntity¶
Клапан (водоснабжение, газ).
Sber Valve entity -- maps HA valve entities to Sber valve category.
Uses open_set/open_state features (NOT on_off).
Per Sber specification, valve is controlled via ENUM open/close/stop commands.
Supports optional battery and signal strength reporting.
ValveEntity
¶
Bases: BaseEntity
Sber valve entity for open/close valve control.
Maps HA valve entities to the Sber 'valve' category.
Uses open_set (command) and open_state (state) features
per Sber specification. Does NOT use on_off.
Optionally reports battery_percentage, battery_low_power,
and signal_strength when the HA entity provides these attributes.
Initialize valve entity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity_data
|
dict
|
HA entity registry dict containing entity metadata. |
required |
Source code in custom_components/sber_mqtt_bridge/devices/valve.py
fill_by_ha_state
¶
Parse HA state and update open/close status, battery, and signal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ha_state
|
dict
|
HA state dict with 'state' and 'attributes' keys. |
required |
Source code in custom_components/sber_mqtt_bridge/devices/valve.py
update_linked_data
¶
Inject data from a linked entity (battery, battery_low, signal).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
role
|
str
|
Link role name. |
required |
ha_state
|
dict
|
HA state dict with 'state'. |
required |
Source code in custom_components/sber_mqtt_bridge/devices/valve.py
create_features_list
¶
Return Sber feature list with open_set, open_state, and optional battery/signal.
Returns:
| Type | Description |
|---|---|
list[str]
|
List of Sber feature strings supported by this entity. |
Source code in custom_components/sber_mqtt_bridge/devices/valve.py
create_allowed_values_list
¶
Return allowed values for the open_set feature.
Source code in custom_components/sber_mqtt_bridge/devices/valve.py
to_sber_current_state
¶
Build Sber current state payload with online, open_state, battery, and signal.
Returns:
| Type | Description |
|---|---|
dict[str, dict]
|
Dict mapping entity_id to its Sber state representation. |
Source code in custom_components/sber_mqtt_bridge/devices/valve.py
process_cmd
¶
Process Sber open_set command and produce HA valve service calls.
Maps open_set ENUM values:
- "open" -> open_valve
- "close" -> close_valve
- "stop" -> stop_valve
State is NOT mutated here -- it will be updated when HA fires a
state_changed event that is handled by fill_by_ha_state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cmd_data
|
dict
|
Sber command dict with 'states' list. |
required |
Returns:
| Type | Description |
|---|---|
list[dict]
|
List of HA service call dicts to execute. |
Source code in custom_components/sber_mqtt_bridge/devices/valve.py
ScenarioButtonEntity¶
Кнопка сценария (input_boolean).
Sber Scenario Button entity -- maps HA input_boolean to Sber scenario_button.
SCENARIO_BUTTON_CATEGORY
module-attribute
¶
Sber device category for scenario button entities.
ScenarioButtonEntity
¶
Bases: BaseEntity
Sber scenario button entity.
Maps HA input_boolean entities to the Sber 'scenario_button' category.
Reports button events (click / double_click) based on the boolean state.
Initialize scenario button entity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity_data
|
dict
|
HA entity registry dict containing entity metadata. |
required |
Source code in custom_components/sber_mqtt_bridge/devices/scenario_button.py
fill_by_ha_state
¶
Parse HA state and update button event type.
Maps 'on' to 'click' and anything else to 'double_click'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ha_state
|
dict
|
HA state dict with 'state' key. |
required |
Source code in custom_components/sber_mqtt_bridge/devices/scenario_button.py
create_features_list
¶
Return Sber feature list including 'button_event'.
Returns:
| Type | Description |
|---|---|
list[str]
|
List of Sber feature strings supported by this entity. |
Source code in custom_components/sber_mqtt_bridge/devices/scenario_button.py
create_allowed_values_list
¶
Return allowed values for button_event feature.
Source code in custom_components/sber_mqtt_bridge/devices/scenario_button.py
to_sber_current_state
¶
Build Sber current state payload with online and button_event keys.
Returns:
| Type | Description |
|---|---|
dict[str, dict]
|
Dict mapping entity_id to its Sber state representation. |
Source code in custom_components/sber_mqtt_bridge/devices/scenario_button.py
process_cmd
¶
Process Sber command (no-op for scenario button).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cmd_data
|
dict
|
Sber command dict (ignored). |
required |
Returns:
| Type | Description |
|---|---|
list[dict]
|
Empty list -- scenario buttons are read-only. |