I wrote a simple groovy app myself, to run thermostat-type setup. So there are few sensors and plugs, activating a dehumidifier etc. Key lines of code are
in preferences: input “switchP”, “capability.switch”, required: true, title: "Wall Plug?"
in an event handler: def currentSwitch = switchP.currentState(“switch”)
log.debug "Wall Plug: $currentSwitch” then returns “null” in the log file
log.debug "Wall Plug: $currentSwitch.value” throws a NullPointException: Cannot get property ‘value’ on null object @ line xx