Jump to content

How does it work? Timing etc


hart2hart

Recommended Posts

Posted

I created a simple test program to see how Backup Node server works internally to determine if it runs in line or is launched asynchronously so the program would immediately execute the next step.  I performed a Run (Then) on the program, and it only ran 1-2 seconds (was green) so the wait obviously did not occur.

SecSys:DSC Alarm Test 

If
   - No Conditions - (To add one, press 'Schedule' or 'Condition')
 
Then
        Set 'Backup Ligthing State / Save_Restore lighting' Backup
        Wait  1 minute 
 
Else
   - No Actions - (To add one, press 'Action')
 

I am trying to determine if a wait is needed after the Backup and if so how long of a wait to allow before turning on the All Lights scene to avoid getting wrong light states.  Backup appeared to run asynchronously (based a long or short poll showing in Node server log almost immediately followed about 11 seconds later with a storm of log events naming lots of devices with Node server logging set at debug mode short segment follows with .... used show removed information)  but as a side effect it ended program execution since no Wait 1 minute occurred.  If that's true and as intended, I will need backup in its own program to be run from another program that has multiple sequential steps and with a wait after it is called to allow it time to complete.   Please help me understand the timing and program execution requirements so I don't make wrong assumptions. 

The Node server says no configuration is needed and I assume that means it knows the ISY that it is running on.  How about the long and shortpoll?  Do they have a function and if so what?

 

2022-05-28 10:08:28,756 Command    udi_interface.interface DEBUG    interface:send: PUBLISHING {'set': [{'key': 'customdata', 'value': {'xx xx xx x': {'name': 'Back Porch:Floods', 'value': 0}, ....  }}}]}
2022-05-28 10:08:28,761 Command    udi_interface      DEBUG    backup:query:    Found node Yard:Bird Bath Bottom - Heate with type 2.57.68.0 category 2 and status 0
2022-05-28 10:08:28,762 Command    udi_interface.custom DEBUG    custom:__setitem__: CUSTOM: xx xx xx x = {'name': 'Yard:Bird Bath Bottom - Heate', 'value': 0} ... saving
2022-05-28 10:08:28,763 Command    udi_interface.custom INFO     custom:_save: Sending data customdata to Polyglot.

...

2022-05-28 10:08:28,786 Command    udi_interface      INFO     backup:query: Query processed 169 devices.
2022-05-28 10:08:28,787 Command    udi_interface.interface DEBUG    interface:_parseInput: DEQUEING customdata
2022-05-28 10:08:28,790 Command    udi_interface.interface DEBUG    interface:_parseInput: DEQUEING customdata
2022-05-28 10:08:28,793 Command    udi_interface.interface DEBUG    interface:_parseInput: DEQUEING customdata
2022-05-28 10:08:28,973 MQTT       udi_interface.interface DEBUG    interface:_message: QUEUING incoming message customdata
2022-05-28 10:08:28,975 Command    udi_interface.interface DEBUG    interface:_parseInput: DEQUEING customdata
2022-05-28 10:08:29,012 MQTT       udi_interface.interface INFO     interface:_message: Successfully set key = customdata
2022-05-28 10:08:29,126 MQTT       udi_interface.interface DEBUG    interface:_message: QUEUING incoming message customdata
2022-05-28 10:08:29,127 Command    udi_interface.interface DEBUG    interface:_parseInput: DEQUEING customdata
2022-05-28 10:08:29,164 MQTT       udi_interface.interface INFO     interface:_message: Successfully set key = customdata
2022-05-28 10:08:29,376 MQTT       udi_interface.interface DEBUG    interface:_message: QUEUING incoming message customdata
...

 

Thanks 

Posted

No command sent by the ISY to a node is synchronous. 

In this case, the ISY sends the backup command to the node server node.  It does not wait for any response. The node server then queries every lighting type node for it's status.  It does this one-by-one.  How long it takes to complete will depend on how many devices you have and what else the ISY is busy doing.

Polling is not used.  It only does the queries when asked and same for the restore.

Posted
2 hours ago, TJF1960 said:

@hart2hart I believe a wait with nothing after it will not execute, it needs another command after it in order to wait.

Never though about it but in all normal programs, I got a next command.  Only for this test have I not had a next command.  LOL

2 hours ago, bpwwer said:

No command sent by the ISY to a node is synchronous. 

In this case, the ISY sends the backup command to the node server node.  It does not wait for any response. The node server then queries every lighting type node for it's status.  It does this one-by-one.  How long it takes to complete will depend on how many devices you have and what else the ISY is busy doing.

Polling is not used.  It only does the queries when asked and same for the restore.

Thanks.  I'll watch the Node server log to get a good estimate of how long it takes to process so I can pick a delay.

Posted

Okay, Ive got backup running or at least it goes through steps.  The problem is when I send a restore command there is error in the log.

 

2022-05-28 14:41:12,522 Command    udi_interface      DEBUG    backup:restore: getting custom data to restore: {'address': 'controller', 'cmd': 'RESTORE', 'query': {}}
2022-05-28 14:41:12,523 Command    udi_interface.interface ERROR    interface:_handleInput: _parseInput: failed controller.runCmd(RESTORE) can only concatenate str (not "int") to str
Traceback (most recent call last):
  File "/var/polyglot/.local/lib/python3.8/site-packages/udi_interface/interface.py", line 795, in _handleInput
    self.nodes_internal[item['address']].runCmd(item)
  File "/var/polyglot/.local/lib/python3.8/site-packages/udi_interface/node.py", line 165, in runCmd
    fun(self, command)
  File "/var/polyglot/pg3/ns/00:21:b9:00:f1:fd_7/nodes/backup.py", line 123, in restore
    cmd = '/rest/nodes/' + address + '/cmd/DON/' + self.CustomData[address]['value']
TypeError: can only concatenate str (not "int") to str
2022-05-28 14:41:13,673 MQTT       udi_interface.interface DEBUG    interface:_message: QUEUING incoming message longPoll
2022-05-28 14:41:13,675 Command    udi_interface.interface DEBUG    interface:_parseInput: DEQUEING longPoll
2022-05-28 14:41:13,723 MQTT       udi_interface.interface DEBUG    interface:_message: QUEUING incoming message shortPoll

Posted

Seems like that used to work.  I wonder if a new version of Python is now more strict about that sort of thing.

Posted
Try version 2.0.4, I made some changes that I think should fix that.

Thanks it works great.

For use cases where only a few lights change state, would it be worth considering grabbing the current state at start of restore , comparing before and after state, and only sending REST commands where they are different? Kinda a temporary scene? Add a Restore Differential button?
Guest
This topic is now closed to further replies.

×
×
  • Create New...