18

I have just started investigating smart lights.

I am interested in using some Wi-Fi sockets in some lamps in my office to automate the lights.

I am curious if there is a way to turn my lights on from my PC, and ultimately turn them on when my Linux machine wakes from suspension. Then turn them off when the Linux machine suspends.

Are there Wi-Fi sockets that use a certain messaging protocol that is open, for which I could write an app to use with them?

0

5 Answers 5

12

Belkin WeMo devices use uPnP and SOAP messages for control so can be easily controlled from any number of languages and options. Some details on the work I've done working out the protocol can be found here.

There are also the Sonoff devices that can be flashed with firmware to allow them to be controlled using MQTT.

IKEA's new TRÅDFRI light system use CoAP (with DTLS security) so is another open protocol that you can play with. My notes on this are here.

For any of these you should be able to use the Linux power management system (scripts in /etc/apm/resume.d & /etc/apm/suspend.d) to fire off commands when the machine changes state. Just remember that the network may take a second or so to come back up when a machine resumes.

4

There are sooooo many ways to do what you ask for.

There are proprietary solutions with API's and there are Open solutions with total openness.

Your question is broad and hard to give a straight answer depending on what your criteria is like: the size of your wallet, technical spec, availability in your market your preferences on color and so on.

If you want an direction to where to find info, I have found youtube an inspiration, OpenHAB.org (An Home Automation Hub) that has addons for many vendors and open API's.

And of course you can schedule post and pre power script in linux, my prefered plattform :-)

3

If you're looking to keep clutter off of your wifi network, you could use Z-Wave or Zigbee lights (bulbs, sockets, or switches). Each of those network protocols can be run using a USB controller that would plug into your Linux machine. Both standards have active open-source communities. As MatsK said, it is pretty easy to integrate those into power scripts in Linux.

0

If you are using wiz connected lights then this (Control Wiz Connected Lights Through Gnome Shell) Gnome shell extension can help you out.

0

Philips Wiz

Phillips Wiz (also on HA) lights could be controlled with pywizlight or directly sending JSON to UDP port 38899

pywizlight

# Install
pip3 install pywizlight

# Commands
discover   Discovery bulb in the local network.
off        Turn a given bulb off.
on         Turn a given bulb on.
set-state  Set the current state of a given bulb.
state      Get the current state of a given bulb.

# Example  
wizlight on --ip 192.168.1.148 --k 2700 --brightness 30

Using JSON

echo -n '{"id":1,"method":"setState","params":{"state":true}}' | nc -u -w 1 192.168.100.148 38899 | jq .

The | jq . just use jq to beautify the JSON output.

More examples here.

Philips Hue

Regarding sending JSON data directly to a UDP port, Philips Hue does not support this method for controlling lights. Instead, it uses a RESTful API that communicates over HTTP. You can send commands in JSON format to the Hue Bridge's IP address using standard HTTP requests.

Also

  • With other Matter-compatible devices you might need Matter SDK. Some of them let you send JSON with something RESTful like curl -X POST http://192.168.1.148/control -H "Content-Type: application/json" -d '{"on": true}'
  • Check also https://openrgb.org/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.