- Platform information:
- Hardware: Raspberry Pi
- OS: OH2
rules
rule "Controls Initializing"
when
System started
then
logInfo("ControlsInitializing", "Controls Initializing ------>")
Thread::sleep(5000) // need to experiment to find the right value to ensure all the Items have been restored
// logInfo("InitializingControl", "GPIO_Light_state.state: " + GPIO_Light_state.state.toString)
if( (GPIO_Light != null) && (GPIO_Light_state.state != null) ){
logInfo("GPIO_Light", GPIO_Light_state.state.toString())
GPIO_Light.sendCommand(GPIO_Light_state.state)
// GPIO_Cooler.sendCommand(GPIO_Cooler_state.state.toString())
// GPIO_FanCeiling.sendCommand(GPIO_FanCeiling_state.state.toString())
// GPIO_Fan.sendCommand(GPIO_Fan_state.state.toString())
}
end
rule "Controls Update"
when
Member of Control received command
then
// logInfo("UpdateControl", "Controls Update >>>>>>>>>")
// logInfo("Update Control", "---------------> Member " + triggeringItem.name + " to " + receivedCommand)
switch triggeringItem.name {
case "GPIO_Light" : GPIO_Light_state.postUpdate(receivedCommand.toString())
case "GPIO_Cooler" : GPIO_Cooler_state.postUpdate(receivedCommand.toString())
case "GPIO_FanCeiling" : GPIO_FanCeiling_state.postUpdate(receivedCommand.toString())
case "GPIO_Fan" : GPIO_Fan_state.postUpdate(receivedCommand.toString())
// default : logInfo("Update Control", "Error in switch! item:" + triggeringItem.name)
}
end
Log
2019-11-19 05:51:52.857 [INFO ] [me.model.script.ControlsInitializing] - Controls Initializing ------>
2019-11-19 05:51:58.387 [INFO ] [se.smarthome.model.script.GPIO_Light] - OFF
2019-11-19 05:51:58.396 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Error during the execution of startup rule 'Controls Initializing': Could not invoke method: org.eclipse.smarthome.model.script.actions.BusEvent.sendCommand(org.eclipse.smarthome.core.items.Item,java.lang.String) on instance: null