openLuup: Cameras

Hey akbooer :slight_smile:

I’ve been running openLuup for a looong time now and it’s that stable that I’ve not had to touch it for over a year (I use it mostly to integrate with my Visonic alarm).

I finally updated yesterday to take advantage of some of the newer features … in particular the smtp camera motion sensor triggers.

My cameras are attached to an NVR which sends the motion event emails from a single IP address to a single destination email address, but with different subjects to specify which channel triggered the event.

So, I very badly hacked smtp.lua and the I_openLuupCamera1.xml to allow registering of a handler for “subject fuzzy matching”.

For now I just used the “mac” attribute on the camera device to hold the partial subject (for example “NVR alarm:NVR1 channel:3”) and made I_openLuupCamera1.xml register the handler with that as the destination with:

--local ip = luup.attr_get ("ip", devNo) --ip = (ip or ''): match "%d+%.%d+%.%d+%.%d+" --if ip then --smtp.register_handler (openLuupCamera, ip) -- receive mail from camera IP --end local mac = luup.attr_get ("mac", devNo) or -1 if mac ~= -1 && and mac ~= nil and mac ~= '' then smtp.register_handler (openLuupCamera, mac) end

Then I added a bodge to smtp.lua for “subject matching”:

[code]-- subject receipients
for i, destination in pairs (destinations) do
local message = state.data: decode () – decode MIME message
local headers = message.header

            local newHeaders = {["content-type"] = "text/plain"}    -- vanilla message
            for a,b in pairs (headers) do
                if type(a) == "string" and not a: match "^content" then
                      newHeaders[a] = b
                end
            end
            newHeaders.subject = newHeaders.subject or "---no subject---"
            if newHeaders.subject:sub(1, #destination.email) == destination.email then
                    deliver (destinations[destination.email])
            end
    end[/code]

It seems to work OK, maybe worth adding as an option to openLuup officially as I am sure it would be useful to others … but of course coded in a much better fashion than my mashed together attempt!

Hi Martyn!

Glad things are going well and also that you’ve updated and are starting to enjoy (and improve) the new features.

I’ll take a look and try and think of a clean way to include this sort of functionality.

I know what you mean about not touching the system… see attached graphs for uptime of my main openLuup installations.

Cheers, AK

I'll take a look and try and think of a clean way to include this sort of functionality.

Cool, my hack works well, but definitely needs improving for general consumption.

This is one of the original RPi and runs my PBX … haven’t touched it for nearly 6 years 8)