We have moved at community.getvera.com

Author Topic: openLuup: Cameras  (Read 4280 times)

Offline martynwendon

  • Full Member
  • ***
  • Posts: 120
  • Karma: +15/-1
Re: openLuup: Cameras
« Reply #60 on: November 01, 2018, 07:21:33 am »
Hey akbooer :-)

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:

Code: [Select]
--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: [Select]
-- 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


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!


Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: openLuup: Cameras
« Reply #61 on: November 01, 2018, 07:36:01 am »
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
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline martynwendon

  • Full Member
  • ***
  • Posts: 120
  • Karma: +15/-1
Re: openLuup: Cameras
« Reply #62 on: November 01, 2018, 10:29:17 am »
Quote
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)