Re: [mh] RoomMe
Timothy Spaulding <[email protected]>
| Newsgroups | gmane.comp.misc.misterhouse.user |
|---|---|
| Message-ID | <MN2PR01MB57436DF75A67A15B82221CD5CDDB0@MN2PR01MB5743.prod.exchangelabs.com> |
Howard,
Thanks for the pointers. I initially didn’t understand what you were sharing, but after reading through the json_server.pl code (several times) I was able to get a handle on how to solve my issue.
I hope the below can help others.
In short, the way I am resolving my question is to create a new subroutine in my user code and call it via the http://<mh:port>/sub?<my<http://%3cmh:port%3e/sub?%3cmy> new sub>. There are no parameters being passed to the sub. However, inside the sub, I am creating a local hash of the body of the web request with the following:
My $jsonHash = decode_json($HTTP_DATA); #$HTT_DATA is a global variable and contains the body of the web request
And then I am grabbing the value of each key in to a local var like this:
my $userID = $jsonHash->{"userId"};
Now I can proceed with using the data.
Regards,
Tim
From: H Plato <[email protected]>
Sent: Monday, April 13, 2020 2:49 PM
To: Timothy Spaulding <[email protected]>
Cc: [email protected]
Subject: Re: [mh] RoomMe
Hi Tim,
I do something similar with the razberry module. Razberry loads a custom module that provides a push event to MH when a state changes. Take a look at main::razberry_push in the razberry package, and I think I parse post data in the json_server.pl. (It’s been a while since I’ve looked at the json server code)
On Apr 13, 2020, at 10:57 AM, Timothy Spaulding <[email protected]<mailto:[email protected]>> wrote:
Hi,
I wanted to try again to see if anyone knows how I can read this JSON data from the body of a HTTP call from a sub? Or any preferred method/strategy to have MH act on the JSON data?
Thanks,
Tim
From: Timothy Spaulding <[email protected]<mailto:[email protected]>>
Sent: Friday, January 10, 2020 6:16 PM
To: [email protected]<mailto:[email protected]>
Subject: [mh] RoomMe
Hi All,
A friend shared this relatively new device called a RoomMe (http://www.IntelliThings.net<http://www.intellithings.net/> .
Short story is that it is a device that can identify a person cell phone via Bluetooth in a room and can set scenes/settings based on that user’s preference.
They also have a way to call an external link via POST with JSON in the body of the post that looks like the following:
{
"userId":0,
"event":
{
"name":"RoomExit",
"lastInRoom":true
},
"id":"<email address>",
"sensorId":"<BT MAC Address>",
"type":"Event",
"userName":"Tim",
"roomName":"Office Suite"
}
There are different events. Attached is the complete API documentation.
Can anyone share ideas on the best way for MH to make use of this data? RoomMe doesn’t support a lot of systems at present; and having MH do the logic based on parameters seems like a potentially good fit.
Tim
________________________________________________________
To unsubscribe from this list, go to: https://lists.sourceforge.net/lists/listinfo/misterhouse-users
________________________________________________________
To unsubscribe from this list, go to: https://lists.sourceforge.net/lists/listinfo/misterhouse-users