I am attempting to have script control and restore devices while maintaining device previous status. I have come up with the following:
#### OfficeLightsOn.cs ####
Is there a better way to go about this other than defining 8 additional events? Like possibly having the trigger scripts control the devices directly. I have yet to find any examples of this. I have found examples that control what HomeSeer thinks is the device status, but it doesn't actually send command to device.
Can someone point me in the right direction?
#### OfficeLightsOn.cs ####
Code:
public Object Main(Object[] parm) { for(int i = 1; i < 5; i++) { string index = i.ToString(); string lightGlobalVariableName = "officeLamp" + index + "_ManualControlState"; string errCode = hs.CreateVar(lightGlobalVariableName); int lightState = hs.DeviceValueByName("Office Lamp " + index); hs.SaveVar(lightGlobalVariableName, lightState );//+ " value is " + value.ToString() hs.TriggerEvent ("Turn on Light" + index); } return null; }
Code:
#### OfficeLightsOff.cs #### public Object Main(Object[] parm) { for(int i = 1; i < 5; i++) { string index = i.ToString(); string lightGlobalVariableName = "officeLamp" + index + "_ManualControlState"; object lightobj = hs.GetVar(lightGlobalVariableName); string lightState = (lightobj != null) ? lightobj.ToString():"-1"; if (lightState == "0") hs.TriggerEvent ("Turn Off Light" + index); } return null; }
Is there a better way to go about this other than defining 8 additional events? Like possibly having the trigger scripts control the devices directly. I have yet to find any examples of this. I have found examples that control what HomeSeer thinks is the device status, but it doesn't actually send command to device.
Can someone point me in the right direction?
Comment