Add ability to set color. Added limited ability to set effect. The only effects that work are: blink, breathe, okay, channel_change. Added hex_to_RGB color
This commit is contained in:
@@ -92,3 +92,23 @@ class TapDial(Hass):
|
||||
self.log(f'2.2 {self.active_entity.friendly_name} is currently {onoff}')
|
||||
self.active_entity.toggle()
|
||||
self.log(f'2.2 Toggle on/off power to {self.active_entity.friendly_name}')
|
||||
|
||||
# This function was written by chatgpt!
|
||||
def hex_to_rgb(self, hex_color: str) -> list:
|
||||
|
||||
# Remove the "#" if it's included
|
||||
hex_color = hex_color.lstrip('#')
|
||||
|
||||
# Check if the string has a valid length
|
||||
if len(hex_color) != 6:
|
||||
raise ValueError(f"Invalid hex color: {hex_color}. Must be 6 characters long.")
|
||||
|
||||
try:
|
||||
# Split the hex color into its RGB components and convert to integers
|
||||
r = int(hex_color[0:2], 16)
|
||||
g = int(hex_color[2:4], 16)
|
||||
b = int(hex_color[4:6], 16)
|
||||
return [r, g, b]
|
||||
except ValueError:
|
||||
raise ValueError(f"Invalid hex color: {hex_color}. Must contain only valid hex digits.")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user