Can someone help me with changing icons based on status?

So, I currently have control of my Phillips Hue lights from my touchbar using Phue and HueKey. Its working perfectly, but it'd be really nice to have the icon change depending on the on/off status of the Hue lights. Phue can report the status for me, and I can tie this into a command/script that BTT can trigger (thats how the lights turn on and off currently), but I have no idea how to go about programming that to make it happen. Im assuming in my script, I can create a boolean that changes its value based upon the return status, but how can i get BTT to recognize the value of that particular varibable in a random script? How can BTT change to an alternate icon based upon the return status of a variable from a script?


Again... Alternate Color Regex:

from phue import Bridge

b = Bridge('192.168.1.15')

lights = b.get_light_objects('id')

light_names = b.get_light_objects('name')

light_list = b.get_light_objects('list')

def mb_light_status():
if b.get_light(6, 'on') is False and b.get_light(7, 'on') is False and b.get_light(5, 'on') is False:
    return False
    print("False")
else:
    return True
    print("True")

mb_light_status()

This is the python im trying to run, launch path is /usr/bin/python, parameters is -c, when i try to run the script it doesnt return anything. Can BTT run scripts like this dependent on another program?

Turns out I just needed to remove the return statements, BTT is looking for the console output so by returning, it was never printing

edit: while this works, this also changes the Widget Identifier to whatever you print. Any way I can keep the original text but merely change the color/icon based on the regex?

2nd edit: figured this out..again...itd help if i had read:
In the script you can either return a simple string which will then be shown on the widget, or you can return a JSON string like this (must be escaped):
"{"text":"newTitle",
"icon_data": "base64_icon_data",
"icon_path":"path_to_new_icon",
"background_color": "255,85,100,255",
"font_color": "100,200,100,255",
"font_size": 10}"

1 Like