djdevil wrote: Monday 17 February 2020 13:14
there is no one you can help me thanks
Sure someone can. But what kind of idx should be updated every 5 minutes ? Is it a switch, or a text device a uservariable maybe ? Please do not expect forum member to read your mind
djdevil wrote: Monday 17 February 2020 13:14
there is no one you can help me thanks
Sure someone can. But what kind of idx should be updated every 5 minutes ? Is it a switch, or a text device a uservariable maybe ? Please do not expect forum member to read your mind
you are right, sorry!
the idx is Blinds Percentage Inverted
local scriptVar = 'blindPosition'
return
{
on =
{
timer =
{
'every 5 minutes',
},
httpResponses =
{
scriptVar
},
},
logging =
{
level = domoticz.LOG_DEBUG, -- set to LOG_ERROR when tested and OK
marker = scriptVar,
},
execute = function(dz, item)
if item.isTimer then
dz.openURL({
url = 'http://192.168.1.29:5000/AM43BlindsAction/CheckStatus',
callback = scriptVar,
})
return
end
if item.ok then
local blind = dz.devices('Tenda bagno') -- Change to name of domoticz device
local rt = item.json
local position = rt['Tenda bagno'][1].position
dz.log('Position of blind is ' .. position, dz.LOG_DEBUG
blind.dimTo(position).silent()
else
dz.log('There was a problem handling the request', dz.LOG_ERROR)
dz.log(item, dz.LOG_ERROR)
end
end
}
djdevil wrote: Monday 17 February 2020 18:18
Not work this is my debug log:
2020-02-17 18:18:03.284 Status: dzVents: Error (2.4.19): blindPosition: ...domoticz/scripts/dzVents/generated_scripts/Script #1.lua:37: attempt to index local 'rt' (a nil value)
Probably the response of your Bluetooth does not tell domoticz it returns a json. Can you try this one ?
local scriptVar = 'blindPosition'
return
{
on =
{
timer =
{
'every 5 minutes',
},
httpResponses =
{
scriptVar
},
},
logging =
{
level = domoticz.LOG_DEBUG, -- set to LOG_ERROR when tested and OK
marker = scriptVar,
},
execute = function(dz, item)
if item.isTimer then
dz.openURL({
url = 'http://192.168.1.29:5000/AM43BlindsAction/CheckStatus',
callback = scriptVar,
})
return
end
if item.ok then
local blind = dz.devices('Tenda bagno') -- Change to name of domoticz device
local rt = dz.utils.fromJSON(item.data)
if rt == nil then
dz.log(item, dz.LOG_ERROR)
return
end
local position = rt['Tenda bagno'][1].position
dz.log('Position of blind is ' .. position, dz.LOG_DEBUG
blind.dimTo(position).silent()
else
dz.log('There was a problem handling the request', dz.LOG_ERROR)
dz.log(item, dz.LOG_ERROR)
end
end
}