• Z-Wave Forum
    Home Automation made simple
It is currently Wed Oct 18, 2017 12:37 pm
  • View new posts
  • View unanswered posts
  • Who is online
  • In total there is 1 user online :: 0 registered, 0 hidden and 1 guest (based on users active over the past 5 minutes)
  • Most users ever online was 33 on Fri Apr 21, 2017 2:30 pm
  • Users browsing this forum: No registered users and 1 guest

Mother and motion cookies

by jompa68 » Wed Feb 18, 2015 8:28 pm

I have created a integration with Sen.se's product "Mother and motion cookies" and my HC2.
sen.se have a API and it is possible to get json data from your mother or motion cookies.

Skärmavbild 2015-02-18 kl. 20.07.07.png
Skärmavbild 2015-02-18 kl. 20.07.07.png (20.31 KiB) Viewed 7965 times


example code of a walk/step feed
Place this in a scene

Code: Select all
-- ID of cookie from feed (walking feed)
local cookieWalk = 'F6s7juyUKgpxxxxxxxxxxxxxxxxxxxxxxx'

-- Replace Authorization in header part. Use https://www.base64encode.org to encode your
-- username:password from apis.sen.se

local httpClient = net.HTTPClient();


   httpClient:request('https://apis.sen.se/v2/feeds/'..cookieWalk..'/events/?format=json', {
   success = function(response)
   if tonumber(response.status) == 200 then
    --local stepReport ={}     
    local jsonData = json.decode(response.data) 
    local total=0
    for i = 1, #jsonData.objects do
        if jsonData.objects[i].profile == 'WalkStandard' then
            if string.sub(jsonData.objects[i].dateEvent,1,10) == os.date("%Y-%m-%d") then
                 total = total + jsonData.objects[i].data.numberSteps
            end
       end   
   end
    print('Total steps/walk today: '..total)
    fibaro:call(423, "setProperty", "ui.lblSteps.value", total)
     else
    print('call::checkUpdate ERROR [HTTPClient:request] status: ' .. response.status)
     end
end,
    options = {
      headers = {
        ['Authorization'] = 'Basic >>>>Change here!<<<<'
      }
    }
});
jompa68
 
Posts: 22
Joined: Mon Feb 16, 2015 11:06 am

Return to LUA

cron

User Menu

Login