No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Pi Websockets Client


The idea behind this project is to control devices by physically wiring them to Raspberry Pis. This client is designed to subscribe to a websocket API I built, and respond to events that are broadcast by it.

My current use case is a Raspberry Pi Zero W with pin 11 wired up to the base of a transistor that shorts a normally open push button switch, thus turning something on.


I'm using this gem for websockets clients. It works well, but doesn't seem to support reconnecting when a connection is lost. My workaround for this is to write the timestamp from each ping to a file (they come every 3 seconds). I then have a separate bash script ( which runs every minute via cron and checks for the age of the last ping. If the ping is old it'll kill this process and relaunch. Not terribly elegant, but it works well, and makes the client rather robust. Lastly, I set the Pi to restart every night at 3am via cron.

I launch the ruby script on boot via @reboot cron. The will also start it up, but there will be a longer delay.

Example .env file


These values have to match those set in the API. The device_guid will vary for each device, and is created by the API. PLATFORM=PC is for dev, and turns off all the GPIO pin stuff; set it to PLATFORM=PI for prod.