just wanted to share:
This dzventz script checks car status and notifies for
- If you lock the car with any open window
- When charging is started, stopped or has a charging fault.
it was created for my Volvo, for which the device sensors were made available by the Volvo Recharge Plugin (https://github.com/akamming/Domoticz_Vo ... rge_Plugin), but this dzVentz script is generic and could be adapted for any car for which you have similar car sensors
Code: Select all
return {
on = {
devices = {
'Volvo', -- Lock Device of the volvo,
'Volvo-ChargingSystemStatus', -- device which contains the charging state
-- 'test' -- for testing purposes
}
},
logging = {
level = domoticz.LOG_DEBUG, -- adjust to the whatever loglevel you like
marker = 'volvo', -- adjust to whatever marker you want
},
execute = function(domoticz, device)
domoticz.log('Device ' .. device.name .. ' was changed to ' ..device.nValue..','..device.sValue, domoticz.LOG_DEBUG)
-- code to handle the changing of the lock status
if (device.name=='Volvo') then -- Lock device of the Volvo, make sure this is the same name on which the script triggers
-- check if device was locked
if (device.active) then
domoticz.log('Device was locked',domoticz.LOG_DEBUG)
-- Which devices do you want to check?
windowsToBeChecked = { -- make sures these names match the names in domoticz
'Volvo-SunRoof',
'Volvo-FrontLeftWindow',
'Volvo-FrontRightWindow',
'Volvo-RearLeftWindow',
'Volvo-RearRightWindow'
}
-- checking the devices
for key,window in pairs(windowsToBeChecked) do
-- check if window is open
domoticz.log("Checking window "..window,domoticz.LOG_DEBUG)
local WINDOW=domoticz.devices(window)
if (WINDOW.active) then
domoticz.log(window.." is open, sending notification",domoticz.LOG_DEBUG)
notificationMessage = "Auto afgesloten met open raam: "..window
domoticz.notify("Volvo",notificationMessage,domoticz.PRIORITY_HIGH)
domoticz.log("Notification sent: "..notificationMessage,domoticz.LOG_FORCE)
else
domoticz.log(window.." is closed, no need to notify",domoticz.LOG_DEBUG)
end
end
else
domoticz.log('Device was unlocked, no need to do anything',domoticz.LOG_DEBUG)
end
elseif (device.name=='Volvo-ChargingSystemStatus') then -- Lock device of the Volvo, make sure this is the same name on which the script triggers
domoticz.log("Charging system Status changed, check if we have to notify",domoticz.LOG_DEBUG)
if (device.sValue=='Charging') then
domoticz.log("Charging started, notifying",domoticz.LOG_DEBUG)
domoticz.notify("Volvo","Laden is gestart",domoticz.PRIORITY_MODERATE)
elseif(device.sValue=='Done') then
domoticz.log("Charging stopped, notifying",domoticz.LOG_DEBUG)
domoticz.notify("Volvo","Laden is gereed",domoticz.PRIORITY_MODERATE)
elseif(device.sValue=='Fault') then
domoticz.log("Charging Èrror, notifying",domoticz.LOG_FORCE)
domoticz.notify("Volvo","Laden is gestopt, laadfout!",domoticz.PRIORITY_HIGH)
else
domoticz.log("charging status can be ignored: "..device.sValue,domoticz.LOG_DEBUG)
end
else
domoticz.log('Unknown device: '..device.name,domoticz.LOG_ERROR)
end
end
}