-
12th March 2019, 06:34 PM
#1
Automated Home Sr Member
Cortex 'uptime'
The batch files that run when our Cortex server starts up write entries in a log file recording the date and time of each event; over the years this has proven useful when investigating problems, such as when the server reboots unexpectedly.
Recently I decided that it would be helpful to have the latest boot date/time available on a Notice Board rather than having to login to the server and view the logfile. So I started to look at ways of presenting the information so that I could get it via the app on my Android device. I realised that the ideal would be to present a built-in object that held the Cortex start date/time, but that doesn't seem to exist, so I had to construct something similar myself.
I modified a batch file to write the boot date and time to a file 'index.html' in JSON format, set-up a copy of the TinyWeb web server on port 8000 and added a Cortex Web Client API object to read the website at 127.0.0.1 - I now had the information I wanted in a Cortex object that I could present on the Notice Board.
The index.html file looks like this:
{
"At":"17:40:47 on 10-03-2019"
}
When decoded this gives me a Cortex object called "Server Boot At Response 0" under "Web API Client".
I have added the entry 'Server booted at <Web API Client.Server Boot At Response 0=$0>' to "All Display" and connected this to "Martin Notice Board - New Message in" to display a formatted message - it is triggered by the 'Server Boot Finished' signal from the 'Web API Client'.
In order to force the message to be sticky on the Notice Board I send an event to the Web Client API Server Boot Send trigger every 15 minutes.
Although this seems to be working as desired I do have a couple of questions:
1) Is there an easier way of doing this?
2) Is there an existing Cortex object that I could have used instead?
-
13th March 2019, 01:32 PM
#2
Automated Home Legend
short answer is yes ...
have a look at the connections available for World ...
we use its On Initialise Complete connection to provoke announcement of Cortex relaunches via Sound & via AllDisplay ...
our messages including <Time> & other inserts to say when it happened etc ...
Chris
PS: many thanks for posting detail on your approach - could help with some other things we're looking to include ...
-
14th March 2019, 06:20 PM
#3
Automated Home Sr Member
Thanks, I hadn't seen those connection possibilities.
However, On Initialise Complete only seems to offer 'Annunciate' options, and I'm looking for message output - am I missing something?
-
14th March 2019, 07:11 PM
#4
Automated Home Legend
ours is connected like this :
World ... On Initialise Complete ... AllDisplay - CortexRunning Update Text Line
AllDisplay ... Behaviour ... Name CortexRunning / DisplayText as you choose
AllDisplay ... Connections ... CortexRunning Update Text Line - World / On Initialise Complete
AllDisplay ... Connections ... CortexRunning Text Line Output - as follows :
. Sound - Speak Text in Broadcast
. NoticeBoard - New Message in
. SystemMessages - Event Message in tray
HTH
Chris
-
2nd April 2019, 10:15 PM
#5
Automated Home Sr Member
I am happy with the way that I can see the last server reboot time on my noticeboard and decided to try a few other things; the TinyWeb server supports CGI, so I have written a Perl script to pull the last line from the current solar logging file so that I can display the temperatures in the thermal store - but I now realise that I don't quite understand how to substitute values into text message strings.
This is the data that I use to create the message about the server reboot time: 2019-04-02 17_53_03-Web API Client Server Boot Send edit.jpg
And this is the data that I have generated to provide information about the thermal store: 2019-04-02 17_53_31-Web API Client Thermal Store Send edit.jpg
Here are the message strings that I use to output the text messages to the noticeboard: 2019-04-02 17_49_54-Idratek _ CortexW10 _ Green Cottage 2019.jpg
This is what is sent to the noticeboard, first for the server reboot: 2019-04-02 17_51_35-Martin Notice Board Behaviour Menu.jpg
And now for the thermal store: 2019-04-02 17_52_08-Martin Notice Board Behaviour Menu.jpg
Clearly I am doing something wrong, but I can't see what the problem is - I have to admit that I struggled to get the server reboot message to display correctly at first.
Please can someone explain how to correct this?
Many thanks, Martin
-
6th April 2019, 05:07 PM
#6
-
6th April 2019, 11:40 PM
#7
Automated Home Legend
Try: $ Response 0=$0> at the end
Or in general - When you create the user defined text, right click to bring up the Tag insertion tool then choose Insert objects property and from next list select the Text insertion Tag and in the ensuing connections menu enable the Value filter. Now you can search for the Web API Client and will see the response connections in the event ports list which you can then select Response 0 for in your case.
-
7th April 2019, 03:32 PM
#8
Automated Home Sr Member
Thanks both, I managed to solve my problem yesterday afternoon, but then didn't have time to post anything to the forum.
It seems that the Web API Client always appends a numeric value to the end of the tag name - so where I was originally expecting to need <WAPI.Boot At Response=$0> it actually needs <WAPI.Boot At Response 0=$0>. (This doesn't seem to be consistent with the Cortex Help description of tags, which is why it took me a while to get my 'uptime' text working)
Also, the value isn't always 0, it seems to be an incrementing index within a Web API Client object, so for my new text message I need to use <WAPI.Thermal Store At Response 1=$0>, <WAPI.Thermal Store Upper Response 2=$0> and <WAPI.Thermal Store Lower Response 3=$0>; I thought that the only way to find the correct 'index' value was to look at the Web API Client connections once you have created the tags, but Karam has now explained how to insert the tags by right-clicking in the text box - thank you Karam.
I'm still not sure why the index is added as I thought a tag should be unique without it - anyway, not to worry, everything is now working and having experimented a little more I now understand better how to use the Web API Client.
-
7th April 2019, 05:31 PM
#9
Automated Home Legend
good, well done ...
looking at ours, in some cases our index gets as high as 8 for some of our displayed text ...
too long ago that we set ours up, to remember the details, but do remember being surprised when I found, working just from the Help, it all worked first time - so I must have understood the incrementing index at the time !
Chris
Last edited by chris_j_hunter; 7th April 2019 at 05:36 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules