Error importing RM

Hi @bravenel

On FB somebody asked how to display sunset & sunrise on dashboard tiles. I did a quick example and took screenshots and then somebody else asked if i could export the rule. So this is the first time i am playing with the feature.

This is on my C7 with 2.2.4.145

I exported the RM, deleted the RM, then attempted a Restore, received the following error.

And the logs show:

The rule did import and looks ok, but when i click on Rule Machine again in apps i gets this:

With the same error in the logs.

Is this a result of importing a rule with local variables and connectors?

If RM is stuck with an error, you need to restore your DB. I will look into that rule to see if I can see the problem.

thank you.

I was just waiting for your reply before doing that, just in case you wanted more info.
I also replicated this on my C5 'sandbox'

Also interesting is that i can delete the rule, but i still get the error when clicking on Rule Machine. The when i go back to Apps, the deleted rule re-appears.

I just created the same rule and backed it up then restored it with no error.

interesting. can i send you my .json?

Also, would you recommend a soft reset first & then restore or just a restore?

Just post the json (as code </>) with Hide Details (gear icon in the compose post window). You can simply restore your db. I'm going to add a warning about making a backup of the db before messing with these features.

First time doing this ... learn something every day :wink:

Routine - pull sunset_sunrise.json

{"deviceReplacements":{},"appReplacements":{"3395":{"appTypeName":"Rule-4.0","appTypeNamespace":"hubitat","appName":"Rule-4.0","appLabel":"Routine - pull sunset/sunrise","parentAppTypeName":"Rule Machine","parentAppLabel":"Rule Machine","singleInstance":false}},"appData":{"3395":{"state":{"actionListMain":["1","2"],"connectors":{"Sunrise.time":{"id":"4138","type":"Variable"},"Sunset.time":{"id":"4139","type":"Variable"}},"actionDone":true,"lv.Sunset.time":"2020-11-24T21:46:00+0000","hasRuleAct":false,"selectActionsParams":{"thisStr":"Main","label":"Routine - pull sunset/sunrise"},"editCondIf":null,"usesTime":false,"trigCustoms":[],"repeating":[],"capabDone":true,"lastEvtName":"Triggered","skippingMain":false,"locationBlocked":[],"lvt.Sunset.time":"Time","ndx.false":1,"lvList":["Sunrise.time","Sunset.time"],"ruleNdx":1,"timeTriggers":[],"allVarsO":["Detected.lock.code","Door.controller.status","Door.trigger.id","Garage.controller.status","Kitchen.evening.holdoff","Sunrise.time","Sunset.time","Welcome.arrival","Welcome.timer"],"actLabelIndent":"","howManyT":2,"subscribedVariables":[],"certainTimes":[],"prevState":{"PB":"true"},"capabstrue":{"1.true":"When time is 4:00 AM EST","2.true":{}},"lastEvtDate":"24-Nov-2020","actionsMain":{"1":{"wait":null,"delay":"","modes":{},"method":"getSetVariable","indent":"","rule":0,"label":"Set Sunrise.time to sunrise time\n","cond":0},"2":{"wait":null,"delay":"","modes":{},"method":"getSetVariable","indent":"","rule":0,"label":"Set Sunset.time to sunset time\n","cond":0}},"nestedInIf":[],"actNdx":3,"installed":true,"lastEvtValue":0,"waitEvents":[],"private":"true","gvList":["Detected.lock.code","Door.controller.status","Door.trigger.id","Garage.controller.status","Kitchen.evening.holdoff","Welcome.arrival","Welcome.timer"],"hasDevice":null,"ndx.true":2,"allVars":{"Sunrise.time":{"val":"2020-11-24T12:26:00+0000","type":"Time"},"Welcome.arrival":{"val":0,"type":"Number"},"Garage.controller.status":{"val":1,"type":"Number"},"Door.trigger.id":{"val":"physical","type":"String"},"Detected.lock.code":{"val":"Steve","type":"String"},"Welcome.timer":{"val":0,"type":"Number"},"Door.controller.status":{"val":1,"type":"Number"},"Sunset.time":{"val":"2020-11-24T21:46:00+0000","type":"Time"},"Kitchen.evening.holdoff":{"val":"2020-11-12T20:00:00.000-0500","type":"Time"}},"simpleCond":false,"nestedRepIf":[],"nestedBlockMain":[],"lastEvtTime":"02:04 PM","lv.Sunrise.time":"2020-11-24T12:26:00+0000","lvt.Sunrise.time":"Time","cutAction":[],"nestedIfMain":[],"nestedLabel":[],"paramNdx":1,"lastEvtDevId":null,"varUseList":{},"waitCondNdx":1,"token":0,"nestedSkipAllMain":[],"capabsfalse":{},"timeTriggersW":{},"timeFormat":"hh:mm a","waitConds":[]},"appSettings":[{"deviceList":null,"multiple":false,"name":"tCapab1","type":"enum","value":"Certain Time"},{"deviceList":null,"multiple":false,"name":"tCapab2","type":"enum","value":""},{"deviceList":null,"multiple":false,"name":"actionDone","type":"button","value":""},{"deviceList":null,"multiple":false,"name":"runAction","type":"button","value":""},{"deviceList":null,"multiple":false,"name":"pausRule","type":"button","value":""},{"deviceList":null,"multiple":false,"name":"deleteLv:Sunrise.time","type":"button","value":""},{"deviceList":null,"multiple":false,"name":"actSubTypeMain.1","type":"enum","value":"Set Variable"},{"deviceList":null,"multiple":false,"name":"valTimeOpMain.2Sunset.time","type":"enum","value":"Sunset"},{"deviceList":null,"multiple":false,"name":"actSubTypeMain.2","type":"enum","value":"Set Variable"},{"deviceList":null,"multiple":false,"name":"cancelLv","type":"button","value":""},{"deviceList":null,"multiple":false,"name":"insertAct","type":"enum","value":""},{"deviceList":null,"multiple":false,"name":"delete","type":"enum","value":""},{"deviceList":null,"multiple":false,"name":"goof","type":"button","value":""},{"deviceList":null,"multiple":false,"name":"editLv:Sunset.time","type":"button","value":""},{"deviceList":null,"multiple":false,"name":"cancelCon","type":"button","value":""},{"deviceList":null,"multiple":false,"name":"time1","type":"enum","value":"A specific time"},{"deviceList":null,"multiple":false,"name":"deleteLv:Sunset.time","type":"button","value":""},{"deviceList":null,"multiple":false,"name":"locVar","type":"text","value":""},{"deviceList":null,"multiple":false,"name":"varType","type":"enum","value":""},{"deviceList":null,"multiple":false,"name":"capab","type":"enum","value":""},{"deviceList":null,"multiple":false,"name":"createCon:Sunrise.time","type":"button","value":""},{"deviceList":null,"multiple":false,"name":"valTimeOpMain.1Sunrise.time","type":"enum","value":"Sunrise"},{"deviceList":null,"multiple":false,"name":"actionCancel","type":"button","value":""},{"deviceList":null,"multiple":false,"name":"createCon:Sunset.time","type":"button","value":""},{"deviceList":null,"multiple":false,"name":"refreshActions","type":"button","value":""},{"deviceList":null,"multiple":false,"name":"deleteCon:Sunset.time","type":"button","value":""},{"deviceList":null,"multiple":false,"name":"editAct","type":"enum","value":""},{"deviceList":null,"multiple":false,"name":"myVarsMain.2","type":"enum","value":"Sunset.time"},{"deviceList":null,"multiple":false,"name":"editLv:Sunrise.time","type":"button","value":""},{"deviceList":null,"multiple":false,"name":"myVarsMain.1","type":"enum","value":"Sunrise.time"},{"deviceList":null,"multiple":false,"name":"comments","type":"textarea","value":""},{"deviceList":null,"multiple":false,"name":"hasAll","type":"button","value":""},{"deviceList":null,"multiple":false,"name":"cancelCapab","type":"button","value":""},{"deviceList":null,"multiple":false,"name":"cutAct","type":"enum","value":""},{"deviceList":null,"multiple":false,"name":"atTime1","type":"time","value":"04:00"},{"deviceList":null,"multiple":false,"name":"deleteCon:Sunrise.time","type":"button","value":""},{"deviceList":null,"multiple":false,"name":"delayActMain.1","type":"bool","value":""},{"deviceList":null,"multiple":false,"name":"origLabel","type":"text","value":"Routine - pull sunset/sunrise"},{"deviceList":null,"multiple":false,"name":"varValue","type":"time","value":""},{"deviceList":null,"multiple":false,"name":"moreVar","type":"button","value":""},{"deviceList":null,"multiple":false,"name":"delayActMain.2","type":"bool","value":""},{"deviceList":null,"multiple":false,"name":"actTypeMain.2","type":"enum","value":"Set Mode, Variables or File, Run Custom Action"},{"deviceList":null,"multiple":true,"name":"logging","type":"enum","value":null},{"deviceList":null,"multiple":false,"name":"editCond","type":"enum","value":""},{"deviceList":null,"multiple":false,"name":"actTypeMain.1","type":"enum","value":"Set Mode, Variables or File, Run Custom Action"},{"deviceList":null,"multiple":true,"name":"deleteAct","type":"enum","value":null},{"deviceList":null,"multiple":false,"name":"actTypeMain.3","type":"enum","value":""},{"deviceList":null,"multiple":false,"name":"updateRule","type":"button","value":""}],"subscriptions":[{"handler":"connHandler","name":"variable","type":"DEVICE","typeId":4138,"typeName":"Sunrise.time","filter":"true"},{"handler":"connHandler","name":"variable","type":"DEVICE","typeId":4139,"typeName":"Sunset.time","filter":"true"}]}}}

Did you have a bunch of devices selected in this rule that you then removed? Had you edited this rule a bunch?

This feature is probably never going to work well for rules that have been put through the wringer...

No. This was a brand new rule that I created from scratch just the other day.

I don’t even think I edited it at all.

If you are seeing something different then I am getting a little concerned about my DB. I pulled it over from my C5 when I did my manual migration.

You mentioned connectors.... Did the original rule have connectors?

Yes it had a variable connector on each local variable.

OK, thanks. Yeah, I just reproduced the error that way. I'll look into it. It does try to remove connectors on import/restore, so maybe it messed that part up.

Wait. It was probably me.

I have been trying to get rid of my ghost connectors on my other C5 that I have hub meshed with my C7.

This morning I blew away all the rule machine connectors in the device page on both C7/C5 and I didn’t rebuild them yet.

Now after I restored, I see those local variable connectors were part of what I ripped out.

I am my worst enemy. I am sorry I wasted your time.

Edit. Illuminance connectors do not seem to get posted in the global variable chart but they do get created under the rule machine in devices.

Edit 2 : but I am still concerned that you thought the rule was heavily edited.

No, this isn't something you did.

No, json is just friggin hard to look at, let alone try to read!

I was able to recreate the error by simply adding connectors to the two local variables. So, something else is wrong with the import code. Looking into it.

1 Like

thank you for not being anoyed with me :wink:

Whew! got it. thanks.

Cool. now i feel somewhat useful. lol.

indent is your friend.

1 Like

We found this bug. Fix in next release.

3 Likes

Any chance you could add export/import for Simple Automation Rules?

Maybe. I started to but ran into some issues with the automatic naming. Just haven't had a chance to sort that out.

1 Like

cool. thank you sir.