I'm happy to hear that!
Mosvold hat geschrieben: ↑So 30. Jul 2017, 14:18
Is it possible to send operation mode commands using JSON to Robonect?
(Such as Start, End of day,
home, etc)
It's quite off topic but you can control the mower from Domoticz by letting Domoticz open an URL. See
Übersicht aller implementierten Kommandos.
Below is a Domoticz dzVents script. (Minimum dzVents version is 2.2.0). It can serve as an example of what you can do. If You have further questions about dzVents or the script, it's better to ask them at the Domoticz forum.
Good luck!
Code: Alles auswählen
--[[
glenn.lua by BakSeeDaa
dzVents Lawn Mower script
Version 1.1.1
--]]
local MOWER_NAME = 'Glenn'
local STATUS_DETERMINING = 'Status is determined'
local STATUS_PARKED = 'Parked'
local STATUS_MOWING = 'Mowing'
local STATUS_LOOKING = 'Seeking charging station'
local STATUS_LOADING = 'Charging'
local STATUS_SEARCHING = 'Moving to lawn mowing area'
local STATUS_ERROR = 'Error'
local STATUS_LOST_SIGNAL = 'Circuit error'
local STATUS_SWITCHED_OFF = 'Turned off'
local STATUS_SLEEPING = 'Sleeping'
local STATUS_MODE_AUTO = 'Auto'
local STATUS_MODE_MAN = 'Manuell'
local STATUS_MODE_HOME = 'Hem'
local STATUS_MODE_DEMO = 'Demo'
local TIMER_STATUS_DISABLED = 'Inactive'
local TIMER_STATUS_ACTIVE = 'Active'
local TIMER_STATUS_STAND_BY = 'Waiting'
local MOWER_URL = 'http://USERNAME:PASSWORD@MYMOWERHOST:80/'
return {
active = true,
logging = {
--level = domoticz.LOG_DEBUG, -- Select one of LOG_DEBUG, LOG_INFO, LOG_ERROR, LOG_FORCE to override system log level
marker = "glenn"
},
on = {
devices = {
'Glenn Sensor', -- The alarm sensor
'Glenn Status', -- Main status
'Glenn Mode', -- Operating mode
'Glenn Timer Status', -- Timer Status
'Glenn Battery Level',
},
timer = {
'every 15 minutes'
}
},
data = {
lastFeierAbend = { history = true, maxItems = 1 }
},
execute = function(domoticz, device, triggerInfo)
local MOWER_STATUS_DEVICE = domoticz.devices('Glenn Status')
local MOWER_ALARM_DEVICE = domoticz.devices('Glenn Sensor')
-- Init data if missing (e.g. the first time that the scripts runs)
if (domoticz.data.lastFeierAbend.size == 0) then domoticz.data.lastFeierAbend.add('Init') end
if triggerInfo.type == domoticz.EVENT_TYPE_DEVICE then
if device.name == 'Glenn Force Mowe until 13:30 and then quit for the day' then
-- See http://robonect.de/viewtopic.php?f=10&t=37
if device.state == 'On'
and (domoticz.devices('Glenn Timer Status').state ~= TIMER_STATUS_ACTIVE) then
local url = MOWER_URL..'job?begin=0&end=1497031200&fs=0&corridor=255&after=3&save=1'
domoticz.sendCommand('OpenURL', url)
else
-- local url = MOWER_URL..'json?cmd=mode&mode=auto'
-- domoticz.sendCommand('OpenURL', url)
end
end
-- Sync dl4b Glenn
-- We need Glenn Sensor to conditionally switch dl4b Glenn because lawn mowing may occur when we are not at home or sleeping
if device == MOWER_ALARM_DEVICE then
if device.state == 'On'
and (domoticz.devices('Glenn Timer Status').state == TIMER_STATUS_STAND_BY) then
if (domoticz.devices('dl4b Glenn').state ~= 'On') then domoticz.devices('dl4b Glenn').switchOn() end
else
if (domoticz.devices('dl4b Glenn').state ~= 'Off') then domoticz.devices('dl4b Glenn').switchOff() end
end
end
if device.name == 'Glenn Status' then
local event = 'Robotklipparen Glenn'
local description = ''
local priority = -2
if (device.state == STATUS_SEARCHING) then
if domoticz.devices('Glenn Timer Status').state == TIMER_STATUS_ACTIVE then
-- The robot is scheduled for activity and allowed to go out ...
description = MOWER_NAME..' will begin mowing the lawn.'
else
-- The robot is working outside it's schedule ...
description = MOWER_NAME..' working late hours'
end
elseif (device.state == STATUS_LOOKING) then
if (domoticz.devices('Glenn Timer Status').state == TIMER_STATUS_ACTIVE)
or (domoticz.devices('Glenn Timer Status').state == TIMER_STATUS_DISABLED) then
-- The robot is scheduled for activity and allowed to go out and in...
-- or returning from a job outside it's normal schedule
description = MOWER_NAME..' is docking for recharging the batteries.'
elseif domoticz.devices('Glenn Timer Status').state == TIMER_STATUS_STAND_BY then
-- The robot has finished a job within it's normal schedule ...
description = MOWER_NAME..' is crawling back to his shed and finishes his job for this day.'
end
end
if description ~= '' then
domoticz.helpers.sendNotification(event, description, priority)
if (priority == 0) then
domoticz.helpers.speak(domoticz.security, description, '', 1)
else
domoticz.helpers.speak(domoticz.security, description)
end
end
end
elseif triggerInfo.type == domoticz.EVENT_TYPE_TIMER then
if (MOWER_STATUS_DEVICE.state == STATUS_MOWING
or MOWER_STATUS_DEVICE.state == STATUS_LOOKING
or MOWER_STATUS_DEVICE.state == STATUS_SEARCHING
or MOWER_STATUS_DEVICE.state == STATUS_ERROR)
and MOWER_STATUS_DEVICE.lastUpdate.minutesAgo > 133 then
-- Glenn has been out for too long. Where is he?
local event = 'Robotklipparen '..MOWER_NAME
local description = MOWER_NAME..' has been out for too long . Is he drunk or what?'
local priority = 0
domoticz.helpers.speak(domoticz.security, description, '', 1)
domoticz.helpers.sendNotification(event, description, priority)
end
if domoticz.time.hour > 9 and domoticz.time.hour < 17
and domoticz.devices('WH2600 Rain').rainRate > 0.015
and domoticz.data.lastFeierAbend.getLatest().time.hoursAgo > 12
and domoticz.devices('Glenn Mode').state == STATUS_MODE_AUTO then
domoticz.data.lastFeierAbend.add()
local message = 'Oh no, it\'s raining. '..MOWER_NAME..' gets the rest of the day off.'
domoticz.log(message, domoticz.LOG_INFO)
domoticz.helpers.speak(domoticz.security, message)
local url = MOWER_URL..'json?cmd=mode&mode=eod'
domoticz.sendCommand('OpenURL', url)
end
end
end
}