jacmet / pir-web

Motion detection and visualization with Tasmota, flask and fullcalendar

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Simple webui for visualizing motion detection on calendar widget

Client is a ESP8266 module with a PIR sensor running Sonoff-Tasmota, which is configured to perform a HTTP GET whenever activity is detected by the PIR sensor using a rule like:

Switchmode1 1
Switchtopic 0
Rule1 on switch1#state=1 do websend [<url>] /add/<id> endon
Rule1 1

See Wemos-D1-Mini-and-HC-SR501-PIR-Motion-Sensor for more info.

The server is written with python-flask, uses a sqlite database and fullcalendar to visualize the motion events on a calendar.

Lighttpd configuration looks something like:

  server.document-root = "/path/to/static"

  # fixup URLs for flask
  url.rewrite-once = (
    "^/static(.*)$" => "$1",
    "^/(events.*|add.*)$" => "/pirweb/$1"
  )

  fastcgi.server = ("/pirweb" =>
    ((
        "socket" => "/tmp/pirweb.sock",
        "bin-path" => "/path/to/pirweb.py",
        "check-local" => "disable",
        "max-procs" => 1
    ))
  )

Password protection (except for the /add endpoint as Tasmota doesn't support authentication) can be done with something like:

  # auth required for everything except add
  auth.backend = "htdigest"
  auth.backend.htdigest.userfile = "/path/to/htdigest"

  $HTTP["url"] !~ "^/pirweb/add" {
    auth.require = ( "" =>
            (
            "method" => "basic",
            "realm" => "<realm>",
            "require" => "valid-user"
            )
    )
  }

About

Motion detection and visualization with Tasmota, flask and fullcalendar


Languages

Language:JavaScript 88.1%Language:HTML 5.9%Language:CSS 4.5%Language:Python 0.8%Language:PHP 0.7%