The Vera Community forums have moved!

Advanced => Plugins & Plugin Development => Programming => VeraAlerts => Topic started by: RichardTSchaefer on November 22, 2016, 10:09:35 am

Title: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: RichardTSchaefer on November 22, 2016, 10:09:35 am
There have been problems saving changes to Message Overrides since earlyl in 2016.

MCV has changed the API for scenes in UI 7.19  to solve various problems with scenes. (Notifications in Vera are implemented as scenes).
If you are having problems with Saving Vera Alerts I recommend upgrading to the UI 7.19 firmware.
See:
   http://forum.micasaverde.com/index.php/topic,40391.0.html#new

And upload the attached Vera Alerts File (Apps -> Develop Apps -> Luup Files -> Upload)
(Remove the .txt extension first!)

I will be releasing this about 1 week after Vera Makes the 7.19 release official.


If you constantly get a message indicating that XXX notifications have been updated when you open the Vera Alert Editor ... you are having problems saving changes.
With this update, you should only get this messages when a notification is created or changed!
Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: Spanners on December 20, 2016, 09:36:49 pm
Has this been pushed out via apps.mios.com now or is it still a manual update?

Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: RichardTSchaefer on December 21, 2016, 10:09:57 am
It' in MCV audit for a couple of days.
When you see Version 7.21 ... you will not need this patch.
Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: Aaron on December 26, 2016, 04:39:43 pm
Richard,
running VeraPlus UI7 1.7.2414

just uploaded the .js you posted and now get "ERROR : Error in lua for scenes and events"

I tried opening Vera Alerts device and, didn't modify anything, then closed it and got the message "Failed to save system configuration."

thoughts on how to troubleshoot?

thx
Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: Sender on December 26, 2016, 04:42:16 pm
Hi, i had the same. Follow the first post and press f5 or try another browser. It was a caching problem with me.
Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: Aaron on December 26, 2016, 04:46:01 pm
Hi, i had the same. Follow the first post and press f5 or try another browser. It was a caching problem with me.

just tried both Chrome (always use this for Vera) & FF (my daily browser for everything else)... same problem.
Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: Sender on December 26, 2016, 04:47:56 pm
Do you see version exp2.0 in reports? Reports from veralerts? Else you dont have rhe latest...
Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: Aaron on December 26, 2016, 07:28:10 pm
Do you see version exp2.0 in reports? Reports from veralerts? Else you dont have rhe latest...

says 7.15 ... I looked at the file Richard posted, it shows Version:"7.15" inside the file
Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: Aaron on December 26, 2016, 07:39:59 pm
Do you see version exp2.0 in reports? Reports from veralerts? Else you dont have rhe latest...

Can you please post or send me your version?  I'm going to force the re-install of the app using the URL but would like to get this fixed with the manual update if possible. thx
Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: Sender on December 27, 2016, 12:57:54 am
It is in the 1st post.  That is the version.
Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: Aaron on December 27, 2016, 01:10:35 am
It is in the 1st post.  That is the version.

that is what caused the problem for me... and it says version 7.15, not exp2.0

I just reloaded the app store version and the error is gone.
Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: Sender on December 27, 2016, 02:02:52 am
So sorry, this is exp2.0: http://forum.micasaverde.com/index.php/topic,37675.0.html
Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: Spanners on December 29, 2016, 07:32:07 am
After the upgrade to latest firmware I can't create any new scenes, and every time I exit VeraAlerts I see this error:

Failed to save system configuration.

I've installed the .js in the original post, but no change.

Any suggestions? (I've opened a ticket with support for this issue, and have an already open one where I can't create associations and see the same error message).

Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: Aaron on December 29, 2016, 10:25:26 am
Open the link in the post above yours

Sent from my SM-G935T using Tapatalk

Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: Spanners on January 02, 2017, 03:45:41 am
Richard,

Been looking through my user_data.json to see if I can find what Vera is choking on. Current status is can't change any configuration other than adding or deleting devices. Can't modify scenes, enable/disable notifications etc.

Looking at Vera Alerts related things I see about 17 alerts in the format of:

"lua": "--[[StartVeraAlerts]]luup.call_action('urn:richardgreen:serviceId:VeraAlert1','DeviceNotification', ..................

And others in the form of:

"lua": "LS1bW1N0YXJ0VmVyYUFsZXJ0c11dbHV1cC5jYWxsX2FjdGlvbigndXJuOnJpY2hhcmRncmVlbjpzZXJ2aWNlSWQ6VmVyYUFsZXJ0MS ................................

associated with "encoded_lua": 1


Should all of the VeraAlerts scene edits be in the encoded format now?




Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: RichardTSchaefer on January 02, 2017, 01:15:49 pm
this appears to be yet another Vera bug.
It seems you might need to encode things even if they do not need to be encoded.

You can force Vera Alerts to modify everything by going to settings ... then disable Notifications  ... exit ...
Then open again and enable notifications.
Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: Spanners on January 02, 2017, 04:13:56 pm
this appears to be yet another Vera bug.
It seems you might need to encode things even if they do not need to be encoded.

You can force Vera Alerts to modify everything by going to settings ... then disable Notifications  ... exit ...
Then open again and enable notifications.

Bingo!

Doing this cleared the saving configuration error and I was able to make changes to scenes, associations etc. if I made changes to a message override I had to repeat it, I guess veraalerts is still selectively encoding on single modification?

Any chance of a hotfix JS file with always encode set to validate the Vera bug?


Edit: can only create or modify scenes if they don't have a notification. Presumably due to selective encoding again.
Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: Rodger3876 on January 03, 2017, 07:06:42 pm
Tried this process. It toke 4 tries to get Process Notification to uncheck? Now I can not get it to go back On? Frustrated & will wait and see what things look like in the Morn.
Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: RichardTSchaefer on January 04, 2017, 06:40:39 am
If you have any other scenes with LUA in them ... that are not part of a Notification ... then there is still a MCV bug.

The latest change to the Vera Scene API created a chicken and egg problem.
Vera works with scenes that had LUA that are PRE-API change.
However if you have any scene with LUA (And notifications are hidden scenes) than if you try to modify ANY scene  (Regular scene or standard scene) you have to modify ALL the scenes to use the new API .

Well my workaround only fixes the notification scenes. It forces all notification scenes to be converted to the new API in one shot. It does not fix NON notification scenes.

Vera is going to have to release a FIX for those that try to save data when you have scenes with LUA.
You may be able to fix this as follows:
1) Start with the lowest scene.
2) Edit any scene that has LUA. 
     Make a simple change to the LUA like add a space character somewhere ...
3)  Save the scene .. you will get an error.
4)  Keep doing this until you edit all of your scenes.

DO NOT refresh your browser during this time.

Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: Spanners on January 04, 2017, 07:23:34 am
Or put a notification on every scene and let VeraAlerts update them all.

This worked for me. :)
Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: Aaron on January 04, 2017, 11:19:59 am
If you have any other scenes with LUA in them ... that are not part of a Notification ... then there is still a MCV bug.

The latest change to the Vera Scene API created a chicken and egg problem.
Vera works with scenes that had LUA that are PRE-API change.
However if you have any scene with LUA (And notifications are hidden scenes) than if you try to modify ANY scene  (Regular scene or standard scene) you have to modify ALL the scenes to use the new API .

Well my workaround only fixes the notification scenes. It forces all notification scenes to be converted to the new API in one shot. It does not fix NON notification scenes.

Vera is going to have to release a FIX for those that try to save data when you have scenes with LUA.
You may be able to fix this as follows:
1) Start with the lowest scene.
2) Edit any scene that has LUA. 
     Make a simple change to the LUA like add a space character somewhere ...
3)  Save the scene .. you will get an error.
4)  Keep doing this until you edit all of your scenes.

DO NOT refresh your browser during this time.
Could this api problem be causing my LUA startup errors? I get them now and I never did on UI5. Log error says there is no 'end', on every one...  As I remove the code from the lowest to highest. Haven't done them all yet.

I may look at if there is a way to use PLEG to avoid Lua startup code in any of the scenes. I  basically have the scene check my custom PLEG scenes (which is tracked by multi switches) and if in certain modes, like vacation mode, the scene doesn't trigger.

Maybe I should have PLEG do the checks and simply disable the native vera scene instead?

Sent from my SM-G935T using Tapatalk

Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: RichardTSchaefer on January 04, 2017, 12:18:23 pm
@Spanners

Great idea ... never thought of that ...
Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: Aaron on January 04, 2017, 03:11:39 pm
Figured it out
Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: Rodger3876 on January 05, 2017, 09:04:35 pm
I put Notifications in all my Scenes, It took several attempts but got it done. I still had problems making changes to Vera Alerts? After Letting it sit over nite (24hrs) Every thing seems to be OK Tonight. I have been able to make changes & they hold & system has smoothed out. Thanks
Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: dklinkman on January 08, 2017, 10:02:06 pm
This seems the most relevant thread for my problem.  Hope so.  Late Nov / Dec I started having problems with VeraAlerts on my main Vera 3.  Usually I could open the configuration and save and it would start working again.  Come Jan it isn't working at all.  In the process of forcing a firmware upgrade at MCV request I hosed my system.  Still working that out.

So I switched to my backup Vera 3.  Very simple config.  Just one Z-Wave device (a switch) and some virtual devices.  Firmware 1.7.902, VeraAlerts 7.21.  No scenes, no startup Lua.  One device like I said.

Within AltUI I added a notification to the switch to notify when switched on.  In the notification I selected my id to be notified (vs default).  So far so good.

Under VeraAlerts clicked edit.  Checked all the settings.  Made a simple message override for the notification.  The report is attached to this post.

I tested and verified that alerts are working when initiated manually.  But the alert from the notification is never sent.  This is what I was seeing on the other Vera also where I have 90+ alerts configured.

I also notice that when I go into the edit message overrides, it will often say '1 device notification updated'.  Even when there were no updates.  In fact there have been no updates since I created that single notification.  I saw this behavior on the other Vera also.  When I close and then reopen the edit, that message is gone.  But not long after it is back.  I've tried the various remedies suggest in this thread bit no change.  I've restarted Vera more than once to make sure I am not hitting the 20 message limit (on this Vera, the other one is licensed).

So I'm happy I've been able to replicate the problem in a simple environment.  But I'm stuck.  I've turned on verbose logging and thankfully there's not much going on in this Vera but even so I'm not seeing any standout errors.  But I don't know what to look for,

Hopefully Richard or someone can offer suggestions for what to look for or what to do to fix.

Thanks   --David
Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: RichardTSchaefer on January 09, 2017, 06:22:12 am
Do you have any LUA or Startup LUA in scenes ?
Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: dklinkman on January 09, 2017, 06:30:22 pm
None.  I was careful to verify that on the original unit also.  On the second unit I am running with just a single switch and notification, and no scenes, and I verified no startup Lua.

Attached below is the configuration of the entire Vera.  The PLEG is unconfigured as is the PLTS.
Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: RichardTSchaefer on January 09, 2017, 07:13:42 pm
Did you try:

1) In Vera Alerts Settings, Disable Notifications
2) Reload Vera ...  Refresh Browser
3) Enable Notifications
4) Reload Vera ... Refresh Browser
5) Go into Vera Alert Settings ... do you seen any updates needed ?
Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: dklinkman on January 09, 2017, 07:15:26 pm
Yes did that.  Update message goes away.  But then comes back after a bit.

I will try it again now using your exact sequence.
Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: dklinkman on January 09, 2017, 07:22:31 pm
Ok, haven't noticed this before.  I went back to UI7 to try your sequence just have AltUI out of the picture.  I usually work in AltUI when possible.

When I click the Edit tab under VeraAlerts I get the following error message on the screen.  Screenshot below also.

Code: [Select]
Error executing function vaInit(): Cannot read property 'Init' of undefined
Under AltUI the edit panel appears and I can alter settings just fine.  Though that update message does come back.
Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: RichardTSchaefer on January 09, 2017, 08:57:37 pm
Something is messed up in your configuration ....

Login via ssh
     cd /etc/cmh-ludl
     rm -i *VeraAlert*

Reboot (power cycle) your vera.
If it does not reload the Plugin files ... Update the plugin manually.

Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: dklinkman on January 09, 2017, 10:25:21 pm
I did as you suggested including rebooting the vera.

It looks like the plugin reloaded just fine.  But the same error persists as before.
Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: dklinkman on January 11, 2017, 08:54:29 pm
I see in the logs that apparently user data format changed leading to the current firmware version.  Could that be a factor?

I'm still stuck here with no functioning VeraAlerts.  Main vera is still hosed though MCV is trying to fix that.  Months of backups and none of them work.
Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: RichardTSchaefer on January 12, 2017, 07:57:34 pm
I do not know what to say ... other than to remove all scenes (and startup LUA)  and notifications ... and start over.
Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: dklinkman on January 12, 2017, 08:06:07 pm
Ok...  Except....  Am I talking to the wall?....  I have no scenes, no startup Lua...  ONE z-device and ONE notification that I have added and removed at least a few times.  Does the use case get any simpler?  What am I looking for?

I would try to troubleshoot your code except that you encrypted it.

What?
Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: RichardTSchaefer on January 13, 2017, 09:25:53 am
Turn on debug ... reload ... and do a send alert from the editor ... check the log file ...


Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: Spanners on January 19, 2017, 05:55:01 am
I'm back to being stuck.

Don't get notifications updated when I go into VeraAlerts, but if I try to edit one I get the "Failed to save system configuration." error on exit and sometimes a "Failed to save msgoverride" pop up in the VeraAlerts editor.

Disabling/Enabling notifications doesn't resolve it.



Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: RichardTSchaefer on January 19, 2017, 09:46:44 am
Do you have other scenes with LUA code or startup LUA ?
Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: Spanners on January 20, 2017, 06:27:07 am
Do you have other scenes with LUA code or startup LUA ?


Yes, but all the scenes are set up with VeraAlerts notifications so they should be getting encoded properly. I have 2 lines in startup LUA.

Code: [Select]
emoncode = require("EnergyMonitor")
emoncode.EnergyMonitorOnTimer()
Title: Re: UI7 - Saving Vera Alerts Configuration Prior to UI 7.19
Post by: RichardTSchaefer on January 20, 2017, 06:40:21 am
You may have to remove the startup lua ... let Vera alerts upgrade the scenes .. then add the startup lua back later.

MCV software will only update one thing at a time ... and fail if there are any other that are not updated.
Also Vera has the option for Scene Level LUA and Trigger Level LUA ... the Vera Alerts will only only update the Scene Level Lua code.
So it may not work for you and you may need to wait for a MCV fix.