webCoRE for Hubitat Updates

I admit I only just recently started looking at the webCoRE code so its very possible I'm missing something in the bigger picture. However, I don't see what is incorrect with my short code suggestion above. Can you please help me understand why its incorrect?

BTW, I tested my suggestions before I posted and they are working for me. So I'd really like to understand where is incorrect and why you think I shouldn't do that. :thinking:

I can see that you are re-using 'delay' as a local variable to hold the setLevel duration value when the variable name 'delay' is already being used throughout the code as a global variable to store the Piston Execution Delay value. Those are two different timings. Your code puts the setLevel duration value into the 'delay' variable and then passes that value (I believe incorrectly) as the Piston Execution Delay parameter in the "else executePhysicalCommand" line. So everything else that calls the do_setLevel routine is going to get a 0L value for Piston Execution Delay even if it should be something else. It also drops the Piston Execution Delay value from the 1st executePhysicalCommand with the sSTLVL attribute. My suggested change should fix those two things (as far as I can tell).

Does it work correctly? I'm not sure about that. :thinking: The setLevel duration is working now and thats good. But it looks to me like your code fix is no longer honoring the previous Piston Execution Delay properly. Instead of just telling me mine is incorrect, can you please help me understand with a little more details? I am an experienced programmer but am new to the webCoRE code and I would like to understand it better.

@nh.schottfam
Wondering if you could add this really simple change to WC. :wink:
As my HPM updates always fail due to sync problem I have to check the app code manually to make sure I'm up-to-date.
The WC engine text reads the wrong line of the code so it reports the wrong version.
I'm at 0211 on both so the first HE version is incorrect.

image

I've got a C3 hub with Webcore and seeing this today? I'm one version back with WC but on the current version of Hubitat. What is this system event list telling me?

Feature request: Would it be terribly difficult to return something from a piston activated via HTTP, i.e. in the response body?

Don't care much about the exact format, but having the choice of plain text or a json object would be really great.

Thanks.

The severeLoad event, may or may not be related to the webCoRE load piston list request. The System Events is just a list of events that occurred.

To see what is running you should look at the device or app metrics under 'logs'

I don't think this would be webcore, as there are no changes that cause it to use more cpu.

1 Like

Currently piston execute 'fires the piston' with the arguments, but does not wait for it to finish.

It returns 'Ok' or 'ERROR' depending if it was able to fire the piston.

You could always have the piston call an endpoint as it runs

Optionally you can enable pistons to fire a location event when they complete (this is off by default). (HE console -> Apps -> webcore -> settings -> log piston executions)

This fires a location event as the piston exits an execution. It includes in the data piston Id, piston name, event data that fired it, and the piston state information (this is displayed in the dashboard). Some apps (like Echo Speaks) can use this as a trigger into Echo Speaks

I don't think that would work. I have a dashboard implemented as an HTML file. The dashboard runs on a Fire tablet, running Fully Kiosk Browser. The html file is actually stored in HE's file system; there is no web server, nor any need for one. All functionality is implemented in javascript. It makes ajax calls to HE via the Maker API to initiate actions.

I'd like to have the dashboard make an ajax call to webcore to retrieve some values.

Could be wrong, but I don't think there's any way to create an endpoint in javascript that waits for incoming connections.

It is a major architectural change to have an option to allow the piston to run to completion before returning, and have a mechanism to specify a response body?

For everyone -

pushed an update to webcore to do this to try out a suggested method. There is a new endpoint that allows to query global variables.

This also works for HE hub variables via the @@variable format

where redacted and 163 are filled in appropriately to your environment (you can look at the execute piston URLs in HE console -> select a piston -> Execute to understand how to adjust for your deployment)

If you use HPM, do an HPM repair on webcore, otherwise I changed the webcore main file

The usage:

$ curl http://192.168.86.xxx/apps/api/163/global/@HolidayNextDaysAway?access_token=redacted

{"val":26,"result":"OK","timestamp":1613750680295}
$

or

https://cloud.hubitat.com/api/redacted/apps/163/global/@foo?access_token=redacted

2 Likes

This feature has opened a whole new range of possibilities especially sharing data between different platforms such as Node-RED and even webCoRE running on different platforms.

Awesome.

What I have been doing to display updating custom information on the dashboard is using an attribute template on the dashboard and a virtual device that stores the data from WebCoRE.

Driver for virtual device:

metadata {
   	definition (name: "webCoRE Value", namespace: "Derakkon", author: "Derakkon") {
    		capability "Refresh"
    		attribute "Value","string"
    		command "changeValue"
     	}
}
def changeValue (param) {
	sendEvent("name":"Value", "value":param)
}

@nh.schottfam Feature Request
Is it possible to put a delay option (ms, sec) in a With statement?
I can execute a global var with a list of items in a For/Each and put a wait command in the Do but you can't have a With and a list of items execute slower.
Use case here is that my Blink cameras sometimes miss a command because Blink gets the commands too fast. Also my night routines turn off a lot of lights and sometimes the mesh gets overwhelmed with the number Turn Off's.
There may be other block constructs that might benefit from this iteration delay as well.
EDIT: I haven't tried it but if I put a delay in a With block does it actually iterate through the block for each list item, thus using the wait, or does it just execute the commands on the list all at once?
Cheers.

Anyone having an issue with the $sunrise and $sunset variables not showing the correct date? Mine seem to lag a day and not show today's.

I use this var/constant :wink: in many pistons and it has been fine.
I am on the latest version of HE C7 and WC.

Does it list the correct date in the variables list?

Seems to.
datetime$sunrise2/21/2021, 7:22:00 AM
datetime$sunset2/21/2021, 5:51:00 PM
datetime$nextSunrise2/22/2021, 7:20:00 AM
datetime$nextSunset2/22/2021, 5:53:00 PM

You know what would be a great companion feature to this? A new app preference to specify a web endpoint that would automatically be called whenever a global variable changes.

Seems you could write a piston for that.

you can set a command execution delay for a piston, which will insert a delay (up to 1000ms) after issuing a physical device command