PowerShell has historically been focused on managing servers’ software. With the implementation of the CIM cmdlets in v3, that changed quite a bit. See this module in particular to see how to manage hardware directly with PowerShell. Well there is another form of hardware manipulation that I wanted to expose some PowerShell support for. If you saw my previous blog post or my YouTube video, you can probably tell that I’m messing with some home automation hardware. Using the FluentDwelling project by Soapbox Automation, I’ve taken control of my brand new Insteon PowerLinc Modem and Dimmable Switch. This enabled me to create the app(s) in the video.
While testing my implementation, I needed a way to test the Insteon commands without the overhead of the entire system. To do this I harnessed PowerShell and made a simple module around the FluentDwelling API. I created a couple simple cmdlets to gain access to the PowerLinc modem and issue some basic commands against the light switch.
The first step is to get a hold of the modem. Use the Get-PowerlineModem specifying the PortName. Your system may be using a different port.
Next, you’ll have to get the device you want to manage. Every Insteon device comes pre-stamped with a unique DeviceId. The Get-Device cmdlet will return the devices that are currently in the modem’s database. This database is sync’d from the management software called HouseLinc provided by Insteon. There are two devices with the same Id because the device supports bi-direction communication. It can inform the modem that someone has turned on the light switch manually.
Finally, you can set the state of the light. Just pass in one of the devices returned by Get-Device and set the State property. Right now this cmdlet supports On and Off along with dimmable light ramping. Ramping a light causes it to turn on or off gradually rather than right away. When you ramp on, you can specify the dim value. This can be between 1-255. By default it’s set to 128 or about 50%.
I’ve uploaded the current module to GitHub. If you have any Insteon or X10 devices feel free to fork me. I probably won’t be adding new devices to the module until I actually get some new ones as it’s pretty hard to test the cmdlets without the compatible device.