How to DEBUG your RULES

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
dampa
Normal user
Posts: 28
Joined: 19 Jul 2018, 01:48

How to DEBUG your RULES

#1 Post by dampa » 31 Mar 2019, 19:03

Here is my method for debugging RULEs while I'm developing and I hope it helps some people out.

First thing is to add a 'Generic - Dummy Device', name it 'data' and name one of the variables 'debug'. For our example, let's assume you select device 12 and named the first variable 'debug' .

Now in your rules just add anywhere you want
TaskValueSet,11,1,n.m // debug
I suggest if you have more than one 'on xxxxx do' use 1.m for the first on/do, 2.m for the second etc. In addition change m for each debug spot. As the rules fire, the variable will change telling you where you are. It's really helpful when your rules do what you told them to do, not want them to do. :D

Or in other words, things just don't work and you don't know why. This will at least tell you the last part of the rule that worked.

Here is an example from a ruleset I use
==============
on dataReq do
TaskValueSet,12,1,1.1 // debug <<<<<<<<<<<<<<<<<

TaskValueSet,12,1,%eventvalue1% // set rxGroupID from received message
TaskValueSet,12,2,%eventvalue2% // set rxNodeID from received message
TaskValueSet,12,3,%eventvalue3% // set requesterID from received message

// is this a 'all' group or a requset for my group
if [rx#rxGroupID] = [my#groupID] or [rx#rxGroupID] = 0
TaskValueSet,12,1,1.2 // debug <<<<<<<<<<<<<<<<<
event checkNode // yes go check node requested
endif
endon

on checkNode do
TaskValueSet,12,1,2.1 // debug <<<<<<<<<<<<<<<<<
// is this a 'all' nodes or a request for my node
if [rx#rxNodeID] = [my#nodeID] or [rx#rxNodeID] = 0
TaskValueSet,12,1,2.2 // debug <<<<<<<<<<<<<<<<<
event sendData // yes go send the data
endif
endon
==============

User avatar
dynamicdave
Normal user
Posts: 132
Joined: 30 Jan 2017, 20:25
Location: Hampshire, UK
Contact:

Re: How to DEBUG your RULES

#2 Post by dynamicdave » 04 Apr 2019, 13:46

What a clever idea.
It will be extremely useful in developing some of my Rule-Sets.
Thanks for sharing.

lairnewtons
Normal user
Posts: 1
Joined: 06 Apr 2019, 21:42

Re: How to DEBUG your RULES

#3 Post by lairnewtons » 06 Apr 2019, 21:44

What a great idea?!
I luve it! Very useful!
Thank for sharing :D
"Believe in the spirit of love, it can heal all things!"
Download granny 2.0

Post Reply

Who is online

Users browsing this forum: dynamicdave and 4 guests