webCoRE for Hubitat Updates

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

The tricky part of sunrise and sunset, is they change 'at midnight'.

So if you are trying to get a future one, if it has not happened yet today, you get a future one, otherwise you have the past one, which webcore could push ahead by 24 hours, which is not exactly right.

So what to do?

if you schedule these (sunrise or sunsets) at a top level (not indented level) of a piston, you could add at the end of your piston

if time happens daily at 3:00:00 AM
then (nothing listed)

ie all you are doing is forcing the piston to run at 3:00, where it will use today's values for sunrise, sunset for future runs (so always accurate).

You could have chosen 12:01:00 AM, or 12:30, etc. You may not want to use 1 or 2 AM due to daylight savings times adjustments, but likely even those work.

Here is an example of my use (my mode controller)

My problem is that webcore for me doesnt seem to update those variables correctly. $sunrise and $sunset both are dated for yesterday (2/20 not 2/21) and $nextSunrise and $nextSunset are dated for tomorrow (2/22). Seems to not update for today's date but lag a day.

That's happened to me also. I saw it once a few months ago and never since. You can try rebooting your hub and see if it goes away. I think that's what fixed it for me.

Out of curiosity, are you on the latest hub platform?