Trigger a rule when a thing goes Offline because of COMMUNICATION_ERROR

Aaaaaand it is beyond Christmas and the rule did not provide a successful reset yet. TBH today the bridge finally turned zombie for once. And the rule I made in rules DSL behaved correctly but did not solve the problem. I think due to a power outage one month ago due to which the Innr power plug did not reconnect to my hue bridge properly (I have two Innr plugs, both were unreachable after that time). My hypothesis is that the plugs probably want to connect to the bridge when it is not yet online, fail and don’t retry. I did not try to reconnect them on purpose, just because of this rule.

Anyway, my DSL rule looks like this:

// Triggers:
// - When velux:klf200:meterkast changed

// context: veluxreset-1
if (getThingStatusInfo("velux:klf200:meterkast").getStatusDetail().toString() == "COMMUNICATION_ERROR") {
	logWarn("VeluxWARN", "Velux KLF is zombie, restarting it via the power socket")
	logInfo("VeluxINFO", "Velux KLF zombie -> disable bridge")
	sendHttpPutRequest("http://localhost:8080/rest/things/velux:klf200:meterkast/enable", "text/plain", "false", headers, 1000)
	Thread::sleep(2000)
	logInfo("VeluxINFO", "Velux KLF zombie -> power off")
	Velux_Bridge_Smartplug.sendCommand(OFF)
	Thread::sleep(10000)
	logInfo("VeluxINFO", "Velux KLF zombie -> power on")
	Velux_Bridge_Smartplug.sendCommand(ON)
	VeluxEnableTimer = createTimer(now.plusSeconds(30))[|
		logInfo("VeluxINFO", "Velux KLF zombie -> enable bridge")
		sendHttpPutRequest("http://localhost:8080/rest/things/velux:klf200:meterkast/enable", "text/plain", "true", headers, 1000)
		VeluxEnableTimer = null
	]
}

Reason that it took three-and-half month to finally turn zombie:
I bought the Innr plugs only after the previous post (innr as these had the right dimensions not to block the plugs next to it and are compitable with the hue environment that is already present).
After incorporating them in hue, one wall switch of hue commanded a room i.s.o. a single light, took me a few weeks to figure out that mistake (turning off the bridge together with the light).
Had to turn of power a few times for other reasons and finally the power outage one month ago…

Now waiting for the next zombie state (plugs are paired again) :slight_smile: