The script requires two virtual devices one of type weight (weegschaal) and one of type percentage (vetpercentage).
The IFTTT:
In IFTTT create an applet using Withings and Webhooks:
If New Body Scale measurement by [USER], then Make a web request
In the Webhook make a GET request for the following URL (change to your domoticz URL):
Code: Select all
https://user:[email protected]/json.htm?type=command¶m=customevent&event=Withings&data=[{"gewicht": {{WeightKg}}},{"vet": {{FatPercent}}}]
Code: Select all
return {
-- 'active' controls if this entire script is considered or not
active = true, -- set to false to disable this script
logging = {
level = domoticz.LOG_INFO, -- Max. one level can be active; comment the others
-- level = domoticz.LOG_ERROR,
-- level = domoticz.LOG_DEBUG,
-- level = domoticz.LOG_MODULE_EXEC_INFO,
marker = "Withings"
},
-- trigger
on = {
customEvents = { 'Withings' }
},
-- actual event code
execute = function(domoticz, device)
if device.data[1] then
local gewicht = tonumber(device.data[1].gewicht)
domoticz.log('Nieuwe weging, gewicht: ' .. gewicht, domoticz.LOG_INFO)
domoticz.devices('Weegschaal').updateWeight(gewicht)
end
if device.data[2].vet then
local vet = tonumber(device.data[2].vet)
domoticz.log('Nieuwe weging, Vet%: ' .. vet, domoticz.LOG_INFO)
domoticz.devices('Vetpercentage').updatePercentage(vet)
end
end
}