section of - Functie mirobo gegevens
and domoticz brings me this error in the log. can you help me thanks!
Code: Select all
return {
on = {
devices = {
'Cippy - Status',
'Presenza',
},
timer = {
'at 10:00 on mon,wed,fri',
'at 23:59'
},
logging = {
level = domoticz.LOG_INFO,
},
},
execute = function(domoticz, device)
-- Devices m.b.t. onderhoud
local cap_main_brush = domoticz.devices('Cippy - Care Main Brush').nValue
local cap_side_brush = domoticz.devices('Cippy - Care Side Brush').nValue
local cap_filter = domoticz.devices('Cippy - Care Filter').nValue
local cap_sensors = domoticz.devices('Cippy - Care Sensors').nValue
-- Push-notificaties voor onderhoud
local main_brush = 'La grande spazzola arancione di Cippy deve essere sostituita al più presto! La capacità è solo '..cap_main_brush..'%.'
local side_brush = 'La piccola spazzola sul lato di Cippy deve essere sostituita al più presto! La capacità è solo'..cap_side_brush..'%.'
local filter = 'Il filtro di Cippy deve essere sostituito al più presto! La capacità è solo'..cap_filter..'%.'
local sensors = 'I sensori di Cippy devono essere puliti al più presto! La capacità è solo '..cap_sensors..'%.'
-- User variables
local text1 = 'Pulizia non ancora effettuata oggi'
local text2 = 'Preparo Pulizia'
local text3 = 'Pulizia in corso'
local text4 = 'Ritorno alla base'
local text5 = 'Pulizia effettuata oggi'
local Cippy = domoticz.devices('Cippy - Status')
--Cippy.dump()
-- Notificatie-tabel
local myNotificationTable = {domoticz.NSS_PROWL} -- table with one or more notification system. Can be one or more of
-- dz.NSS_GOOGLE_CLOUD_MESSAGING,
-- dz.NSS_HTTP,
-- dz.NSS_KODI,
-- dz.NSS_LOGITECH_MEDIASERVER,
-- dz.NSS_NMA,
-- dz.NSS_PROWL,
-- dz.NSS_PUSHALOT,
-- dz.NSS_PUSHBULLET,
-- dz.NSS_PUSHOVER,
-- dz.NSS_PUSHSAFER
-- Automatisch starten tussen bepaalde tijd en niemand thuis
if domoticz.variables('CippyState').value == text1 then
if domoticz.time.matchesRule('at 9:00-16:00 on mon,wed,fri') then
if domoticz.devices('Presenza').state == 'Off' then
domoticz.devices('Cippy - Fan Level').switchSelector(20).silent() -- 10=Laag, 20=normaal, 30=hoog, 40=maximaal, 50=mop
domoticz.devices('Cippy - Control').switchSelector(10).silent()
domoticz.notify('Cippy info', '🧹 Cippy sta per pulire')
domoticz.variables('CippyState').set(text2)
end
end
end
--Functie mirobo gegevens
local function mysplit(inputstr, sep)
if sep == nil then
sep = "%s"
end
local t={} ; i=1
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
t[i] = str
i = i + 1
end
return t
end
--Mirobo gegevens ophalen
local handle = io.popen("sudo mirobo --ip 192.168.1.28 --token 3973764b514d43507a55476d616b4f41") --- IP & TOKEN !!!!
local result = handle:read("*a")
handle:close()
domoticz.log('Result:'..result)
t = mysplit(result,"\n")
if(t[1] ~= nil) then
if(t[2] ~= nil and t[4] ~= nil and t[5] ~= nil) then -- 1=Status, 2=Batterij, 3=Fanspeed, 4=Tijd, 5=Oppervlakte
-- Informatie
local battery = string.gsub(t[2],"Batteria: ","")
local fanspeed = string.gsub(t[3],"Velocità: ","")
local cleantime = string.gsub(t[4],"Pulizia: ","")
local cleanspace = domoticz.utils.round(string.gsub(string.gsub(t[5],"Area Pulita: ","")," m²",""),0)
--Stand zuig-ventilator
if fanspeed == '38 %' then fanspeed = 'lage'
elseif fanspeed == '60 %' then fanspeed = 'Normale'
elseif fanspeed == '75 %' then fanspeed = 'Alta'
elseif fanspeed == '98 %' then fanspeed = 'Massima'
elseif fanspeed == '105 %' then fanspeed = 'lavaggio'
else fanspeed = 'onbekende'
end
-- User variables bijwerken en notificaties versturen
if domoticz.variables('CippyState').value ~= text1 then
if Cippy.rawData[1] == 'Cleaning' then
domoticz.variables('CippyState').set(text3)
domoticz.notify('Cippy info', '🧹 Cippy sta effettuando la pulizia')
elseif Cippy.rawData[1] == 'Back to home' then
domoticz.variables('CippyState').set(text4)
domoticz.notify('Cippy info', 'Cippy alla velocità '..fanspeed..' ha pulito '..cleanspace..' m² in '..cleantime..' e ritorna alla stazione di ricarica con una batteria di '..battery..'.')
elseif Cippy.rawData[1] == 'Charging' and domoticz.devices('Presenza').state =='Off' then
domoticz.variables('CippyState').set(text5)
domoticz.notify('Cippy info', '✅ Cippy ha pulito e si ricarica')
elseif Cippy.rawData[1] == 'Paused' then
domoticz.notify('Cippy info', '😴 Cippy è un po stanco e si prende una pausa')
elseif Cippy.rawData[1] == 'Sleeping' then
domoticz.notify('Cippy info', '😴 Cippy non ha nulla da fare e si è addormentato. Portala alla base in modo che si possa caricare.')
elseif Cippy.rawData[1] == 'Waiting' then
domoticz.notify('Cippy info', '❗ Cippy sta aspettando le tue istruzioni')
elseif Cippy.rawData[1] == 'In Error' then
domoticz.notify('Cippy info', '❗ Cippy ha problemi e ha bisogno di aiuto!')
end
end
end
endCode: Select all
2019-10-18 23:59:02.482 Status: dzVents: Error (2.4.19): An error occured when calling event handler Script #1
2019-10-18 23:59:02.482 Status: dzVents: Error (2.4.19): /home/pi/domoticz/dzVents/runtime/Domoticz.lua:172: attempt to perform arithmetic on local 'x' (a string value)
2019-10-18 23:59:02.483 Status: dzVents: Info: ------ Finished Script #1