Our focused here is on the lights button. It's pretty simple with a panel pictured below:
I have yet to add the dimmer function in my Nodejs code but built the UI anyway. Seeing as I am the only user of this system, I think that's okay. The On/Off button is a slider which generates an event of 'on' or 'off'. Yep it's that simple.
For my slider I have given it the ID of "office". Now, whenever there is a event fired off the widgetId will be "office".
As with all of the projects involving CE building the UI typically takes less than 10 minutes but it's still fun to build and test them out. For Node code I took a previous project and have just made some adjustments and added some new code.
The CEKasa repo contains 3 files to make the project work. Our .env file to host are passwords and usernames, and the server and endpoint files. The endpoint file is an adaptation of the endpoint file from https://github.com/voipnorm/CEbusyLightOmega/blob/master/endpoint.js.
What you will notice with the new endpoint file is some lines that are not required are commented out. This is because we will bring all our code together in a later post to build a room controller on our Pi. Now you get it:). I need more material to write about, that's right.
So what's the difference between the two projects you may ask? Well its below. The new monitorWidget function is looking for our Touch 10 events when you move the slider.
Not a terribly complicated piece of code but it works.
There you have it folks, an inexpensive room light controller. In this project I am only controlling 1 light but this can be expanded to as many lights in the room as you like. I left the dimmer out for now. If you want to have a go, let me know your results in the comments below.
Hope your enjoying these project posts. It's a great way to get started programming with Pi, Webex Room devices and Nodejs.
Intro to project:
Working with Kasa cloud: