We have moved at community.getvera.com

Author Topic: WallyHome  (Read 5386 times)

Offline Sliptronic

  • Newbie
  • *
  • Posts: 10
  • Karma: +0/-0
WallyHome
« on: December 27, 2014, 12:49:25 am »
Has anyone used the WallyHome with the nest?   I would love to figure out how to write a plugin for the vera in order to get status from and information form the WallyHome sensors.

Any help would be much appricated I am a decent programer but have never written anything for the vera.  Wallyhome has an open API

JL

Offline kyb2012

  • Full Member
  • ***
  • Posts: 119
  • Karma: +4/-0
Re: WallyHome
« Reply #1 on: January 03, 2015, 01:19:01 pm »
Just ordered a Wally home unit myself.  Very interested in a plugin.  Perhaps Watou will take it on.

Offline TC1

  • Hero Member
  • *****
  • Posts: 1088
  • Karma: +90/-88
Re: WallyHome
« Reply #2 on: January 03, 2015, 02:54:27 pm »
While the product looks interesting, not sure what advantage it has if you already have a Z-wave controller/network. For $30 each (less if you have a Lowes' coupon) you can get these rebranded Everspring sensors:

http://www.lowes.com/pd_422362-45367-TST01-1_0__?productId=4740940

Plus, you don't have to invest in a separate hub just for these sensors.

Plus, one ideally wants their communication devices on a UPS in case power goes out so you still get communication notices. The hub for these sensors needs to be plugged directly into the wall as to not interfere with the signal from the sensors.

The only advantage/novelty I see here is the supposed 10 year battery life on the sensors.

Just some thoughts.

Offline kyb2012

  • Full Member
  • ***
  • Posts: 119
  • Karma: +4/-0
Re: WallyHome
« Reply #3 on: January 05, 2015, 12:49:44 am »
You're right, most of what Wallyhome does can be done with other zwave sensors.
But, I like the fact that it's dual purpose (flood and temp) and can be used to adjust Nest based on average temp from multiple sensors.

Offline TC1

  • Hero Member
  • *****
  • Posts: 1088
  • Karma: +90/-88
Re: WallyHome
« Reply #4 on: January 05, 2015, 10:07:46 am »
Right... but these sensors will more than likely be near the floor and in hidden spots (for the moisture sensing). Where the temperature is markedly different than the average room temp humans feel.

Again, if you had no other HA controllers in your house, then these things might be interesting. If you already have any type of HA controller/automation setup, then there are cheaper ways of implementing what these things are trying to accomplish.

Offline integlikewhoa

  • Master Member
  • *******
  • Posts: 5630
  • Karma: +157/-382
Re: WallyHome
« Reply #5 on: January 05, 2015, 10:46:49 am »
You're right, most of what Wallyhome does can be done with other zwave sensors.
But, I like the fact that it's dual purpose (flood and temp) and can be used to adjust Nest based on average temp from multiple sensors.

I'm with TC1 on this. The sensors alone are more then z-wave ones, let alone the controller. It cost 300 for the package, but then again if you bought a NEST I guess getting your money's worth is not a high priority anyways.

Many z-wave devices have temp sensors in them (motions mostly), but I don't feel the need for them.

I'm sure someone could make a plugin, but I'm thinking it not worth their time as there is nothing gained from this that I can see so far. 

Offline RoChess

  • Sr. Newbie
  • *
  • Posts: 46
  • Karma: +2/-0
Re: WallyHome
« Reply #6 on: January 05, 2015, 08:19:01 pm »
You can also DIY things.

For example the Fibaro RGBW controller has 4 analog inputs allowing 0-10V sensors to be added. Water sensors themselves are cheap, and you can also control up to 20 meter of RGBW LED strips :)

Can even go cheaper with like a door/window sensor that has a terminal contact, such as the EnerWave one I use as a doorbell myself. You will only get a boolean result of flood yes/no, but that is usually enough.

Offline kyb2012

  • Full Member
  • ***
  • Posts: 119
  • Karma: +4/-0
Re: WallyHome
« Reply #7 on: February 08, 2015, 11:59:36 pm »
Since I bought the Wallyhome sensors, I thought that I might as well try my hand at writing a plugin or lua script to get the readings from these sensors.  But I need a lot of help....
I'm hoping that someone can help me with calling the API and reading the JSON response.
When I call the API below with the appropriate <token> and <client id> values from a REST API tool, I get a JSON response.  But when I try the LUUP below, in the log, I only see the last logged statement "Wally finished".  I don't see the "result" or "status" values.  Am I adding the header in the right place?   


local socket = require("socket")
local ltn12 = require('ltn12')
local https = require("ssl.https")


https.METHOD = "GET"

local result = {}
https.headers = {
                 ["Authorization"] = "Bearer <token>",
                 --["content-length"] = string.len(data),
                 ["content-type"] = "application/json"
                }

local url = "https://api.snsr.net/v2/places/<client id>/sensors"
           
local result, status = https.request(url)

luup.log("Wally result:", result)
luup.log("Wally status:", status)

luup.log('Wally finished = !!!!!!!!!!!!!!!');

Offline cybrmage

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1104
  • Karma: +113/-43
Re: WallyHome
« Reply #8 on: February 09, 2015, 03:56:56 am »
Since I bought the Wallyhome sensors, I thought that I might as well try my hand at writing a plugin or lua script to get the readings from these sensors.  But I need a lot of help....
I'm hoping that someone can help me with calling the API and reading the JSON response.
When I call the API below with the appropriate <token> and <client id> values from a REST API tool, I get a JSON response.  But when I try the LUUP below, in the log, I only see the last logged statement "Wally finished".  I don't see the "result" or "status" values.  Am I adding the header in the right place?   


local socket = require("socket")
local ltn12 = require('ltn12')
local https = require("ssl.https")


https.METHOD = "GET"

local result = {}
https.headers = {
                 ["Authorization"] = "Bearer <token>",
                 --["content-length"] = string.len(data),
                 ["content-type"] = "application/json"
                }

local url = "https://api.snsr.net/v2/places/<client id>/sensors"
           
local result, status = https.request(url)

luup.log("Wally result:", result)
luup.log("Wally status:", status)

luup.log('Wally finished = !!!!!!!!!!!!!!!');


Your code is close... but is missing a few important parameters in the https call...

You need to specify the mode the request is to use, you need to specify the encryption protocol the request will use, and you need to specify what the https module will do to verify the remote host.

You also will need to use the generic form of the https.request meathod (In my experience the short form almost never works properly, or as expected)..

Provided below is a code snippet to help you out, taken from my Wink Hub plugin (and subtley modified to suit your situation..)... Not that the decode_json function is a generic (and small) json decoder that is embedded within my plugin... you can use any json decoder you desire...

Code: [Select]
local https = require("ssl.https")
local ltn12 = require("ltn12")
local respBody = {}
local client_id = "<client id>"
local req_url = "https://api.snsr.net/v2/places/"..client_id.."/sensors"
local jResp = ""

debug("Sending http request ["..req_url.."] ["..req_json.."].",2)
local rBody, rCode, rHeaders, rStatus = https.request(
{
method = "get",
url = req_url,
headers = { ["Authorization"] = "Bearer <token>",["Content-Type"] = "application/json", ["Content-Length"] = #req_json },
sink = ltn12.sink.table(respBody),
verify = "none",
mode = "client",
protocol = "tlsv1",
options = "all",
redirect = false
}
)

if (tonumber(rCode,10) == 200) then
local jResp = decode_json(table.concat(respBody))
-- the jResp now contains a keyed Lua table with your decoded json data
else
log("https request FAILED!",1)
end

Offline kyb2012

  • Full Member
  • ***
  • Posts: 119
  • Karma: +4/-0
Re: WallyHome
« Reply #9 on: February 09, 2015, 07:42:22 pm »
Thanks @cybrmage. 
I copied the decode_json function from your plugin and tried to access the values in the lua table.
I tried using the following:
Code: [Select]
   local jResp = decode_json(table.concat(respBody))
   for k,v in pairs(jResp) do
     luup.log("Wally loops "..k.." = "..v)
   end
 

But I get an error on the luup.log line.
I'm close, because if I just log the value of 'respBody', I see the JSON response.  But I need to parse it and was hoping that the decode_json function would do that.

For debugging, when I dump the raw value of respBody, I get:
Code: [Select]
[ {
"snid" : "90-7a-f1-00-25-c0",
"offline" : false,
"location" : {
"created" : "2015-01-11T02:56:26.764Z",
"updated" : "2015-01-11T02:56:26.755Z",
"id" : "54b1e65ae4b05d",
"room" : "Bathroom",
"appliance" : "Toilet",
"floor" : "Main Floor",
"placeId" : "54acad12",
"sensorId" : "90-7a-f1-00-25-c0"
},
"paired" : "2015-01-11T02:56:58.297Z",
"suspended" : false,
"state" : {
"RH" : {
"value" : 52,
"at" : "2015-02-10T00:23:36.592Z"
},
"COND" : {
"value" : 1,
"at" : "2015-02-10T00:23:36.592Z"
},
"TEMP" : {
"value" : 20,
"at" : "2015-02-10T00:23:36.592Z"
}
},
"thresholds" : {
"RH" : {
"min" : 30.0
},
"TEMP" : {
"min" : 10.0,
"max" : 38.0
}
},
"updated" : "2015-02-10T00:23:37.051Z",
"activities" : [ ],
"alarmed" : false,
"hardware" : { }
}
]

I'm primarily trying to get the "alarmed", "TEMP.value", with the unique sensor values being - "room", "appliance", and "floor".  I'm a JSON NOOB.

Offline cybrmage

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1104
  • Karma: +113/-43
Re: WallyHome
« Reply #10 on: February 09, 2015, 10:57:18 pm »
Thanks @cybrmage.

Your welcome 8-}


I copied the decode_json function from your plugin and tried to access the values in the lua table.
But I get an error on the luup.log line.

I'm close, because if I just log the value of 'respBody', I see the JSON response.  But I need to parse it and was hoping that the decode_json function would do that.

The decode_json function from my plugins(s) decode the json into a parameterized Lua table... When you try to traverse the table with the pairs function, you end up trying to log Boolean values and tables, which the log function can't do (that is why my plugins have a print_r function - to convert tables, functions and Booleans into strings that can be logged...).

As for extracting the data... It helps to format the json data so that you can more easily see the structure...
Code: [Select]
{
"snid" : "90-7a-f1-00-25-c0",
"offline" : false,
"location" : {
"created" : "2015-01-11T02:56:26.764Z",
"updated" : "2015-01-11T02:56:26.755Z",
"id" : "54b1e65ae4b05d",
"room" : "Bathroom",
"appliance" : "Toilet",
"floor" : "Main Floor",
"placeId" : "54acad12",
"sensorId" : "90-7a-f1-00-25-c0"
},
"paired" : "2015-01-11T02:56:58.297Z",
"suspended" : false,
"state" : {
"RH" : {
"value" : 52,
"at" : "2015-02-10T00:23:36.592Z"
},
"COND" : {
"value" : 1,
"at" : "2015-02-10T00:23:36.592Z"
},
"TEMP" : {
"value" : 20,
"at" : "2015-02-10T00:23:36.592Z"
}
},
"thresholds" : {
"RH" : {
"min" : 30.0
},
"TEMP" : {
"min" : 10.0,
"max" : 38.0
}
},
"updated" : "2015-02-10T00:23:37.051Z",
"activities" : [ ],
"alarmed" : false,
"hardware" : { }
}

From there, you can access the jResp table...

IE...
alarmed = jResp["alarmed"]
TEMP.value = jResp["state"]["TEMP"]["value"]
room = jResp["location"]["room"]
appliance = jResp["location"]["appliance"]
floor = jResp["location"]["floor"]

Basically, once you have formatted the output, you can find the data you want and deduce the correct index keys to use...

Hope that helps.... check out the getDeviceListLocal function in my Wink Hub plugin for more examples...