Popcorn Time

I’ve have benefited from the forums for a number of years so wanted to give back with a little example project of mine… Automated Popcorn Maker.

(Please note this is for OpenHAB 2.x as I have been a little reluctant to jump into the OpenHAB 3 pool.)

So…I have a small popcorn maker beside the TV I ocassionally fill with kernals for movie nights.
It’s plugged into a Sonoff outlet that is triggered by pressing a little 433Mhz button linked to aSonoff RFBridge. When OpenHAB gets an activation request from the bridge sends an ON command to the switch via MQTT.

While the Popcorn Maker is in the OFF state the sitemap shows an icon called popcornmaker-off which represents a dimly lit machine in standby

Turning on the maker starts a 5 minute timer and immediately hides the power switch and replacing the icon with a working lit machine. The switch is unavailable so that the process can’t be restarted or cancelled by mistake. (I have an emergency override in that appears on my sitemap for safety)

When cooking is finished the sitemap replaces the popcorn_maker_working icon with the popcorn_maker_done icon.

It then starts a 3 minute cooldown counter that when expired resets everything.

I also have a picture called popcorn.png in my HTML folder and this gets displayed on the TV screen via a chromecase. I have left the code in but commented it out. Just as a little bit extra fun. I have the lion roar movie clip play at the beginning of the cooldown time… all ready for me to cast the movie!

Fun Times


Step One: Save all these images in your icons\classic folder.

popcornmaker-off = popcornmaker-off.svg popcornmaker = popcornmaker-on.svg

popcorn_maker_working = popcorn_maker_working.svg popcorn_maker_done popcorn_maker_done.svg


Step Two: Add these to your ITEMS file

Switch Popcorn_maker_power             "Popcorn Maker"                     { ga="Outlet" [ inverted=false ], mqtt="<[tameion:stat/Popcorn_Maker/POWER:state:default], >[tameion:cmnd/Popcorn_Maker/POWER:command:*:default]" } 
String Popcorn_time                    "Turn on the Popcorn Maker"         { ga="Outlet" [ inverted=false ], mqtt="<[tameion:stat/Popcorn_Time:state:default], >[tameion:cmnd/Popcorn_Time:command:*:default]" } 
Switch Popcorn_maker_countdown_timer   "Popcorn Maker Runtime"             {expire="5m, command=OFF"}
Switch Popcorn_maker_done              "Popcorn Maker cooldown period"     {expire="2m, command=OFF"}

You will


Step Three: Add these to a RULES file

rule "Popcorn Maker"
      when
        Item Popcorn_time received command ON
      then
        logInfo("INFO", "[SCRIPT: Places - Workshop] [ RULE: Popcorn Maker")	
        say("Excellent idea - I shall make the popcorn now, Sir!")
        Thread::sleep(10000) // Let him finish speaking
        sendCommand(Popcorn_maker_countdown_timer, "ON") // start the cooking timer
        Popcorn_maker_power.sendCommand(ON)
        // chromecast_chromecast_[YOUR ID]_playuri.sendCommand("http://localhost:8080/static/Popcorn.png")
    end


  rule "Popcorn Maker Power down & Cool down"
      when
        Item Popcorn_maker_countdown_timer received command OFF
      then
        logInfo("INFO", "[SCRIPT: Places - Workshop] [ RULE: Popcorn Maker Timer shut down")	
        sendCommand(Popcorn_maker_power, "OFF")
        sendCommand(Popcorn_maker_done, "ON") // Start popcorn cooldown timer
        say("Just letting it cool down, sir")
    end


  rule "Popcorn Maker Cooldown"
      when
        Item Popcorn_maker_done received command OFF
      then
        logInfo("INFO", "[SCRIPT: Places - Workshop] [ RULE: Popcorn all finished, sir - I hope you like it!!")	
        say("Popcorn all finished, sir - I hope you like it!!")
        sendCommand(Popcorn_time, "OFF")
        chromecast_chromecast_[YOUR_ID]_playuri.sendCommand("Stop")
    end



Step Four: Add these to your SITEMAP file

Switch item=Arcade_console_power icon=arcade
Switch item=Popcorn_time label="Popcorn Maker" icon=popcornmaker visibility=[Popcorn_time=="OFF"]			
Text label="Popcorn - I'm making it..." icon=popcorn_maker_working visibility=[Popcorn_maker_power=="ON"]
Text label="Popcorn - Just letting it cool" icon=popcorn_maker_done visibility=[Popcorn_maker_done=="ON"]

So I hope it works for you. I’ve had fun doing this and the kids think it’s just great. We trigger it with the voice command, “It’s Movie Time”

Let me know if you use it OR how we could improve it - I would love the encouragement !

7 Likes

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.