moin zusammen!
Seit dem Update auf 4.520 funktioniert eine meiner Loggong-Szenen nicht mehr, und ich finde den Grund dazu nicht. Vielleicht könnt ihr mal draufschauen?! Danke! Bis zum Update hat die Szene die Daten immer ordentlich gesendet; Update gemacht, nichts verändert, keine Reaktion der Szene
--[[
%% properties
153, 159, 155, 187, 163, 198,161,149,22,18,26,33,101,165,98,53,116 batteryLevel
%% events
%% globals
fifteenMinuteTimer
--]]
--
--oneMinuteTimer: https://forum.fibaro.com/topic/21656-recording-data-to-allthingstalkio/
--Hilfe durch https://forum.fibaro.com/topic/21656-recording-data-to-allthingstalkio/?page=3&tab=comments#comment-161550
--Szenenstart bei Wertminderung: https://www.siio.de/fibaro-homecenter-einsteigerguide-teil-2-getriggerte-szenen/
--Triggern in LUA-Szenen
-- Scene : All Things Talk Test
-- Version : 1.3
-- Date Created : 09 June 2016
-- Last Changed : 12 November 2018
-- HC Version : Home Center 2 v4.510
-- Created By : Dave Harrison
-- Purpose : To test sending data to AllThingsTalk.io
-- Trigger : Triggered by the Timer Scene updating the fifteenMinuteTimer global variable
-- Revision History
-- ----------------
-- 1.2 19-Nov-16 SmartLiving.io rebranded as AllThingsTalk.io
-- 1.3 12-Nov-18 New authentication method
--====================================================
-------------------- Declaration: Local Variables
--====================================================
local debug = true
local sourceTrigger = fibaro:getSourceTrigger()
local currentDateISO = os.date("%Y-%m-%dT%X")
local currentDateTime = os.time()
local devices =
{
WohnzimmerThermostat1 = {deviceId = 153, property = "batteryLevel",assetId = "fnkA6vcYspPebahslxgcEvE0"},
WohnzimmerThermostat2 = {deviceId = 159, property = "batteryLevel", assetId = "hd39timELr37556V6S2cgFqo"},
EsszimmerThermostat = {deviceId = 155, property = "batteryLevel", assetId = "64z8BcdUfulY5tri3iwDh9Cv"},
KuecheThermostat = {deviceId = 187, property = "batteryLevel", assetId = "8GgVDq47MI2xgxIn5VK7QMwD"},
BadezimmerThermostat = {deviceId = 163, property = "batteryLevel", assetId = "en96zOIbzXhKKBLjOGdzOFjV"},
WindfangThermostat = {deviceId = 198, property = "batteryLevel", assetId = "TjfAC8NhY9bbO5AnNSyWT0Ea"},
BueroThermostat = {deviceId = 161, property = "batteryLevel", assetId = "7sbr9Ug5CYByaYif9b9V7vnG"},
AnkleideThermostat = {deviceId = 149, property = "batteryLevel", assetId = "VeTJteLgnsJArZY5pqWCLYVS"},
EsszimmerSmokesensor = {deviceId = 22, property = "batteryLevel", assetId = "YtOskdqE34OhqO6Y2ci6m5tP"};
WohnzimmerSmokesensor = {deviceId = 18, property = "batteryLevel", assetId = "7YCG7hwIqwiXqEhq7cu24qkf"},
EsszimmerMotionsensor = {deviceId = 26, property = "batteryLevel", assetId = "gvrqsliqeR7v1wpCWXOHBphS"},
TreppeMotionsensor = {deviceId = 33, property = "batteryLevel", assetId = "qYwvQ6V095itiP5mmxp06Dhj"},
KinderzimmerLiThermostatFenster = {deviceId = 101, property = "batteryLevel", assetId = "Yuds2Y1ASpoG4NUezq8fyzhh"},
KinderzimmerLiThermostatGiebel = {deviceId = 165, property = "batteryLevel", assetId = "LCODYFcGqSQb1BoVIQhVU1y3"},
KinderzimmerReThermostatFenster = {deviceId = 98, property = "batteryLevel", assetId = "lWbFg7Ky0Qkh3qO9QJSqWVFB"},
KinderzimmerReThermostatGiebel = {deviceId = 53, property = "batteryLevel", assetId = "GtCqaclWdVA4rO6BdxrEnKPs"},
SchlafzimmerThermostat = {deviceId = 116, property = "batteryLevel", assetId = "s5Lr9W77DPczLZhGSepjAJgm"}
}
--====================================================
-------------------- Functions
--====================================================
local function log(str) if debug then fibaro:debug(str); end; end
local function errorlog(str) fibaro:debug("<font color='red'>"..str.."</font>"); end
local function sendData (assetId, requestBody)
local deviceToken = "maker:*******" -- Replace maker:xxxxxxxxx with your Device Authentication Token
local url = "https://api.allthingstalk.io/asset/" .. assetId .. "/state"
local httpClient = net.HTTPClient({timeout=5000})
local httpHeaders =
{
["Authorization"] = "Bearer " .. deviceToken,
["Content-Type"] = "application/json",
}
httpClient:request(url, {
options={
headers = httpHeaders,
data = requestBody,
method = 'PUT',
timeout = 5000,
checkCertificate = false,
},
success = function(response)
if (response.status >= 200 and response.status < 300) then
log(assetId .. ": " .. response.status .. " - successful")
else
errorlog(assetId .. ": " .. "ERROR")
end
end,
error = function(error)
errorlog(assetId .. ": " .. "ERROR")
log(error)
end
})
end
--====================================================
-------------------- Main
--====================================================
-- Send data to AllThingsTalk
-- --------------------------
local requestData = {}
-- Check each device and format the request data
for i, device in pairs(devices) do
-- requestData = {value = tonumber(fibaro:getValue(device.deviceId, "value")), at = currentDateISO}
requestData = {value = tonumber(fibaro:getValue(device.deviceId, device.property)), at = currentDateISO}
local requestBody = json.encode(requestData)
log(i .. ": " .. requestBody)
-- Send the data
sendData(device.assetId, requestBody)
end