Z-Wave fire alarm rules error

Hi All

I have Z-Wave PSM02 multi-sensors in each room of my house. They have an annoying habit of randomly, but frequently, reporting the room temperature in degrees F instead of degrees C (which they are configured for, me being a Brit).

I wrote a simple rule that seemed to fix the problem:

rule "SammyTempChanged"
Item Temperature_FF_SammyBedroom changed
if(Temperature_FF_SammyBedroom.state > 40) {
Temp = Temperature_FF_SammyBedroom.state as DecimalType
Temp = (Temp - 32) *5/9 //converts F to C
postUpdate(Temperature_FF_SammyBedroom, Temp)
etc. etc.

However, I recently added Sonos control to my OH system and realised I could add code that would set off a fire alarm if any room temp got above (say) 40 C, which never happens here in the UK.

So, I added the following to the above rule:

	if(Temperature_FF_SammyBedroom.state > 38) {
		if (FireAlarm.state != ON) {
			sendCommand(FireAlarm, ON)
			notifyMyAndroid("Fire Alarm in Sammy's bedroom!","Fire")
			sendMail("vitchling@hotmail.com", "Fire Alarm in Sammy's bedroom!", "Sammy Bedroom Fire!")


After some testing at lower temperature thresholds, it seemed to work remarkably well. With 4 Sonos speakers belting out at 90% volume a message saying “THERE’S A FIRE! GET OUT NOW!” I was quite pleased with myself. Nobody would mistake that message and I expect my neighbors would hear it too.

All seemed well for a week or two until recently the alarm was triggered. No fire. No real over-temperature input. But I can’t understand why my events log showed these events when the alarm went off:

2016-02-16 14:41:59 - Temperature_FF_SammyBedroom state updated to 14.5
2016-02-16 14:41:59 - Temperature_FF_SammyBedroom state updated to 58
2016-02-16 14:42:00 - Temperature_FF_SammyBedroom state updated to 14.44444444
2016-02-16 14:42:00 - FireAlarm received command ON

Neither do I understand why the fire alarm was triggered.

Looking through my event logs, my “F” to “C” conversion gets triggered fairly often on most of my sensors (similar to above) but they haven’t triggered my fire alarm…

I’m a novice at coding. Can anyone explain why my temperature units conversion seems to work so well most of the time but randomly seems to trigger my alarm after a couple of weeks for no obvious (to me) reason?


can you show us your entire rule? not in 2 peace.

And you know that you can use group to make only one rule instead of multiple rule for every sensor?

As 14.5C is 58F, you obviously realize the root cause of the “fire” trigger is misinterpretation as 58C.

Bearing in mind that when your conversion rule updates the F/C value, it will re-trigger itself on “changed”, I would guess there is some other unexpected re-entrancy as well.

I would re-jig the rule, assuming you really have the conversion and fire alarm activity all in one rule, so that the fire test uses that ‘Temp’ local variable instead of the '“real” item. (making sure Temp is always read or calculated) I think that would avoid avoid unexpected state changes without applying reentrant locks.

An alternative approach would be to have a ‘virtual’ item alongside that only ever holds the C value.

and to be absolutly sure, i would do something like that:

myTemp = Temperature_FF_SammyBedroom.state as DecimalType
if(myTemp  > 40) {
	myTemp = (myTemp - 32) *5/9 //converts F to C
	postUpdate(Temperature_FF_SammyBedroom, myTemp)
//your fire rule with myTemp as variable

but i must point out, that your fire rule will only fire up a 39C, after that it will convert 40 like it was 40F to C.

40F = 4C, did it really go that down in your home?

You could easily trigger your rule at 55. That will be better for your fire rule.