API for Xeoma

Xeoma Software

Moderators: Admin_N, Administrator, Admin_P, Admin_K

API for Xeoma

Postby psmith » Fri Jun 02, 2017 8:35 pm

Does Xeoma have an API?

When an external event occurs I would like to send a signal to Xeoma to start recording video for a specified time. For example, if a visitor presses a door bell button I would like that to signal Xeoma that it should record the visitor's image.
psmith
 
Posts: 2
Joined: Fri Jun 02, 2017 8:30 pm

Re: API for Xeoma

Postby skylord123 » Fri Jun 02, 2017 10:00 pm

I'm working on something similar but with PIR motion sensors instead. Take a look at the HTTP switcher module. It gives you the ability to create a URL that you can use to turn something on and off (and even a time limit to stay on I believe).
skylord123
 
Posts: 32
Joined: Fri Jun 02, 2017 5:18 pm

Re: API for Xeoma

Postby psmith » Sat Jun 03, 2017 8:39 am

Thanks. That is exactly what I need. Xeoma is rather more capable than I first thought!
I rather like your idea and am thinking of doing the same as follows:
1) Several PIR sensors with 433 Mhz radio link
2) Transmit movement signals via radio link to
3) Arduino concentrator hub with 433 MHz module, wifi module and TM1638 display module
4) Arduino sends http-request via wifi to Xeoma switcher module
5) Arduino flashes LED and displays PIR sensor number, button to cancel alarm.
6) Switcher module turns on the video stream corresponding to PIR sensor number to start recording.

Then turn off recording with suitable delay after movement stopped or alarm cancelled.
psmith
 
Posts: 2
Joined: Fri Jun 02, 2017 8:30 pm

Re: API for Xeoma

Postby skylord123 » Mon Jun 05, 2017 3:51 pm

Yeah very similar to my setup. Only real difference is I am using the esp8266 to publish MQTT messages. My server will then listen for these MQTT messages and respond (Really wish Xeoma had a MQTT module so I didn't have to have a python script as a middle man). Reason for doing this is I can have Home Assistant listen to MQTT for these same events. That way having my PIR motion sensor at my front door can work to turn on my font light as well as triggering my cameras to record. I am also going to use it to let me know if someone is at the front door (if package gets delivered or what not). I also plan to add some temp and door sensors and using MQTT makes this very easy.

I will also be setting up my cameras so it uses a combination of PIR motion sensing with the built in Xeoma motion sensing during the day then only use PIR at night (bugs cause a ton of false positives which just eats up my storage space, want to bring false positives down). Just like you said, Xeoma is a lot more capable once you start diving into it. Awesome we can setup rules this way.

EDIT: One thing I would love to figure out is how to use the esp8266 to control how sensitive the PIR sensor is (instead of using pots) that way I could change the sensitivity without physical access to the device.

EDIT2: Found out you can use the HTTP Marking module to apply tags to recordings at that time. I am going to use this with my PIR motion sensors so I can filter out recordings that happened because of the PIR motion sensor or the built in Xeoma one.
skylord123
 
Posts: 32
Joined: Fri Jun 02, 2017 5:18 pm

Re: API for Xeoma

Postby jonbanjo » Sat Jul 01, 2017 10:31 am

A few possibilities here. In my case, I’d use my mess of HA bits and pieces (currently Vera wich I’d hoped would do te lot but proved unreliable for me doing zwave and my own python and java which I aim to replace doing the rest). Essentially it would be HA → xeoama.

With what I have, sensor could be X10, LightwaveRF, Zwave or Visonic but I think that could be simplified to the Visonic alarm (for which there is a cheap rs232 interface and although proprietary, a reasonably well documented, on the Internet, protocol) or the more general HA types.

I think the Visonic is probably the most reliable but the sensors go into a sleep mode for a few minutes after a couple of motion detections. This makes sense if the aim is to act on an intrusion but limits their usefulness for more general HA.


A bit of a drift but something I do in the kitchen and living room is to use the cameras own detection (a foscam and a hikvision) in addition to what xeoma does (for me atm, just record and archive when motion is detected). They just send out an email to a custom SMTP server in the HA. Too “laggy” to switch a light on but I find it quite handy to keep a light on, eg, someone washing up might not trigger the HA sensor but the cams can be set to be more sensitive (and of different sensitivity to xeoma).

O well, I guess we just keep playing with these things and eventually get towards things that work for us…).
jonbanjo
 
Posts: 10
Joined: Fri May 19, 2017 9:01 am

Re: API for Xeoma

Postby Admin_P » Tue Jul 25, 2017 2:32 pm

Hello! You may also find the Web Server's API useful.
Admin_P
 
Posts: 245
Joined: Wed Aug 24, 2016 1:49 pm

Re: API for Xeoma

Postby skylord123 » Sat Aug 12, 2017 5:41 am

Sorry for not replying in a while!

I recently built a docker that runs a python webserver middle-man that runs between Xeoma and MQTT (You can view it here: https://github.com/skylord123/xeoma-mqtt ). It takes requests from the HTTP Request Sender module (you point this module to the docker open port) and it will turn the http request into an MQTT message and post it so HA can act on it. I've been using it with a second motion detection module on my front yard cameras to trigger my garage door lights if motion is detected in my driveway and my front door light if motion is detected on the path going up to my front door. It works pretty well. Only issue I have right now is bugs flying in front of the camera but I have been able to bring these false reports down by using the "Disregard motion shorter than" in the motion module.

Now I have also setup HA to trigger recordings on my inside cameras when my PIR motion sensor goes off. It works like this: The PIR motion sensor is an ESP8266 with a cheap PIR motion sensor. When motion is detected it sends a message over MQTT to a channel. HA then gets this and then triggers the "HTTP Switcher" module on my inside camera to start recording. I use this with the motion module and tagging so I know which event triggered the recording. Here is how it looks:
Camera module setup: https://u34423400.dl.dropboxusercontent.com/u/34423400/DualCameraTriggerWithCondition.png
Camera condition module setup: https://u34423400.dl.dropboxusercontent.com/u/34423400/ConditionDualTrigger.png

And here is the code I use to trigger the recording from HA (had to use CURL commands) as well as get status of the switch (so HA isn't in the dark when a reset happens or something and the switch is still on):
Code: Select All Code
switch:
  - platform: command_line
    switches:
      inside_camera_record:
        command_on: 'curl -k "http://xxx.xxx.xxx.xxx:10090/record_trigger_on?module=HttpSwitcher.8"'
        command_off: 'curl -k "http://xxx.xxx.xxx.xxx:10090/record_trigger_off?module=HttpSwitcher.8"'
        command_state: 'curl -k "http://xxx.xxx.xxx.xxx:10090/record_trigger_off?module=HttpSwitcher.8&show_status=true"'
        value_template: '{{ "On" in value }}'


I really want to make it so the xeoma-mqtt code I have written can trigger switches in xeoma from MQTT (that way I don't have to use Curl). Will probably add this in the future. But this works great for now.

EDIT: SMTP to trigger your lights.. Oh man. You can definitely easily improve that response time by switching to another method.
skylord123
 
Posts: 32
Joined: Fri Jun 02, 2017 5:18 pm

Re: API for Xeoma

Postby jonbanjo » Sat Aug 12, 2017 1:16 pm

skylord123 Wrote:SMTP to trigger your lights.. Oh man. You can definitely easily improve that response time by switching to another method.


I didn't notice any other method my cameras have but maybe they do. i originally used this with an ageing Foscam clone a good while ago and maybe didn't look that hard when we got the new cameras... In neither of my usages is the camera used to turn the light on.

Kitchen is turned on by a Fibaro Z Wave sensor. My aim is to have the lights turn off after 3 minutes of "non movement". All the camera needs to do is get one "movement" message through in that time frame to reset a countdown timer in the HA. I've found this method more effective than trying to cover the area with 2 HA sensors and the camera is sensitive enough to say detect someone standing over the stove stirring a pot.

I'm not sure living room (where the lights are usually turned on/off by a remote control) is really needed now we are all LED but at one time when we were on incandescent bulbs, everything on used about 600W and they could get left on. The aim was similar to the kitchen but in this case it will shut down to one table lights after 30 minutes of "non motion".

Anyway, just trying to explain further what I'm doing there and what has worked for me. I'm certainly not claiming it is "the right way" or that there may not be better methods.
jonbanjo
 
Posts: 10
Joined: Fri May 19, 2017 9:01 am

Re: API for Xeoma

Postby skylord123 » Sat Aug 12, 2017 4:35 pm

If that works that is awesome. I would have never even thought to use SMTP to trigger things in HA. Just make sure you keep this in mind if you are using a mail server outside of your internal network (gmail, hotmail, etc):

1) You are at the mercy of your internet connection as well as the uptime of the SMTP service.
2) Most mail providers have a mail sending limit. Gmail will only allow 100-150 emails per day when sending outside of their web gui (via their smtp service).

Personally I hate the idea of having any third party handle my data. I also hate being at the mercy of something I don't really have any control over (ISP or mail provider). That is why I use a local MQTT server to process things. I have lost internet at various times and nothing skips a beat. I also get motion events in HA in milliseconds compared to several seconds for SMTP (least I am guessing? Would be curious how long it actually takes to send these events using SMTP).

If you are hosting your own local mail server, then 10/10 to you for effort. I hate setting up mail servers, lol.
skylord123
 
Posts: 32
Joined: Fri Jun 02, 2017 5:18 pm

Re: API for Xeoma

Postby jonbanjo » Sat Aug 12, 2017 5:06 pm

Ah, this is based around the python smtp server. It's rather crudely hacked wit some hard coding that shouldn't be (as tends to be with my own stuff...) and rather wrapped up in the (I believe now redundant) XPL stuff I use - it's just one module in a program that runs on a pi, another does the rfxcom, etc. but maybe you can decipher something from it.

Code: Select All Code
import jfxplbase
import jfxplutil
import collections
import smtpd
import asyncore
import time
import smtplib

class CustomSMTPServer(smtpd.SMTPServer):
   
    armed = {};
   
    def process_message(self, peer, mailfrom, rcpttos, data):
        try:                                                                                                                                                                   
            isArmed = self.armed[mailfrom]                                                                                                                                     
        except:                                                                                                                                                               
            self.armed[mailfrom] = True                                                                                                                                       
                                                                                                                                                                               
        self.iface.send(mailfrom, self.armed[mailfrom], "on")                                                                                                                 
        if self.armed[mailfrom]:
            smtp = smtplib.SMTP("172.23.41.10", 25)
            smtp.sendmail(mailfrom, rcpttos, data)

    def setArmed(self, arm):
        self.armed = arm;
       
    def setiface(self, iface):
        self.iface = iface
       
class jfipcam(jfxplbase.jfxplBase):
   
    def __init__(self, sendQueue, id, host, listen, mode, params):
       
        self.mode = mode
        self.params = params
        self.yearday = -1
        self.isdark = True
        self.time = time.localtime()
       
        self.inf = collections.OrderedDict()
        self.inf["hop"] = "1"
        self.inf["source"] = "jf-jfxpl." + id
        self.inf["target"] = "*"
       
        super(jfipcam, self).__init__(sendQueue,id, host, listen)
   
    def send(self, address, armed, cmd):
        command = "xpl-trig"
        schema = "sensor.basic"
        data = collections.OrderedDict()
        data["device"] = address
        data["armed"]= str(armed)
        data["command"] = cmd
        xpl = jfxplutil.makexpl(command, self.inf, schema, data)
        self.sendQueue.put(xpl)
   
    def processMessage(self, command, inf, schema, data):
        if super(jfipcam, self).processMessage(command, inf, schema, data):
            return True
        try:
            address = data["address"]
            #print data
            if data["arm"] == "on":
                self.smtpserver.armed[address] = True
            else:
                self.smtpserver.armed[address] = False
            return True
        except Exception as e:
            print e
        return True

    def dostart(self):
        self.smtpserver = CustomSMTPServer(('172.23.41.52', 1025), None)
        self.smtpserver.setiface(self)
        super(jfipcam, self).dostart()
        return True


Basically if a camera reports movement, it kicks out an XPL message. If the camera is armed, it also sends an email to my email address (yep, via a postfix server)
jonbanjo
 
Posts: 10
Joined: Fri May 19, 2017 9:01 am

Re: API for Xeoma

Postby jonbanjo » Sat Aug 12, 2017 5:12 pm

(the lag is mostly in the time the camera takes to send out an email)
jonbanjo
 
Posts: 10
Joined: Fri May 19, 2017 9:01 am

Re: API for Xeoma

Postby ReidHao » Thu Nov 29, 2018 6:38 pm

Hello...in my case my server will then listen for these MQTT messages and respond. Reason for doing this is I can have Home Assistant listen to MQTT for these same events. That way having my PIR motion sensor at my front door can work to turn on my font light as well as triggering my cameras to record.
ReidHao
 
Posts: 1
Joined: Thu Nov 29, 2018 6:35 pm

Re: API for Xeoma

Postby TeraWales » Wed Apr 10, 2019 5:39 pm

Hi...as per my knowledge sensor could be X10, LightwaveRF, Zwave or Visonic but I think that could be simplified to the Visonic alarm or the more general HA types.I think the Visonic is probably the most reliable but the sensors go into a sleep mode for a few minutes after a couple of motion detections.
TeraWales
 
Posts: 1
Joined: Wed Apr 10, 2019 5:31 pm

Re: API for Xeoma

Postby Prajwal Kale » Mon Jul 15, 2019 8:35 am

Thank you for the information.
Prajwal Kale
 
Posts: 3
Joined: Fri Jul 12, 2019 5:54 am


Return to Xeoma - General discussion

Who is online

Users browsing this forum: No registered users and 11 guests