All checks were successful
ci/woodpecker/tag/build/5 Pipeline was successful
ci/woodpecker/tag/build/6 Pipeline was successful
ci/woodpecker/tag/build/1 Pipeline was successful
ci/woodpecker/tag/build/4 Pipeline was successful
ci/woodpecker/tag/namespace Pipeline was successful
ci/woodpecker/tag/build/2 Pipeline was successful
ci/woodpecker/tag/build/3 Pipeline was successful
ci/woodpecker/tag/config Pipeline was successful
ci/woodpecker/tag/build/7 Pipeline was successful
ci/woodpecker/tag/deploy/2 Pipeline was successful
ci/woodpecker/tag/deploy/3 Pipeline was successful
ci/woodpecker/tag/deploy/5 Pipeline was successful
ci/woodpecker/tag/deploy/4 Pipeline was successful
ci/woodpecker/tag/deploy/6 Pipeline was successful
ci/woodpecker/tag/deploy/1 Pipeline was successful
ci/woodpecker/tag/ingress Pipeline was successful
47 lines
1.1 KiB
Python
47 lines
1.1 KiB
Python
"""Hottis LED Stripe vendor transformations."""
|
|
|
|
import logging
|
|
from typing import Any
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
def transform_light_to_vendor(payload: dict[str, Any]) -> str:
|
|
"""Transform abstract relay payload to Hottis LED Stripe format.
|
|
|
|
Hottis LED Stripe expects plain text 'on' or 'off' (not JSON).
|
|
|
|
Example:
|
|
- Abstract: {'power': 'on'}
|
|
- Hottis LED Stripe: 'ON'
|
|
"""
|
|
|
|
bri = 89.0 / 254.0
|
|
r = int(255 * bri)
|
|
g = int(103 * bri)
|
|
b = int(25 * bri)
|
|
|
|
cmd = f"{r} {g} {b}" if payload.get("power", "off").lower() == "on" else "0 0 0"
|
|
return cmd
|
|
|
|
|
|
def transform_light_to_abstract(payload: str) -> dict[str, Any]:
|
|
"""Transform Hottis LED Stripe relay payload to abstract format.
|
|
|
|
Hottis LED Stripe sends plain text 'on' or 'off'.
|
|
|
|
Example:
|
|
- Hottis LED Stripe: 'ON'
|
|
- Abstract: {'power': 'on'}
|
|
"""
|
|
|
|
power = "on" if payload.strip() != "0 0 0" else "off"
|
|
return {"power": power}
|
|
|
|
|
|
# Registry of handlers for this vendor
|
|
HANDLERS = {
|
|
("light", "to_vendor"): transform_light_to_vendor,
|
|
("light", "to_abstract"): transform_light_to_abstract,
|
|
}
|