Author Topic: [solved] resetting AltUI device does not start workflows from their start state  (Read 870 times)

Offline pls90

  • Sr. Member
  • ****
  • Posts: 307
  • Karma: +2/-0
I updated to the latest version (running AltUi on openLuup).
One of my workflows which ramps down light of a dimmer would not turn off the light.
I looked into it and it seems that all workflows which make use of Bag variables have lost these variables.
I mean that they are not empty but entirely missing, clicking on "Bag" in a workflow says "No data to display".
My Bags are defined in a "init" state right upon startup, so resetting the workflow will bring them back.
I tried resetting AltUI entirely, after that the Bags are missing again.
I am not sure if resetting is the cause for their disappearance or if they get lost over time.
A full reset should initialize all of the workflows, right?
Log attached.
« Last Edit: January 17, 2018, 08:09:17 am by pls90 »

Offline amg0

  • Moderator
  • Sr. Hero Member
  • *****
  • Posts: 2963
  • Karma: +194/-8
Re: Bag Variables disapearing on AltUI v2.09.2284
« Reply #1 on: January 07, 2018, 12:20:55 pm »
I updated to the latest version (running AltUi on openLuup).
One of my workflows which ramps down light of a dimmer would not turn off the light.
I looked into it and it seems that all workflows which make use of Bag variables have lost these variables.
I mean that they are not empty but entirely missing, clicking on "Bag" in a workflow says "No data to display".
My Bags are defined in a "init" state right upon startup, so resetting the workflow will bring them back.
I tried resetting AltUI entirely, after that the Bags are missing again.
I am not sure if resetting is the cause for their disappearance or if they get lost over time.
A full reset should initialize all of the workflows, right?
Log attached.

the Bags are remembered in the variable "WorkflowsVariableBag"

The following situation would reset the Bag
- resetWorkflow(wflow_altuiid) resets bag for a given workflow
- enableWorkflows(false) ( the change of the workflow mode of the ALTUI device )
- resetDevice()  ( the RESET of ALTUI device )
- a luup startup when the ALTUI LUA file version is increased. this calls resetDevice() to make sure everything starts clean. since resetDevice() also resets workflow states, every workflow should start from their start state


Offline pls90

  • Sr. Member
  • ****
  • Posts: 307
  • Karma: +2/-0
Re: Bag Variables disapearing on AltUI v2.09.2284
« Reply #2 on: January 07, 2018, 12:25:35 pm »
I tried reset on the AltUI device. After that all my bags are gone.

Offline amg0

  • Moderator
  • Sr. Hero Member
  • *****
  • Posts: 2963
  • Karma: +194/-8
Re: Bag Variables disapearing on AltUI v2.09.2284
« Reply #3 on: January 07, 2018, 12:33:25 pm »
I tried reset on the AltUI device. After that all my bags are gone.
that is what I wrote

Offline pls90

  • Sr. Member
  • ****
  • Posts: 307
  • Karma: +2/-0
Re: Bag Variables disapearing on AltUI v2.09.2284
« Reply #4 on: January 07, 2018, 12:38:38 pm »
so how do you get 20 workflows in a state they will work again? opening every single one of them an clicking reset? Shouldn't that be part of the AltUI reset process?

Offline amg0

  • Moderator
  • Sr. Hero Member
  • *****
  • Posts: 2963
  • Karma: +194/-8
Re: Bag Variables disapearing on AltUI v2.09.2284
« Reply #5 on: January 07, 2018, 03:03:57 pm »
so how do you get 20 workflows in a state they will work again? opening every single one of them an clicking reset? Shouldn't that be part of the AltUI reset process?

after a reset , all workflow start from their START state, they should init and work from there.

Offline pls90

  • Sr. Member
  • ****
  • Posts: 307
  • Karma: +2/-0
Re: Bag Variables disapearing on AltUI v2.09.2284
« Reply #6 on: January 08, 2018, 07:10:37 am »
they didnt when I tested. After initial state i have a init state in which i set the bag variables in the lua section. After central AltUI reset every workflow with init state had no bag variable (no data to display) only manually clicking reset in each workflow fixed that.

Offline pls90

  • Sr. Member
  • ****
  • Posts: 307
  • Karma: +2/-0
resetting AltUI device does not start workflows from their start state
« Reply #7 on: January 14, 2018, 10:18:54 am »

The following situation would reset the Bag
- resetWorkflow(wflow_altuiid) resets bag for a given workflow
- enableWorkflows(false) ( the change of the workflow mode of the ALTUI device )
- resetDevice()  ( the RESET of ALTUI device )
- a luup startup when the ALTUI LUA file version is increased. this calls resetDevice() to make sure everything starts clean. since resetDevice() also resets workflow states, every workflow should start from their start state
amg, on my openLuup/AltUI system and on Vera Plus reset of the AltUI device does wipe Bag variables but does NOT restart workflows from their start state leaving them in a non functioning state as all the Bag variables are missing.
From what you replied I think this is not working as intended.
Could you please have a look?
Thank you.

Offline amg0

  • Moderator
  • Sr. Hero Member
  • *****
  • Posts: 2963
  • Karma: +194/-8
Re: resetting AltUI device does not start workflows from their start state
« Reply #8 on: January 14, 2018, 12:17:13 pm »
You need to capture in the log a full restart sequence in debug mode so we can investigate that

Offline pls90

  • Sr. Member
  • ****
  • Posts: 307
  • Karma: +2/-0
Re: resetting AltUI device does not start workflows from their start state
« Reply #9 on: January 15, 2018, 11:51:48 am »
it is attached to the first post.

Offline amg0

  • Moderator
  • Sr. Hero Member
  • *****
  • Posts: 2963
  • Karma: +194/-8
Re: resetting AltUI device does not start workflows from their start state
« Reply #10 on: January 15, 2018, 12:20:27 pm »
it is attached to the first post.

I do not see any sign of a startup sequence in these logs. when ALTUI starts up it writes in the log something like
"initstatus(devicenum) , starting version <version>"
the workflow reset happening during the startup, we cannot see it in these logs

Offline pls90

  • Sr. Member
  • ****
  • Posts: 307
  • Karma: +2/-0
Re: resetting AltUI device does not start workflows from their start state
« Reply #11 on: January 15, 2018, 12:57:16 pm »
This is what I am doing (raspi on openLuup):
1. turn on debug
2. goto workflow, open one with bag variable, check if Bag variable is populated, OK, looking good
3. goto devices > Altui device, control > reset. Message. "Controller did not respond", so there was a reload
4. goto workflow, open same wf with bag variable, check if Bag variable is populated, "no data to display"
5. download log file, looking for "initstatus", nothing in there, new log attached

Could it be that the missing initstatus is the cause for the issue I am experiancing?
If it was actually doing the initstatus I would not see the Bag variables disappear, right?

If I missed something in the steps above please let me know.

Offline amg0

  • Moderator
  • Sr. Hero Member
  • *****
  • Posts: 2963
  • Karma: +194/-8
Re: resetting AltUI device does not start workflows from their start state
« Reply #12 on: January 15, 2018, 02:52:38 pm »
This is what I am doing (raspi on openLuup):
1. turn on debug
2. goto workflow, open one with bag variable, check if Bag variable is populated, OK, looking good
3. goto devices > Altui device, control > reset. Message. "Controller did not respond", so there was a reload
4. goto workflow, open same wf with bag variable, check if Bag variable is populated, "no data to display"
5. download log file, looking for "initstatus", nothing in there, new log attached

Could it be that the missing initstatus is the cause for the issue I am experiancing?
If it was actually doing the initstatus I would not see the Bag variables disappear, right?

If I missed something in the steps above please let me know.

there is something strange, but I think we miss some logs here, maybe you should ask akbooer what he thinks , why do not we see the startup sequence. the RESET button calls resetDevice lua function which as you can see below should write immediately something in the log

Second potential issue is due to the future 7.27 firmware where we have to use the /port_3480/ notation and to trigger the reload I use this line of code which maybe openluup does not execute and the reload is not happening maybe

( luup.inet.wget("http://localhost/port_3480/data_request?id=reload",10) )


Code: [Select]
function resetDevice(lul_device,reload)
lul_device = tonumber(lul_device)
log(string.format("resetDevice(%d,%s)",lul_device, tostring(reload or "nil")))

if (reload ~= true) then
reload = false
end

-- reset the config
local tbl = getDefaultConfig()
local default = json.encode( tbl )
debug(string.format("Reseting ALTUI config to %s",default))
setVariableIfChanged(ALTUI_SERVICE, "PluginConfig", default, lul_device)

-- reset workflows and timers
Workflows = {}
WorkflowsActiveState = {}
WorkflowsVariableBag = {}
ForcedValidLinks = {}
Timers = {}
luup.variable_set(ALTUI_SERVICE, "WorkflowsActiveState", json.encode(WorkflowsActiveState), lul_device)
luup.variable_set(ALTUI_SERVICE, "WorkflowsVariableBag", json.encode(WorkflowsVariableBag), lul_device)
luup.variable_set(ALTUI_SERVICE, "Timers", "", lul_device)
luup.variable_set(ALTUI_SERVICE, "EmonCmsUrl", "emoncms.org", lul_device)
setVariableIfChanged(ALTUI_SERVICE, "SWVersion", SWVERSION, lul_device)

if (reload==true) then
debug("Forcing a Luup reload")
local httpcode,data = luup.inet.wget("http://localhost/port_3480/data_request?id=reload",10)
end
end

Offline akbooer

  • Master Member
  • *******
  • Posts: 6070
  • Karma: +268/-69
  • "Less is more"
Re: resetting AltUI device does not start workflows from their start state
« Reply #13 on: January 15, 2018, 05:54:30 pm »
there is something strange, but I think we miss some logs here, maybe you should ask akbooer what he thinks , why do not we see the startup sequence.

Indeed.  My thoughts exactly when I looked at the first lines of the log...

Code: [Select]
2018-01-15 18:48:15.564   :: openLuup LOG ROTATION :: (runtime 0.0 days)
2018-01-15 18:48:15.565   luup_log:3: ALTUI: debug: Wkflow - Condition new=="1" is evaluated in real time - no TriggerOnly

This indicates that this is not the first log file since reload, and the log must have rotated at least once.  Worth looking for LuaUPnP.log.1 shortly after reload to see if this is the case.  The first lines of a log immediately after a reload should look like this...

Code: [Select]
2018-01-15 22:49:16.596   :: openLuup LOG ROTATION :: (runtime 0.0 days)
2018-01-15 22:49:16.633   openLuup.init:: init phase completed
2018-01-15 22:49:16.634   openLuup.server:: starting HTTP server on 0.0.0.0:3480 tcp{server}: 0x1940358
2018-01-15 22:49:16.634   openLuup.scheduler:: starting
2018-01-15 22:49:16.634   openLuup.scheduler:: [2]     openLuup device startup

Quote
Second potential issue is due to the future 7.27 firmware where we have to use the /port_3480/ notation and to trigger the reload I use this line of code which maybe openluup does not execute and the reload is not happening maybe

Code: [Select]
luup.inet.wget("http://localhost/port_3480/data_request?id=reload",10)

That will certainly not reload openLuup since it is directed to a port 80 server.  To make this work in openLuup, you'd have to write:

Code: [Select]
luup.inet.wget("http://localhost:3480/data_request?id=reload",10)
So you certainly have identified two things look look further at here.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline amg0

  • Moderator
  • Sr. Hero Member
  • *****
  • Posts: 2963
  • Karma: +194/-8
Re: resetting AltUI device does not start workflows from their start state
« Reply #14 on: January 16, 2018, 02:28:04 pm »
I have put a version on https://github.com/amg0/ALTUI which should improve the situation. I have fixed a bug in the RESET function of ALTUI