Homemade Smart Power Strip

This post is not a hardware post, but just a simple way to use a smart plug to replace a conventional smart power strip to avoid unneeded standby power consumption. For my home entertainment system I previously used a conventional smart power strip, but it caused several crashes of my media center, a Raspberry Pi running Kodi. So I decided to replace it with a standard power strip connected to a smart plug, and let openHAB do the magic.

I decided to use a ZigBee smart plug due to low power consumption and since already having a Philips Hue bridge within range. I went with an Innr smart plug, since the Philips Hue smart plug hadn’t been introduced at the time.

As trigger for turning power on or off, I went with my Harmony Hub. This way I can also turn off the network switch, since the Hub is Wi-Fi connected. When any activity is started, requiring any of the powered off devices, I’ll simply turn on the smart plug. When powering off, I need Kodi to shutdown and wait for this. So here are the rules I ended up with:

rule "TV turn on socket"
when
    // This is logically correct, but too slow because it's only fired when
    // activity has completed. It's a fallback solution because of a bug in
    // the binding, see below.
    Item HarmonyHub_CurrentActivity changed from "PowerOff" or
    // These channel triggers are fast, but logic is messy because logic
    // cannot be reversed. The correct solution would be to trigger on an item
    // bound to "Activity Starting Trigger" and use same logic as above:
    // Item HarmonyHub_ActivityStartingTrigger changed from "PowerOff"
    Channel "harmonyhub:hub:HarmonyHub:activityStarting" triggered Watch_tv or
    Channel "harmonyhub:hub:HarmonyHub:activityStarting" triggered Listen_to_music or
    Channel "harmonyhub:hub:HarmonyHub:activityStarting" triggered Watch_a_movie or
    Channel "harmonyhub:hub:HarmonyHub:activityStarting" triggered Kodi or
    Channel "harmonyhub:hub:HarmonyHub:activityStarting" triggered Chromecast
then
    Tv_Socket_Switch.sendCommand(ON)
end

rule "TV turn off socket"
when
    Item HarmonyHub_CurrentActivity changed to "PowerOff"
then
    var num_of_attempts = 20
    var delay_between_attempts = 5000
    var attempt = 0

    var kodi_initial_online_state = NetworkDeviceKodi_Online.state

    // Waiting for Kodi (might be booting up)
    while (NetworkDeviceKodi_Online.state == OFF && attempt < num_of_attempts)
    {
        attempt = attempt + 1
        Thread::sleep(delay_between_attempts)
    }

    if (NetworkDeviceKodi_Online.state == OFF)
    {
        sendPushMessage.apply("Tv turned off", "Kodi is offline. Something wrong?")
    } 
    else if (kodi_initial_online_state == OFF)
    {
        // Initial state offline, now online - waiting for services to start"
        Thread::sleep(30000)
    }

    if (HarmonyHub_CurrentActivity.state == "PowerOff")
    {
        // Attempting to shut down Kodi
        sendHttpPostRequest('http://pi3:80/jsonrpc', 'application/json', '{"jsonrpc":"2.0","method":"System.Shutdown","id":1}')
        Thread::sleep(30000)

        // Waited 30 seconds, checking if activity didn't start again
        if (HarmonyHub_CurrentActivity.state == "PowerOff")
        {
            Tv_Socket_Switch.sendCommand(OFF)
        }
        else
        {
            sendPushMessage.apply("Tv turned off", "Tv turned on again after Kodi was shut down - now offline. Trying to restart.")
            Tv_Socket_Switch.sendCommand(OFF)
            Thread::sleep(5000)
            Tv_Socket_Switch.sendCommand(ON)
        }
    }
    else
    {
        // Shutdown/power off aborted, new activity started.
    }
end



I might look over-complicated, but I wanted a defensive approach to make sure everything is done to not trigger data corruption when power is taken from the Kodi Pi without proper shutdown. For example, if the Pi is still booting when TV is turned off, it won’t be able to accept a shutdown command yet, so I’m waiting for it to complete booting. Also, in case the TV is turned on again while the Pi is shutting down, I try to boot it again by turning it off and on again.

LG OLED TV and USB drives

I recently purchased a new LG OLED65C8 TV and with it a SanDisk Extreme Pro USB 3.1 SSD drive with a write-speed up to 380 MB/s, after reading these recommendations. I wanted to use this for recordings and time shift (Live Playback). Unfortunately it doesn’t work with time shift – only recording. I sent a request to customer service about this, and conclusion is:

  • LG recommends HDD’s instead of flash drives. Old-fashioned big noisy hard drives which are hard to fit on the back of the TV.
  • LG cannot recommend any devices – no compatibility lists exists. So customers will just have to buy one device at a time until finding one that works. That’s a very costly solution in my opinion.

Now I’m just waiting for burn-in to complete my LG customer experience…

Update: I got a second response from customer service, and unfortunately – as I suspected:

  • Live Playback only works with magnetic disks, not any kind of flash device.
  • This will not be solved/changed with a firmware upgrade.

New SunFlux GU4 MR11 LED bulb

I received twenty of the new GU4/MR11 bulbs from SunFlux a few days ago. Specifications:

  • EAN: 5710777110165
  • Part number: 11016
  • Power: 3 W
  • Color temperature: 2700 K
  • Lumen: 200
  • CRI: >95
  • Beam: 40°
  • Dimmable: Yes
  • Size: Ø35 – L41
  • Life hours: 20.000

I don’t have the equipment to test if the bulbs live up to the specifications, but at least one of the specifications is incorrect: It’s not an MR11 bulb. Well, sort of. Almost. I’ve never had any problem with halogen bulbs of any brand, but these bulbs are too large to fit into my spots. Bummer! A 1 mm difference would probably have made it possible to fit the retaining ring clips into the spot.

I bought the bulbs because SunFlux suddenly, without notice, changed the specifications for the older GU4/MR11 bulb with EAN 5710777110158/part number 11015. It used to be:

  • Power: 3 W
  • Color temperature: 2750 K
  • Lumen: 180
  • CRI: >96
  • Beam: 40°
  • Dimmable: Yes
  • Size: Ø35 – L43
  • Life hours: 20.000

I actually received one of these, and four bulbs of the new version with these changed specifications:

  • Color temperature: 2700 K
  • Lumen: 200
  • CRI: >92

So that’s how I found out – I didn’t get five identical bulbs, even though it was the same order. So they downgraded the CRI, but upgraded the efficiency a tiny bit. These bulbs are ugly, but at least they fit into standard MR11 spots. I’m not sure why they made a new version of the old bulb with almost identical specifications as the new one (except the lower CRI). We’ll see if part number 11015 is being phased out.

Perhaps time to go looking for a spot that has enough space for this bulb…