Homebridge Plugin

Hi all!

I’ve been happily hacking away with my Tidbyt since I received it last week.

While still very much an alpha, I was able to get an initial Homebridge plugin to integrate my Tidbyt device into Apple’s HomeKit ecosystem.

Prerequisites

Brightness Control

So far the integration is fairly limited. The device will show up on your network as a Lightbulb. You can adjust the brightness from 1-100%.

Note: Due to Tidbyt API limitations it is not possible to turn the screen completely off at this time.

You can see it in action here:

I’m excited to hear what others think might be useful to add with the current capabilities of the Tidbyt API.

Custom Apps

The most interesting feature of the plugin is Custom Apps.

Custom Apps allow you to configure your very own applets using Pixlet scripts. You can schedule your applets to update and push to all of your devices at the same time.

Here is what it looks like to configure the Twitter Followers pixlet that I created last week:

This can also be configured manually in the config.json like this:

{
    ...
    "platforms": [
        {
            "authToken": "...",
            "discoverFrequency": 60000,
            "managedDevices": [
                {
                    "id": "mainly-awesome-viking-rabbit-2e1"
                }
            ],
            "customApps": [
                {
                    "id": "TwitterFollowers",
                    "enabled": true,
                    "updateOnStartup": true,
                    "script": "/home/pi/tidbyt/twitter.star",
                    "schedule": "*/30 * * * *",
                    "config": [
                        {
                            "key": "screen_name",
                            "value": "npenree"
                        }
                    ]
                }
            ],
            "platform": "Tidbyt"
        }
    ]
}

And the final result:

I hope to continue to build this out and will try to get some documentation going as time permits.

Happy hacking!

11 Likes

This is awesome, but your GitHub link is broken.

Oops! Sorry about that, the link should be all good now.

Merry Christmas!

Hey @drudge ,

This is amazing! Thanks so much for putting this together and sharing here. I’m totally going to get this setup at home and give this a whirl. Excited to see what else you create and please let us know what we can do to best support you. Something like turning off the screen feels like something we should support and would make the Homebridge integration even better.

Let us know if there are any other limitations that you run into that would make your time easier and we’ll see what we can do on our end!

Hey @drudge,

Thank you for putting this together. I’m not very technical but can usually follow instructions. However, I’m having issues following this. I was able to install homebridge on my NAS; i believe it is a docker container. Do you have any idea how I could install pixlet in this container within homebridge? Could I use the homebridge terminal?

Hi @bgnzo!

It is hard for me to help since I’m not familiar with your NAS setup, but if you are adding customizations to Homebridge it might make sense to build a new Docker image that bundles Homebridge + Pixlet + your homebridge plugins (like homebridge-tidbyt) and run that on your NAS instead.

Alternatively, your setup may allow you to put the Pixlet binary on a data volume or mapped host directory and then perform the setup after attaching to the running container with docker attach.

I’m running Homebridge on a Raspberry Pi and simply installed a pre-compiled Go binary and built pixlet from source there.

Hope this helps, good luck!

Hi all!

I’ve added a new feature to Custom Apps: Config Scripts

Config Scripts are Node.js modules that you can execute to dynamically build configuration parameters before they are passed to the Render Script . This allows you to tap into the vast ecosystem of modules available on npm to build your own connected applets.

A Config Script is a very simple Node module that exports a single function that returns a Promise that resolves to an array of key/value pair objects. The most trivial example looks like this:

module.exports = function(config) {
    return new Promise(function(resolve) {
        resolve([
            {
                key: 'foo',
                value: 'bar',
            },
        ]);
    });
};

I’ve put together a little tutorial to demonstrate how Config Scripts can be used in conjunction with Render Scripts to pull data from the XBOX LIVE API and push your Gamerscore to your Tidbyt device.

Here is the final result:

Let me know what you think.

Wow thank you so much for getting this created!
I was curious, what do you have homebridge setup on?
I’m on a Raspberry Pi 4 w/ Raspberry Pi OS but have been unable to get pixlet installed.
Any chance you have a similar setup?

Hi @ToWn3r !

I’m running Homebridge on a Raspberry Pi 4 using the official image based on Raspbian.

I installed Pixlet using the method outlined here, which consisted of the following steps:

  1. Run wget https://go.dev/dl/go1.17.5.linux-armv6l.tar.gz to download the latest Go for rPI 4
  2. Run sudo tar -C /usr/local -xzf go1.17.5.linux-armv6l.tar.gz to extract go in to /usr/local/
  3. Run sudo apt update && sudo apt install git libwebp-dev -y to install the libwebp dependency.
  4. Run git clone https://github.com/tidbyt/pixlet to get pixlet source
  5. Run cd pixlet && make build to build Pixlet
  6. Move the built pixlet binary to /usr/local/bin (which is in the $PATH ).
1 Like

You’re amazing!
I’m getting a strange error :frowning:

Hi @ToWn3r

It looks like Go is not in your path. Make sure it is by adding the following lines to your ~/.bashrc file:

PATH=$PATH:/usr/local/go/bin
GOPATH=$HOME/golang

Alternatively, you can alter the build command like this:

cd pixlet && PATH=$PATH:/usr/local/go/bin GOPATH=$HOME/golang make build

1 Like

:see_no_evil:

Idk where that is :frowning:

The file would be /home/pi/.bashrc. By default, ls does not show hidden/dotfiles, so the file prefixed with a period does not show. you can use ls -a to show them.

If the file doesn’t exist you can create it with those lines and it will be fine.

Alternatively, you can avoid ~/.bashrc and alter the build command instead like this:

cd pixlet && PATH=$PATH:/usr/local/go/bin GOPATH=$HOME/golang make build

1 Like

Getting closer!
Getting a permission denied

pi@ToWn3r-Pi:~ $ cd pixlet && PATH=$PATH:/usr/local/go/bin     GOPATH=$HOME/golang make build
rm -rf build/out
go run render/gen/embedfonts.go
failed to initialize build cache at /home/pi/.cache/go-build: mkdir /home/pi/.cache/go-build: permission denied
make: *** [Makefile:14: embedfonts] Error 1

If you’ve ran the command with sudo it might have changed permissions on your cache directory.

sudo chown -R pi /home/pi/.cache 

and then try the build again. Just make sure all of the directories are owned by the pi user that you are running as.

1 Like

Perfect! After running the following I think it was built.

sudo chown -R pi /home/pi/.cache

sudo PATH=$PATH:/usr/local/go/bin GOPATH=$HOME/golang make build

1 Like

Great, now you can run mv pixlet /usr/local/bin/ and pixlet will be in your path and available to the Homebridge plugin.

[Tidbyt] Could not locate the pixlet CLI. Make sure it is installed and in your PATH.

Is pixlet actually there? What does ls -lah /usr/local/bin/pixlet show?

What does this show?

> pixlet render --help

If you are unable to run the render above, what does the $PATH show when you run env?