Merge pull request #307 from chirag350/led-strips/zengge-magichome

This commit is contained in:
Shaun Eccles-Smith 2023-03-18 15:57:39 +11:00 committed by GitHub
commit 22324f0511
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 1 deletions

49
devices/zengee.py Normal file
View File

@ -0,0 +1,49 @@
import logging
import flux_led
import numpy as np
import voluptuous as vol
from ledfx.devices import NetworkedDevice
_LOGGER = logging.getLogger(__name__)
class ZenggeDevice(NetworkedDevice):
"""Zengge/MagicHome/FluxLED device support"""
CONFIG_SCHEMA = vol.Schema(
{
vol.Required(
"ip_address",
description="Hostname or IP address of the device",
): str,
vol.Required(
"pixel_count",
description="Number of individual pixels",
default=1,
): vol.All(int, vol.Range(min=1)),
}
)
def __init__(self, ledfx, config):
super().__init__(ledfx, config)
self._device_type = "Zengge/MagicHome/FluxLED"
self.bulb = flux_led.WifiLedBulb(config["ip_address"])
def activate(self):
super().activate()
self.bulb.turnOn()
def deactivate(self):
super().deactivate()
self.bulb.turnOff()
def flush(self, data):
try:
byteData = data.astype(np.dtype("B"))
rgb = byteData.flatten().tolist()
self.bulb.setRgb(rgb[0], rgb[1], rgb[2])
except Exception as e:
_LOGGER.error("Error connecting to bulb: %s", e)

View File

@ -26,4 +26,5 @@
tcp-latency~=0.0.10
voluptuous~=0.12.1
yappi~=1.3.3
zeroconf~=0.39.4
flux_led==0.28.35
zeroconf~=0.39.4