Replacing SiteSensor Plugin (Vera) with MSR
-
That's easy, it has it, so all I need to do is add the menu item to the UI.
-
@toggledbits I found this:
Oddly, the historical is returning Melgrove lol I left the config so that it would pull from the default location which is using lat/long.
-
I'm not sure where you're going with this post? Are you reporting a problem?
-
@toggledbits I guess I am - unless I'm misreading the docs. I believe to have OWM set to use the default location of MSR which is Hanahan SC, not Melgrove Someplace.
I don't want to file a bug until I'm sure it's MSR and not me.
-
OK. In order to sort that out, I need to see your configuration for both the default system location and OWM. Post here or PM is fine.
-
@toggledbits Posted via PM.
-
OK. Looks like all is good, OWM is just returning an odd place name (who knows what data they sourced that from), and since you are using "default" configuration (home location from Reactor main config), it's using OWM's returned name for the entity name. If you do a custom location in the OWM config, you can set the name by adding the "name" to the custom config. I'm going to extend that behavior to the default location config as well, and that will be in today's build. If you want to get it fixed before that, just add a location to your OWMController config section:
- id: weather enabled: true implementation: OWMWeatherController name: OWM Weather config: appid: "yourappidhere" locations: - id: home name: "My Custom Place Name" latitude: nn.nnnnnn longitude: nn.nnnnnn
-
@toggledbits I'm a few nightly builds behind so I'll wait until you have tonight's out. Thanks!
-
@librasun said in Replacing SiteSensor Plugin (Vera) with MSR:
My goal here has been to illustrate some key concepts needed for moving from SiteSensor over to MSR
I never used SiteSensor plugin for Vera before.
Thanks for the MSR example you wrote.
I wanted to try this out and found this Covid-19 API here.
However the http command they give doesn't seem to return any results data, either just in the web browser or in my MSR rule.
https://covid19-api.com/country?name=UK&format=json
The curl command does work OK however
curl -X GET "https://covid19-api.com/country?name=UK&format=json" -H "accept: application/json"
How do I specify the application/json in the MSR rule? Assuming the problem is related to that.
-
Same way. One header per line in that field.
-
cw-kidreplied to toggledbits on Mar 25, 2021, 2:30 PM last edited by cw-kid Mar 25, 2021, 10:42 AM
In the "Request Headers" field in the "Set Reaction" I have tried the following:
Accept: application/json
and tried:
Content-Type: application/json
It allows me to save the rule but when I go back in to the rule that field is empty again and its not collecting the response data in to my empty expression / variable.
-
So there are two separate issues here:
-
First, we need to figure out if the UI is correctly storing the headers or not, and if the problem is merely that it is not restoring/displaying them correctly when you go back into the editor. The check for that is to go into the reaction, add the headers, and save. Then, open the rule status view and it will show you the rule ID underneath the rule condition status and expressions. Go to your
reactor/storage/rules
directory, and grab the same-named file (with.json
suffix) and post it here. Let's see what's being stored. -
Look at the logs to see where the reaction is running and what the request is doing. There may be errors logged.
It's entirely possible that the problem is 1, 2, or even both.
-
-
I cannot upload files to this forum it seems.
I have uploaded the rule to my One Drive here
-
OK. There's definitely two broken things in the handling of headers, so go ahead and open a PR for this. No need to post the rule there (again); I've got it and have the issue in hand, but unfortunately, it's not just a UI issue.
-
-
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 !
20/91