Module: Android IP WebCam

From Yombo
Jump to: navigation, search
Quick Facts
Links
Documentation
Repository
Issue tracker
Module Details
Device types
Created 2018-12-18 06:30:09 GMT
Developer Details
Prod Branch master
Prod Updated 2019-01-02 00:01:23
Prod Version None
Dev Updated 2018-11-03 20:36:58
Dev Version None

Summary

Utilize the Android IP Webcam application to record images and act as a motion and audio sensor. This uses FFMPEG for audio and image processing. Automation rules can be used to trigger saving images when motion or audio is detected.

Requirements

  • An Android tablet or phone.
  • Install IP Webcam on the device.

Installation

  • Install and configure the IP Webcam application on the Android device.
    1. Tip: Set a static IP address for the Android device.
  • Install the Android IP webcam module within the Yombo Gateway software.

Device Setup

  1. Open the Yombo gateway web interface
  2. From the main menu, select "Devices", then select "Add new device".
  3. Select "Android IP Webcam" from the device type drop down.
  4. After entering basic information such as device label and description, enable the motion and noise sensors as desired along with their sensitivity settings.
  5. Restart the gateway for the device to start working.

Usage

If motion or noise sensors are enabled, additional devices will automatically be created. These can be used to save still images (future version will allow saving videos).

Example code

Using a local, custom module, still images can be saved using the following code example:

 1 from time import time
 2 
 3 from twisted.internet.defer import inlineCallbacks
 4 
 5 from yombo.core.module import YomboModule
 6 from yombo.core.log import get_logger
 7 
 8 from yombo.utils import sleep
 9 
10 logger = get_logger("modules.mitchautomation")
11 
12 
13 class MitchAutomation(YomboModule):
14     """
15     Advanced automation rules for Mitch
16     """
17     def _init_(self, **kwargs):
18         self.started = False
19 
20     def _load_(self, **kwargs):
21         self.started = True
22         self.kitchen_webcam_motion_capturing = False
23 
24         self.kitchen_webcam = self._Devices.get("kitchen_webcam")
25         self.kitchen_webcam_motion = self._Devices.get("kitchen_webcam_motion")
26 
27     @inlineCallbacks
28     def start_recording_kitchen(self):
29         if self.kitchen_webcam_motion_capturing:
30             return
31         self.kitchen_webcam_motion_capturing = True
32         while self.kitchen_webcam_motion.status == 1:
33             start = time()
34             image = yield self.kitchen_webcam.get_camera_image()
35             yield self._Storage.save_data(
36                 image.content,
37                 f"file://kitchen_webcam_motion/{self._Storage.expand(500)}/{int(round(time(), 3)*1000)}.jpg",
38                 expires=1,
39                 public=True)
40             duration = time() - start
41             if duration < .250:
42                 yield sleep(.250 - duration)
43 
44         self.kitchen_webcam_motion_capturing = False
45 
46     def _device_status_(self, **kwargs):
47         if self.started is False:
48             return
49 
50         device = kwargs['device']
51         if device.machine_label == "kitchen_webcam_motion" and device.status == 1:
52             self._Calllater.new(0.001, self.start_recording_kitchen)

License

See LICENSE.md file for full details.

The Yombo team and other contributors hopes that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


This page was last edited on 2 January 2019.