Освещение¶
LightEntity¶
Управление освещением: яркость, цвет (HSV), цветовая температура.
Sber Light entity — maps HA light to Sber light category.
Supports brightness, color temperature, RGB color (HSV), and light mode. Uses LinearConverter for value range mapping and ColorConverter for HSV.
LIGHT_ENTITY_CATEGORY
module-attribute
¶
Sber device category for light entities.
COLOR_MODES
module-attribute
¶
HA color modes that map to Sber colour features.
LightEntity
¶
Bases: BaseEntity
Sber light entity with brightness, color, and color temperature support.
Maps HA light entities to the Sber 'light' category with support for: - On/off control - Brightness (scaled 0-255 HA ↔ 100-900 Sber) - Color temperature (mireds ↔ 0-1000 Sber, reversed) - RGB color via HSV conversion - Light mode (white / colour)
Initialize light entity from HA entity data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ha_entity_data
|
dict
|
HA entity registry dict. |
required |
Source code in custom_components/sber_mqtt_bridge/devices/light.py
fill_by_ha_state
¶
Parse HA state and update all light attributes.
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/light.py
create_features_list
¶
Return Sber feature list based on available light capabilities.
Dynamically includes color, brightness, and color temperature features only when the HA entity supports the corresponding color modes.
Returns:
| Type | Description |
|---|---|
list[str]
|
List of Sber feature strings supported by this entity. |
Source code in custom_components/sber_mqtt_bridge/devices/light.py
create_allowed_values_list
¶
Build allowed values map for light features.
Returns:
| Type | Description |
|---|---|
dict[str, dict]
|
Dict mapping feature key to its allowed values descriptor. |
Source code in custom_components/sber_mqtt_bridge/devices/light.py
create_dependencies
¶
Return light_colour → light_mode dependency when both features exist.
Returns:
| Type | Description |
|---|---|
dict[str, dict]
|
Dependencies dict for Sber model descriptor. |
Source code in custom_components/sber_mqtt_bridge/devices/light.py
to_sber_current_state
¶
Build Sber current state payload with all light attributes.
Includes online, on_off, brightness, color/color_temp, and light_mode depending on the current state and color mode.
Per Sber C2C specification, integer_value is serialized as a string.
Returns:
| Type | Description |
|---|---|
dict[str, dict]
|
Dict mapping entity_id to its Sber state representation. |
Source code in custom_components/sber_mqtt_bridge/devices/light.py
process_cmd
¶
Process Sber light commands and produce HA service calls.
Handles the following Sber keys:
- on_off: turn_on / turn_off
- light_brightness: set brightness via turn_on
- light_colour: set HSV color via turn_on
- light_mode: switch between white/colour mode (local state only)
- light_colour_temp: set color temperature via turn_on
Note: light_mode is tracked locally and triggers a state update
to Sber without a HA service call (HA does not have a mode concept).
State is NOT mutated here for on/off — it will be updated when HA fires
a state_changed event. However, light_mode is a Sber-only concept
and must be tracked locally.
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/light.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 | |
LedStripEntity¶
Светодиодная лента с поддержкой цвета и эффектов.
Sber LED Strip entity -- maps HA light entities to Sber led_strip category.
Identical to light in features and behavior, but uses the led_strip
Sber category for LED strip devices.
LED_STRIP_CATEGORY
module-attribute
¶
Sber device category for LED strip entities.
LedStripEntity
¶
Bases: LightEntity
Sber LED strip entity.
Inherits all light behavior (on/off, brightness, color, color temperature) but registers under the Sber 'led_strip' category.
Initialize LED strip entity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity_data
|
dict
|
HA entity registry dict containing entity metadata. |
required |