Menus for DisplayOTron


Hi all,

Recently got some Phillips Hue lights so thought it’d be fun to try and use a Pi with the DisplayOTron to control them.

I’m using the phue library ( to interact with the lights and that all seems okay but I’m struggling to get a menu setup calling the relevant code from the Hue API.

Eventually I’d like to have nested menus so I could drill down from a top menu to control a single light but so far I’m struggling to get even the basics working.

So far I have something like this…

for l in lights:
menu.add_item("Switch on "+,process_light(

process_light function is -

def process_light(light):
print("You selected light " + light)

This builds up the menu correctly and displays it to the LED but I was hoping I could just get it to just print something to screen to confirm I’m passing the name of the light from the menu correctly but when I select the menu option nothing happens. Any ideas why?

I also tried the MenuOption class but I’m confused how I can pass into it the value which was selected as it doesnt look like MenuOption takes a parameter. This is the code I tried -

menu.add_item("Switch off " +,poweroff())

class poweroff(MenuOption):
def init(self):
self.start = self.millis()
def redraw(self, menu):
menu.write_row(0, ‘Switching off light’)

Not sure I explained that very well but any assistance on how to use the menus for the DisplayOTron would be much appreciated (I’ve looked at previous posts but no one seems to be building a dynamic menu on the fly like I’m trying to).



You can have a MenuOption derived class accept a parameter, a good example is the Volume() plugin which needs a backlight instance:

If you look at the code of the plugin itself, you can see that it saves this backlight object to a class variable for use later:

So in your case you could perhaps:

class poweroff(MenuOption):
    def __init__(self, current_led):
        self.current_led = current_led

    def begin(self):
        self.start_time = self.millis()

    def redraw(self, menu):
        menu.write_row(0, 'Switching off light {}'.format(
        if self.millis() - self.start_time > 1000:

menu.add_item("Switch off {}".format(, poweroff(l))

Although you should avoid doing anything but redrawing in redraw and instead hook into the up, down, left, right and select methods to provide menu items for turning the light ON/OFF and exiting the menu item.

Or, perhaps the plugin should take a list of LEDs and display one menu option for each.