Violet SmartSwitch Lite: Home-Assistant & Node-red Integration

Integrating a Violet Smart Switch into Node-red and Home-Assistant

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):

Violet Smartswitch Lite new slimmer design
Violet Smartswitch Lite new slimmer design
Violet's New Scene Tiles
Violet’s New Scene Tiles

○ 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.

Adding the HTTP integration
Adding the HTTP integration

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.

Complete 4 Scene Flow
Complete 4 Scene Flow

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):

Sonoff R3 Pro
Sonoff R3 Pro

Aliexpress

Amazon

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.

HTTP IN Node
HTTP IN Node
HTTP Response Node
HTTP Response Node

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.

Incoming HTTP Debug
Incoming HTTP Debug

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).

Switch Node for 4 Scenes
Switch Node for 4 Scenes

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.

4 Scenes up and running
4 Scenes up and running

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.

Create your webhook
Create your webhook

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.

Select Your Action
Select Your Action

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).

curl command
curl command

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 1
    label2: elgato key light
    request:
      uri: http://192.168.2.42:8123/api/webhook/violet
      method: POST
      headers:
        Content-Type: application/json
      body: ‘{ “key”: “5” }’
  id6:
    label: HA Webhook 2
    label2: Office light
    request:
      uri: http://192.168.2.42:8123/api/webhook/violet1
      method: POST
      headers:
        Content-Type: application/json
      body: ‘{ “key”: “6” }’
  id7:
    label: HA Webhook 3
    label2: Streamlight
    request:
      uri: http://192.168.2.42:8123/api/webhook/violet2
      method: POST
      headers:
        Content-Type: application/json
      body: ‘{ “key”: “7” }’
  id8:
    label: HA Webhook 4
    label2: Notifications to phone
    request:
      uri: http://192.168.2.42:8123/api/webhook/violet3
      method: POST
      headers:
        Content-Type: application/json
      body: ‘{ “key”: “8” }’
As you can see, they’re virtually the same as using Node-red, but with just a slight difference in the URI. I saved this directly underneath my Node-red yaml in the requests file on the microSD card (if you’re going fresh, remember to include the ‘version info’ header from the previous part). I uploaded the file as per the procedures we’ve already covered and within a minute I now had an additional 4 tiles on my screen. This was the maximum I could use currently.
Given that I will be using the tiles to control flows and not individually controlled components (testing aside), I’m happy with that. I don’t need more than 8 at this moment in time. Again, pay no attention to the quality of the screen below there, it’s been taken with a phone so the quality is not representative of the rich inky blank screen.
All 8 Tiles Populated
All 8 Tiles Populated
There were a couple of issues with the screen locking up but a quick firmware update to 1.70 addressed that and the panel has been working flawlessly ever since. It’s very responsive with my sonoff relays clicking on and off like Jessica Fletcher after a triple espresso!
All in all, am really happy with the way it turned out. My panel is even more useful to me now than it was previously. There was some teasong of further integrations to come, but for now, Violet are keeping their cards close to their chest.

Violet: Investment Seed Round

The other bit of news that Ryan wanted to share was that Violet are currently looking to undergo a capital raise and wil be looking for possible investment starting in February. You can read more about that here.
As this is not a financial blog, I’ll just link to it here for your perusal.

In Summary

So there we have it, this was the final missing piece of the puzzle for me. I’m looking forward to what other intergrations the team can sign up and incorporate, but the fact that I can now use Node-red or Home-Assistant natively on the panel means that, frankly speaking, I don’t need anyone else, I can control pretty much whatever I want right now. I am sure the custom side will only get easier from here.
Let me know in the comments if you’ve got one or are considering getting one, I’d be interested in your feedback.

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)!

The Smarthome Book
The Smarthome Book

Leave a Reply