Revert API Microphone Mute Switch
This commit is contained in:
@@ -15,7 +15,6 @@ _OFF = (0, 0, 0)
|
|||||||
_BLUE = (0, 0, 255)
|
_BLUE = (0, 0, 255)
|
||||||
_YELLOW = (255, 255, 0)
|
_YELLOW = (255, 255, 0)
|
||||||
_GREEN = (0, 255, 0)
|
_GREEN = (0, 255, 0)
|
||||||
_DIM_RED = (50, 0, 0) # ADDED for Mute
|
|
||||||
|
|
||||||
|
|
||||||
class LedController(EventHandler):
|
class LedController(EventHandler):
|
||||||
@@ -34,6 +33,7 @@ class LedController(EventHandler):
|
|||||||
try:
|
try:
|
||||||
if interface == "gpio":
|
if interface == "gpio":
|
||||||
_LOGGER.debug(f"Initializing LEDs on GPIO data={data_pin}, clock={clock_pin}")
|
_LOGGER.debug(f"Initializing LEDs on GPIO data={data_pin}, clock={clock_pin}")
|
||||||
|
# Dynamically get GPIO pin objects from the board library
|
||||||
data_pin_obj = getattr(board, f"D{data_pin}")
|
data_pin_obj = getattr(board, f"D{data_pin}")
|
||||||
clock_pin_obj = getattr(board, f"D{clock_pin}")
|
clock_pin_obj = getattr(board, f"D{clock_pin}")
|
||||||
self.leds = adafruit_dotstar.DotStar(
|
self.leds = adafruit_dotstar.DotStar(
|
||||||
@@ -47,6 +47,7 @@ class LedController(EventHandler):
|
|||||||
|
|
||||||
self._is_ready = True
|
self._is_ready = True
|
||||||
_LOGGER.info(f"LED Controller initialized using {interface} interface.")
|
_LOGGER.info(f"LED Controller initialized using {interface} interface.")
|
||||||
|
# Signal that the system is ready
|
||||||
self.run_action("blink", _GREEN, 2)
|
self.run_action("blink", _GREEN, 2)
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
@@ -78,10 +79,12 @@ class LedController(EventHandler):
|
|||||||
try:
|
try:
|
||||||
r, g, b = color
|
r, g, b = color
|
||||||
while True:
|
while True:
|
||||||
|
# Fade in
|
||||||
for i in range(0, 101, 5):
|
for i in range(0, 101, 5):
|
||||||
brightness = i / 100.0
|
brightness = i / 100.0
|
||||||
await self.color((int(r * brightness), int(g * brightness), int(b * brightness)))
|
await self.color((int(r * brightness), int(g * brightness), int(b * brightness)))
|
||||||
await asyncio.sleep(speed)
|
await asyncio.sleep(speed)
|
||||||
|
# Fade out
|
||||||
for i in range(100, -1, -5):
|
for i in range(100, -1, -5):
|
||||||
brightness = i / 100.0
|
brightness = i / 100.0
|
||||||
await self.color((int(r * brightness), int(g * brightness), int(b * brightness)))
|
await self.color((int(r * brightness), int(g * brightness), int(b * brightness)))
|
||||||
@@ -89,8 +92,6 @@ class LedController(EventHandler):
|
|||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
await self.color(_OFF)
|
await self.color(_OFF)
|
||||||
|
|
||||||
# --- EVENT HANDLERS ---
|
|
||||||
|
|
||||||
@subscribe
|
@subscribe
|
||||||
def ha_connected(self, data: dict):
|
def ha_connected(self, data: dict):
|
||||||
_LOGGER.debug("HA Connected, setting idle LED state.")
|
_LOGGER.debug("HA Connected, setting idle LED state.")
|
||||||
@@ -109,6 +110,7 @@ class LedController(EventHandler):
|
|||||||
@subscribe
|
@subscribe
|
||||||
def voice_vad_start(self, data: dict):
|
def voice_vad_start(self, data: dict):
|
||||||
_LOGGER.debug("LED Event: voice_vad_start (user speaking)")
|
_LOGGER.debug("LED Event: voice_vad_start (user speaking)")
|
||||||
|
# Do nothing, allow the blue pulse to continue
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@subscribe
|
@subscribe
|
||||||
@@ -125,15 +127,3 @@ class LedController(EventHandler):
|
|||||||
def voice_run_end(self, data: dict):
|
def voice_run_end(self, data: dict):
|
||||||
_LOGGER.debug("LED Event: voice_run_end")
|
_LOGGER.debug("LED Event: voice_run_end")
|
||||||
self.run_action("color", _OFF)
|
self.run_action("color", _OFF)
|
||||||
|
|
||||||
# --- ADDED: Mute State Handlers ---
|
|
||||||
@subscribe
|
|
||||||
def mic_muted(self, data: dict):
|
|
||||||
_LOGGER.debug("LED Event: Mic muted")
|
|
||||||
self.run_action("color", _DIM_RED)
|
|
||||||
|
|
||||||
@subscribe
|
|
||||||
def mic_unmuted(self, data: dict):
|
|
||||||
_LOGGER.debug("LED Event: Mic unmuted")
|
|
||||||
# Return to the normal idle state (off)
|
|
||||||
self.voice_run_end(data)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user