Replacing SiteSensor Plugin (Vera) with MSR
-
-
OK so lets say I now have a variable in MSR that contains some data pulled down from a HTTP Request to some online API somewhere.
How can I send that value / information to a Generic IO Sensor in Vera ?
I know how to create a GenericIO device in Vera and I know how to send data to it from a simple HTTP command, for example this command will send the text "Hello World"
http://Vera-IP/port_3480/data_request?id=lu_variableset&DeviceNum=128&serviceId=urn:micasaverde-com:serviceId:GenericSensor1&Variable=CurrentLevel&Value=Hello World
And here is the device in Vera:
But how to create a rule to send the contents of an MSR variable (expression) ?
-
I'm going to assume the data was returned in JSON format? In which case MSR treats that like an object {}, whose keys can be referenced with dot notation.
For example, if your variablerespData
stored the response {animal:"cat", clothing:"suit", food:"chow"} and you want to send the current value of the "chow" key therein, simply reference that value withrespData.chow
.One hurdle you may have to overcome, since the data is being fetched and stored in Rule A, but you want to reference the results in Rule B, is that you'd then have to either (a) store respData as a Global Expression, or (b) create a blank Expression in Rule B, and tell Rule A to [Set Variable] on it.
-
@cw-kid said in Replacing SiteSensor Plugin (Vera) with MSR:
But how to create a rule to send the contents of an MSR variable (expression) ?
In case you revised your question, or I misinterpreted it earlier, here goes:
It sounds like you want to send data from MSR to a plug-in / virtual device / sensor over on Vera. Before you begin, go to that "device" > Advanced > Variables and determine which of its variables is intended to receive the data.
Click "EDIT" next to that variable, and look for its complete "service" name in the window; copy that string for use back in MSR.
Close that window on Vera, then head back over to MSR.
In MSR, you will want an [ENTITY ACTION] in the Set Reaction. Choose the target device as the 'Entity' and choose "x_vera_device.set_variable" as the action.
Fill out the three fields, where "service:" and "variable:" come from the string you copied earlier. For "value:" either type a constant (numeric or "text"), or a variable name properly clad in curly brackets ( e.g. ${{respData}} ) so the value gets substituted next time the Rule triggers.
Hope this helps!!
-
Its working. I now have my current WAN IP address being sent from MSR to a virtual device (Generic IO Sensor) on Vera.
So now know how to send any data stored in an expression / variable from MSR to a device on Vera !
-
-
Try lowercase "uk" the way they show in the API docs, perhaps?
accept: application/json
Response should be in the form:
[ { "country": "UK", "code": "GB", "confirmed": 4319128, "recovered": 3748042, "critical": 683, "deaths": 126445, "latitude": 55.378051, "longitude": -3.435973, "lastChange": "2021-03-25T18:23:06+01:00", "lastUpdate": "2021-03-26T14:15:03+01:00" } ]
-
Not a coder, but have been messing about with Vera's Generic IO Sensor device and managed to create a new instance that can accept multiple variables.
So if these HTTP request headers start working, I should be able to push some Covid stats to this "Generic Sensor" in Vera as a test.
Does something like this kind of device for displaying data already exist somewhere?
-
@cw-kid said in Replacing SiteSensor Plugin (Vera) with MSR:
Does something like this kind of device for displaying data already exist somewhere?
Yes, the SiteSensor plug-in ( also by @toggledbits ) for Vera.
-
@cw-kid said in Replacing SiteSensor Plugin (Vera) with MSR:
My expression in the rule says "null" and no data is being brought down.
If it's any consolation, their site seems to be throwing a 500 error when I try to visit https://covid19-api.com/country?name=uk&format=json in my browser. How about yours?
-
cw-kidreplied to LibraSun on Mar 26, 2021, 2:23 PM last edited by cw-kid Mar 26, 2021, 10:31 AM
@librasun said in Replacing SiteSensor Plugin (Vera) with MSR:
If it's any consolation, their site seems to be throwing a 500 error when I try to visit https://covid19-api.com/country?name=uk&format=json in my browser. How about yours?
Same for me also.
However try their CURL command in a terminal window, that works and brings back data OK
-
cw-kidreplied to LibraSun on Mar 26, 2021, 2:25 PM last edited by cw-kid Mar 26, 2021, 10:29 AM
@librasun said in Replacing SiteSensor Plugin (Vera) with MSR:
Yes, the SiteSensor plug-in ( also by @toggledbits ) for Vera.
But aren't we trying to "replace" that plugin
Some decent Generic IO Sensor virtual device we could create and send data too directly from MSR would be nice.
EDIT: I've just noticed my tweaked GenericIO device does not appear correctly in the Vera mobile app but only on the UI7 web GUI.
-
@cw-kid said in Replacing SiteSensor Plugin (Vera) with MSR:
I've just noticed my tweaked GenericIO device does not appear correctly in the Vera mobile app but only on the UI7 web GUI.
Yes, for this reason we can never truly abandon SiteSensor. Why reinvent the wheel, anyway?
But it does beg the question: Why do you need a generic sensor on your Vera when it could "live" on MSR? After all, is it not just a placeholder for data? -
@librasun said in Replacing SiteSensor Plugin (Vera) with MSR:
Why do you need a generic sensor on your Vera when it could "live" on MSR?
So I can add that device in to the Home Remote dashboard app also.
If it's only on MSR I don't know how to connect Home Remote to MSR directly.
-
Fair enough (although I'm certain that capacity will come once MSR variables get exposed via the API).
-
toggledbitsreplied to cw-kid on Mar 26, 2021, 3:13 PM last edited by toggledbits Mar 26, 2021, 11:14 AM
@cw-kid said in Replacing SiteSensor Plugin (Vera) with MSR:
no data is being returned / stored
Sheesh. I'll admit I'm a little on edge this morning because we had a major storm roll through last night with some nasty lightning (and a tornado very close to us) and it apparently killed my daily-use laptop (cheap, old, no big loss, just a distraction to recover but they were almost two-for-a-dollar on sleezeBay), so forgive me, but...
There have been no fewer than 10 posts since the above quoted post, and despite my admonition in bold text yesterday in this very thread, not one mention of what may lie in
reactor.log
. -
-
Notice the
[
that starts the displayed value... it's an array. The{
that follows tells you there's an object as the first element of the array. So you need to pluck the first element out of the array, then dereference through it to the key you want, likecovidstats[0].critical
.
34/91