So a couple of days ago, Ryan from Violet reached out to me to let me know that the main feature that I was waiting for on their smart switch had been released and was out in the wild. It was now possible to integrate http requests on their panel. For me this meant integration directly into Node-red, Home-Assistant and I was no longer limited to just their Sonos and Hue integrations (which work flawlessly by the way).
During our correspondence I learnt that this wasn’t the only development happening over at Violet HQ. Read on for a quick update.
Model Revision
Violet have subsequently revised their SmartSwitch Lite with a newer variant which is not only 7mm thinner but also packs new features (As I don’t have this newer model yet, I’ve taken these directly from their product release):
○ The new device supports both 100-240 V AC and 12-30V DC which means it can either replace a traditional light switch or an existing “smart keypad” powered by extra low voltage wire
○ Via WiFi, SmartSwitch Lite connects with Philips Hue & Sonos out of the box and, for advanced users, almost any other system that uses HTTP requests. This provides access to services like Home Assistant, IFTTT and many more, with more out-the-box integrations on the way.
○ Simply double tap the screen to play/pause audio or hold it to turn the lights on and off, all without waking it. If more control is required, a single tap wakes the screen and displays the sleek interface allowing simple scene recall and audio adjustment.
HTTP integration: Node-red
This was the main thing I had been waiting for. Whilst I use Sonos, I don’t really use Philips Hue and wanted a way to make A better use of the Panel. This is Violet’s first release of this additional software. It’s been working well, but it took me a while to get my head around the HTTP protocol. I needed to overcome various endpoint and authorisation issues. I’ll walk you through how to get yours working.
Ryan did mention that as of now, the only way to configure this is to load a requests.yaml file on to a microSD card and load the integration from there. They plan on allowing SSH/SFTP access at some point to allow for easier configuration, but as of now, this is the only way. At least for you with this tutorial, you should only have to do this once. I can’t tell you how many times I had to pull and re-insert the microSD card back in whilst troubleshooting! I want to point out that the majority of this was down to my inexperience with HTTP protocols as opposed to any issues with the switch.
Their initial configuration page and http example is here if you are experienced and want to get straight into it. If not, read on and you can see how I did it step by step.
HTTPviaSD Configuration
I formatted a microSD card for FAT32 (usung Rufus) and created a file using notepad called requests.yml on the root directory.
I have created 4 buttons or “scenes” and have set them up and labelled them accordingly. Remember to change the IP address to your Node-red installation and also add change your username and password accordingly. My node-red installation is an add-on under Home-Assistant Supervised, so the username and password is my Home-Assistant user:password. If you’re running Node-red in it’s own container or VM then potentially you might not need the ‘user:password@’ bit so you can remove if necessary.
version: 1.0
scenes:
id1:
label: Tasmota 1
label2: Lounge Lights
request:
uri: http://user:[email protected]:1880/endpoint/violet
method: POST
headers:
Content-Type: application/json
body: ‘{ “key”: “1” }’
id2:
label: Tasmota 2
label2: Lounge TV
request:
uri: http://user:[email protected]:1880/endpoint/violet
method: POST
headers:
Content-Type: application/json
body: ‘{ “key”: “2” }’
id3:
label: Tasmota 3
label2: Denon Amplifier
request:
uri: http://user:[email protected]:1880/endpoint/violet
method: POST
headers:
Content-Type: application/json
body: ‘{ “key”: “3” }’
id4:
label: Tasmota 4
label2: Nvidia Shield
request:
uri: http://user:[email protected]:1880/endpoint/violet
method: POST
headers:
Content-Type: application/json
body: ‘{ “key”: “4” }’
Once saved, I then popped the microSD card into the Smartswitch Lite and went to the integrations screen. From here it was a case, of going through the following steps (I was initially on firmware 1.6.0-rc.3).
Settings => Integrations => Add Integration => HTTPviaSD
Then with the SD card installed, you click on Load File.
If everything has worked as plan (your card is in FAT32, the yaml has been correctly spaced) you should be able to proceed further. If you see a screen mentioning parsing, then it means your yaml has been incorrectly formatted so you’ll need to go back to the file and play with it again. Yaml is extremely sensitive to an extra or missing space.
If all has worked ok, click Go There and you’ll find yourselves in the Scenes Screen. Now it’s just a case of Add Buttons. I highlighted the buttons/scenes I wanted to add, leaving them with a tick and then pressed the tick on the top right to proceed. At this point, I then came out to the main menu where I was met with the 4 new scene tiles. So far so good. Now time to configure Node-red. Here’s an overview of the flow I created.
I wanted to use my trusty Sonoff 4CHPRO3 as my test mule for this. If you’re a tinkerer and don’t have one, get one! It sits on my desk and with 4 outputs it’s the perfect item to test various automations on. I’ve already created a post on it here including various integrations. You can pick one up from the link below (affiliate link, won’t cost you anything but helps to support the blog):
First we need to create an HTTP in node, through testing, I also added an HTTP response node, which i don’t think is entirely necessary for this flow now, but I’ve left it in through habit.
It’s also a good idea to set up a debug node, so you can see exactly what’s coming in through the HTTP request.
Once I could see that the msg.payload.key variable was being passed through, I then set up a switch node and directed the flow according to the incoming payload.key (be sure to match the Property to the .key bit otherwise it won’t work).
It was then a case of just deciding what to do with it. Here I just linked it to the Sonoff 4ChPRO 3 outputs. At this moment in time I am using the toggle service call, as it doesn’t make sense to have one button for on and another for off. At least on the test bench. Deploy the flow and test your scenes. If you’ve followed the above you should have a fully working integration.
Now for some of you, this will be a walk in the park and you’ll be injecting your own JSON and creating reams of code directly on the panel. Personally, I prefer to do it all in Node-red and that means keeping this part simple.
HTTP integration: Home-Assistant
For those of you that don’t use Node-red and prefer to keep things purely in Home-Assistant, dont’ worry I’ve got you covered. I’ll show you some examples of how to use the panel to contol HA directly.
Firstly, we need to make sure that we have some things set up in Home-Assistant. Go to your configuration.yaml and make sure you add the following (if you haven’t got it already), and restart your server.
api:
Next we need to go to automations and create a webhook. This can be named whatever you want. Just be sure to remember what naming convention you’ve used, as we’ll need it to build out the link in the requests.yaml file we’ll be using to upload into the panel. See the Trigger section below for the creation.
Now choose what action you will want the panel to trigger. In this example, I’ll have it turn on my Elgato key light air.
Save your automation. Now we need to test it, making sure the webhook is up and running. I suggest you go to a terminal window and try and curl the request.
If all goes well, you should have no error messages, and your action should complete successfully (in my case, the Elgato Key Light Air switched on).
So far so good? Now that we’ve verified that the webhook works (at least locally anyway), we now need to get this onto the microSD card and uploaded into the panel.
I created another four different webhooks for me to play with, and uploaded them as follows. I didn’t need to supply user:password@server here, so just went with the below:
id5:label: HA Webhook 1label2: elgato key lightrequest:uri: http://192.168.2.42:8123/api/webhook/violetmethod: POSTheaders:Content-Type: application/jsonbody: ‘{ “key”: “5” }’id6:label: HA Webhook 2label2: Office lightrequest:uri: http://192.168.2.42:8123/api/webhook/violet1method: POSTheaders:Content-Type: application/jsonbody: ‘{ “key”: “6” }’id7:label: HA Webhook 3label2: Streamlightrequest:uri: http://192.168.2.42:8123/api/webhook/violet2method: POSTheaders:Content-Type: application/jsonbody: ‘{ “key”: “7” }’id8:label: HA Webhook 4label2: Notifications to phonerequest:uri: http://192.168.2.42:8123/api/webhook/violet3method: POSTheaders:Content-Type: application/jsonbody: ‘{ “key”: “8” }’
Violet: Investment Seed Round
In Summary
We’ve got a facebook group if you’re interested in sharing what you’re currently working on. You can find us here:
https://www.facebook.com/groups/386238285944105
If you’re considering a renovation and looking at the structured wiring side of things, or maybe you just want to just support the blog, have a look below at my smarthome book, it’s available in all the usual places (including paperback)!