openHAB: Turn display on and off for a Video ChromeCast

Posted by ads on Sunday, 2020-07-05
Posted in [Ansible][Linux][Openhab]

After figuring out if a ChromeCast is currently used, it was time to fix a long-standing problem. At home we don’t have TVs, just “dumb” displays, and stream content using ChromeCasts. However a video ChromeCast never really turns off, but keeps the display running, using a Backdrop app. This app keeps showing pictures on the display when the ChromeCast is not used otherwise, effectively preventing any powersafe mode.

That’s both annoying (who wants to have pictures shown in the living room or working room all night), and consumes energy. It’s also intentional by Google. So far we had to turn the display on and off manually, which is inconvenient.

Using the newly acquired status information, and a smart plug, I switch the screen on and off whenever needed. I hooked up a Xiaomi Smart Plug (Amazon link without tracking id) to my openHAB system, and I’m using the Raspbee Zigbee bridge to switch the Smart Plug on and off.

Smart Plug, still wrapped
Smart Plug, still wrapped

Smart Plug, unwrapped
Smart Plug, unwrapped

Most of the work is already done in the ChromeCast monitoring rule, all I have is to monitor the virtual switch and react on status changes:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
rule "ChromeCast Living Room in use"
when
    Item CC_LivingRoom_used changed
then
    if (CC_LivingRoom_used.state == ON) {
        logInfo("ChromeCast Plug", "Turning ChromeCast in Living Room on")
        Plug_CC_LivingRoom_Toggle.sendCommand(ON)
    }
    if (CC_LivingRoom_used.state == OFF) {
        logInfo("ChromeCast Plug", "Turning ChromeCast in Living Room off")
        Plug_CC_LivingRoom_Toggle.sendCommand(OFF)
    }
end

Moments after a stream on the device starts, the display comes on. Once the stream stops, the display is off again. No one cares about background pictures …


Categories: [Ansible] [Linux] [Openhab]

Share: