Set Insteon Timers with Visual Basic 6
Efundies.com - Making Electronics Fun
Make sure you have already followed the instructions to Add Insteon Support to Visual Basic.
Setting Insteon timers is done using XML. It is not very difficult, but the code can get a little messy. You may want to check out our free application, Insteon Timer Configs, which includes full source code.
First you create an XML string that contains all of the timers that you want to configure. Then you use sm.SendText to send the XML to the PowerLine Controller (PLC). The PLC will chew on the XML for a while. When it is done processing your timers, the PLC will send back to you "saladapp=free" in your sm_OnText callback.
It is a good idea to respond to "saladapp=free" with sm.SendText "listtimers". You will get back a list of the currently set timers which you can parse to verify that they were set.
All of this is illustrated in Insteon Timer Configs if you need furthur help.
Forming Your Timer XML String
A basic Insteon Timer XML string looks like this:
<Device DID="1" Address="07.B1.12" HouseCode="" UnitCode="" OnLevel="On" DeviceName="LRLamp">LRLamp</Device>
If you want to control multiple devices, add them between <Device...> and </Device> tags inside the <DeviceList> section. Keep in mind, there should be NO LINE BREAKS in this string. It should be one long continuous string.
Once you have formed your XML timer string, simply send it to the PLC with the following command:
Then you can wait for "saladapp=free" in your sm_OnText routine.
If you want a prewritten function that codes your XML string for you, just grab the source to Insteon Timer Configs.