How to Control Homeseer HS3 Devices in Octoprint

How to Control Homeseer HS3 Devices in Octoprint

As a fresh convert to HS3 (née 2019), I’m now hunting for every possible way I can integrate Homeseer control into my other projects. Here’s how I’m using the Octoprint UI to control a lamp beside one of my 3D printers.

Step 1 - Collect the device Reference ID from Homeseer

Open your Homeseer Web Control page, and on the Home tab find the device you want to control. Click on it, and go to the Advanced tab. Note the Reference ID. For me, this is 129.

ReferenceID.png

Step 2 - Build your JSON API URLs

Homeseer’s JSON API allows you to get the status of devices, control devices, and trigger events. We’ll use that to turn a lamp on or off. If your Octoprint server is on the same network as Homeseer, your URL will be in the format:

http://<<HomeseerIP>>/JSON?&request=controldevicebyvalue&ref=<<DeviceReferenceID>>&value=<<ValueToSet>>

If you are not on the same network, want to leverage the MyHS system for control through the cloud, or you have some extra authentication enabled, your URL format will be:

https://connected2.homeseer.com/JSON?user=<<YourHomeseerMyHSEmail>>&pass=<<YourMyHSPassword>>&request=controldevicebyvalue&ref=<<DeviceReferenceID>>&value=<<ValueToSet>>

In my case, Octoprint and Homeseer share the same home network, so I have prepared three URLs. I’m controlling device with ID 129, and setting values of 99, 20, or 0, for On, Dim, or Off:

  • Turn the lamp on: http://192.168.0.88/JSON?&request=controldevicebyvalue&ref=129&value=99

  • Dim the lamp to 20%: http://192.168.0.88/JSON?&request=controldevicebyvalue&ref=129&value=20

  • Turn the lamp off: http://192.168.0.88/JSON?&request=controldevicebyvalue&ref=129&value=0

You can take the URLs you build and paste them into a new tab in your browser. If all goes well, you’ll get some JSON back and your Web Control page will update to show the new status of the device.

Step 3 - Install the System Command Editor plugin for Octoprint

In your Octoprint UI, click the wrench icon, open Plugin Manager, click Get More, and search for System Command Editor by Salandora (homepage).

SystemCommandEditor.png

After installing it and rebooting Octoprint, find its settings page back in Octoprint’s settings window. Right click in the empty green border, and choose Create Command. Give it a name (this will appear in the Octoprint menu), and for the command enter:

curl “<<YourURLHere>>”

For for me, to turn the lamp on, my command is:

http://192.168.0.88/JSON?&request=controldevicebyvalue&ref=129&value=99
CreateCommand.png

Click Confirm, and it will be added to the list. Repeat this process for any other URLs you prepared. You can click and drag the commands in the list to get them into the order you want. When you’re done, you’ll have something like this:

CommandList.png

(I did notice a bug where it will sometimes list the command multiple times after adding a new one — you can ignore this. For me, it still only showed each command once in the Octoprint UI.)

Save your changes when you’re done adding URLs. From the Octoprint UI, click the Power icon and notice your new menu entries. Test them by clicking each one and confirming the device is controlled by Homeseer.

octoprintHomeseer.png

Other Uses

You could use this technique to control the power to a 3D printer, allowing you to physically turn it on from the Octoprint UI. This could be helpful to begin heating when you’re prepping a new file to print.

With the power of Homeseer, there’s many things you can do. Change light colors, adjust a room temperature, start timelapse recording, etc.

Controlling Homeseer Events from Octoprint

You can also trigger an event using the API, if you would prefer to control things that way. Your URL format would be:

/JSON?request=runevent&group=<<GROUPNAME>>&name=<<EVENTNAME>>

…of if you know the Event ID…

/JSON?request=runevent&id=<<EVENT_ID>>

More information about Homeseer’s JSON API can be found here: https://homeseer.com/support/homeseer/HS3/SDK/controlling_with_json.htm

Let me know if you found this useful!

Unboxing the Raspberry Pi 4 - 2GB

Unboxing the Raspberry Pi 4 - 2GB