2020-05-27 18:27:07.780 Error: dzVents: Error: (3.0.7) An error occurred when calling event handler roborock
2020-05-27 18:27:07.780 Error: dzVents: Error: (3.0.7) /home/pi/domoticz/dzVents/runtime/Utils.lua:119: attempt to compare number with string
Code: Select all
return {
on = {
devices = {
'Svetlana - Status',
'Atti_telefon',
},
timer = {
'at 9:28 on mon,tue,wed,thu,fri',
'at 23:59'
},
-- logging = {
-- level = domoticz.LOG_INFO,
-- },
},
execute = function(domoticz, device)
-- karbantartási eszközök
local cap_main_brush = domoticz.devices('Svetlana - Care Main Brush').nValue
local cap_side_brush = domoticz.devices('Svetlana - Care Side Brush').nValue
local cap_filter = domoticz.devices('Svetlana - Care Filter').nValue
local cap_sensors = domoticz.devices('Svetlana - Care Sensors').nValue
-- Push-üzenenetek az eszközök állapotáról
local main_brush = 'A porszívó főkeféje hamarosan cserére szorul! A kapacitás csak '..cap_main_brush..'%. Nézd meg az eustocknál'
local side_brush = 'A porszívó oldalkeféje hamarosan cserére szorul! A kapacitás csak '..cap_side_brush..'%. lehet van a fiókban'
local filter = 'A porszívó porszűrője hamarosan cserére szorul. A kapacitás már csak '..cap_filter..'%. '
local sensors = 'A porszívó szenzorok koszosak. Már csak '..cap_sensors..'%.'
-- User variables
local text1 = 'ma meg nem volt porszivozas'
local text2 = 'porszívózás következik'
local text3 = 'porszívózás'
local text4 = 'vissza a töltőállomáshoz'
local text5 = 'ma felporszívózott'
local Svetlana = domoticz.devices('Svetlana - Status')
--Svetlana.dump()
-- Notificatie-tabel
local myNotificationTable = {domoticz.NSS_TELEGRAM} -- 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
-- Automatikus indítás az alábbi időpontok közt, ha senki nincs otthon
if domoticz.variables('SvetlanaState').value == text1 then
if domoticz.time.matchesRule('at 9:00-18:00 on mon,tue,wed,thu,fri') then
if domoticz.devices('Atti_telefon').state == 'Off' then
domoticz.devices('Svetlana - Fan Level').switchSelector(30).silent() -- 10=csendes, 20=normál, 30=nagy, 40=maximaal, 50=szőnyeg
domoticz.devices('Svetlana - Control').switchSelector(10).silent()
domoticz.notify('Svetlana info', 'A porszívózás elkezdődött')
domoticz.variables('SvetlanaState').set(text2)
end
end
end
--Funkció adatok
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
--funkciók beolvasásáa
local handle = io.popen("sudo mirobo --ip 192.168.1.194 --token 444f427442686a554d4b7a666e676f46") --- 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
-- Információk
local battery = string.gsub(t[2],"Battery: ","")
local fanspeed = string.gsub(t[3],"Fanspeed: ","")
local cleantime = string.gsub(t[4],"Cleaning since: ","")
local cleanspace = domoticz.utils.round(string.gsub(string.gsub(t[5],"Cleaned area: ","")," m²",""),0)
--Szívóerő helyzete
if fanspeed == '38 %' then fanspeed = 'kicsi'
elseif fanspeed == '60 %' then fanspeed = 'normal'
elseif fanspeed == '75 %' then fanspeed = 'nagy'
elseif fanspeed == '98 %' then fanspeed = 'maximum'
elseif fanspeed == '105 %' then fanspeed = 'szőnyeg'
else fanspeed = 'A'
end
-- felhasználói vátozók és értesítések
if domoticz.variables('SvetlanaState').value ~= text1 then
if Svetlana.rawData[1] == 'Cleaning' then
domoticz.variables('SvetlanaState').set(text3)
domoticz.notify('Svetlana info', 'A porszívózás folyamatban')
elseif Svetlana.rawData[1] == 'Back to home' then
domoticz.variables('SvetlanaState').set(text4)
domoticz.notify('Svetlana info', '_ '..fanspeed..' ház felporszívózva: '..cleanspace..' m². Végeztem '..cleantime..' idő alatt. Visszamegyek a dokkolóállomásra. Az akksiban '..battery..' maradt.')
elseif Svetlana.rawData[1] == 'Charging' and domoticz.devices('Atti_telefon').state =='Off' then --ha nem vagyunk itthon
domoticz.variables('SvetlanaState').set(text5)
-- domoticz.notify('Svetlana info', '✅ Töltés')
elseif Svetlana.rawData[1] == 'Paused' then
domoticz.notify('Svetlana info', '😴 a porszivózás szünetel ')
elseif Svetlana.rawData[1] == 'Sleeping' then
domoticz.notify('Svetlana info', '😴 A porszivó megfáradt, vidd vissza a töltőállomásra.')
elseif Svetlana.rawData[1] == 'Waiting' then
domoticz.notify('Svetlana info', '❗ A porszivó utasításra vár, vagy áramszünet van.')
elseif Svetlana.rawData[1] == 'In Error' then
domoticz.notify('Svetlana info', '❗ A porszivónak problémái vannak!')
end
end
end
end
-- Onderhoud-notificaties
if Svetlana.rawData[1] == 'Back to home' then
if domoticz.devices('Svetlana - Care Main Brush').nValue < 10 then
domoticz.notify('Svetlana info', main_brush)
end
if domoticz.devices('Svetlana - Care Side Brush').nValue < 10 then
domoticz.notify('Svetlana info', side_brush)
end
if domoticz.devices('Svetlana - Care Filter').nValue < 10 then
domoticz.notify('Svetlana info', filter)
end
if domoticz.devices('Svetlana - Care Sensors').nValue < 15 then
domoticz.notify('Svetlana info', sensors)
end
end
-- A nap végén alaphelyzetbe áll
if domoticz.time.matchesRule('at 23:59') then
domoticz.variables('SvetlanaState').set(text1)
end
end
}