Thanks Matt, I appreciate you spending some time on my use case. There is a lot to think about in your reply.
The basic idea was to make a easy to happen upon, top view, relatively up to date image without having to do anything like refresh, activate VPN, dig through sub sections, menus etc. I try to make this stuff as easy as possible to use usefully.
I have achieved this now with the current binding and will post the code for completeness at the bottom.
One thing I have noticed with higher refresh rates is my openHAB log filling up with
GarageCamImage changed from raw type (image/jpeg): 768000 bytes to raw type (image/jpeg): 768000 bytes
I try to avoid too much normal business stuff appearing in the logs because the problems and errors get easily missed.
I have three cameras. Here is the garage camera example
.thing
Thing ipcamera:HTTPONLY:001 "Garage camera" @ "Cams"
[
IPADDRESS="192.168.x.x",
USERNAME="x",
PASSWORD="x",
SNAPSHOT_URL_OVERRIDE="http://192.168.x.x/live/0/jpeg.jpg",
POLL_CAMERA_MS=2000,
IMAGE_UPDATE_EVENTS=0,
UPDATE_IMAGE=false,
PORT=80
]
.items
Switch UpdateAllImages "Update images" <camera>
Switch IPCameraImageUpdate_Timer "Update IP camera images timer" <time> {expire="15m,command=ON"}
Image GarageCamImage "Garage camera image" <camera> { channel="ipcamera:HTTPONLY:001:image" }
Switch GarageCamUpdateImage "Get new image" <camera> { channel="ipcamera:HTTPONLY:001:updateImageNow" }
.rule
For manual activation of image update and automatic update every 15mins
rule 'Start updating camera images'
when
Item UpdateAllImages changed to ON or
Item IPCameraImageUpdate_Timer changed to ON
then
GarageCamUpdateImage.sendCommand(ON)
TerraceCamUpdateImage.sendCommand(ON)
PorchCamUpdateImage.sendCommand(ON)
IPCameraImageUpdate_Timer.sendCommand(OFF)
logInfo("Camera", "Updating started" )
if (UpdateAllImages.state != ON) {
if (ImageTimer === null) {
ImageTimer = createTimer(now.plusSeconds(10)) [|
IPCameraImageUpdate_Timer.sendCommand(OFF)
GarageCamUpdateImage.sendCommand(OFF)
TerraceCamUpdateImage.sendCommand(OFF)
PorchCamUpdateImage.sendCommand(OFF)
logInfo("Camera", "Scheduled updating ended" )
ImageTimer?.cancel()
ImageTimer = null
]
}
}
end
For turning off manual activation of image updating
rule 'Stop updating camera images'
when
Item UpdateAllImages changed to OFF
then
GarageCamUpdateImage.sendCommand(OFF)
TerraceCamUpdateImage.sendCommand(OFF)
PorchCamUpdateImage.sendCommand(OFF)
logInfo("Camera", "Manual activated updating stopped" )
end
For garage door monitoring when commanded to Open or Close
rule 'Start garage camera image update while garage door is moving'
when
Item GarageDoorMoving_Sensor changed to ON
then
GarageCamUpdateImage.sendCommand(ON)
logInfo("Camera" , 'Garage door moving >>> Garage image update started')
end
rule 'Stop garage camera image update '
when
Item GarageDoorMoving_Sensor changed to OFF
then
GarageCamUpdateImage.sendCommand(OFF)
logInfo("Camera" , 'Garage image update Stopped')
end
I am not sure if this needed but it makes sure the 15min timer is running at restart
rule "On restart"
when
System started
then
logInfo("Startup" , "System startup time = " + now.toString("HH:mm dd-MM-yyyy"))
IPCameraImageUpdate_Timer.sendCommand(OFF)
end