Release Foscam HD - Video feed with camera controls, and motion/sound detection preview
Possible fix for cheap 40.00 IP Cams from China under various names.

Tools:
1) Download and install PyCharm.
2) Download Filezilla or some other FTP program.
3) If your using an android set top box, download EZ file via playstore.
4) If using android. Load EZ File and go to network to start sharing so you can access your box via FTP.
5) If on android go to Android/data/org.xbmc.files/.kodi/addons/packages
6) Copy script.foscam-0.0.1.zip to your local drive.
7) Extract the file to a directory.
8) Open these two files using PyCharm:
a) service.py
b) foscam.py

Code:
Make the following changes:
service.py
Add this under self._url_cameracontrol inside __init__
        self.url_camerastatus = "http://{0}:{1}/get_status.cgi?{{0}}&user={2}&pwd={3}".format(host,
                                                                                                port,
                                                                                                user,
                                                                                                password)
        
service.py
top of send_command should be replaced and it should read:
        print cmd
        if 'param=5' in cmd: url = self._url_cameracontrol.format(cmd)
        elif 'getDevState' in cmd: url=self.url_camerastatus.format(cmd)
        else: url = self._url_fmt.format(cmd)
        if params is not None:
            url += "&" + urllib.urlencode(params)

service.py
search for alarm_check and top of routine should read this:
    def alarm_check(self):
        if self.motion_enable or self.sound_enable:
            player = xbmc.Player()
            if player.isPlaying() and player.getPlayingFile() == self.camera.video_url:
                return

            self.alarm_active = False
            
            dev_state = self.camera.get_device_state()
            if dev_state:
                for alarm, enabled in (('alarm_status', self.motion_enable),
                                       ('sound_status', self.sound_enable)):
                    if enabled:
                        param = "{0}Alarm".format(alarm)
                        alarm_status = dev_state[param]
                        utils.log_verbose("{0:s} = {1:d}".format(param, alarm_status))
                        if alarm_status == 1:
                            self.alarm_active = True
                            utils.log_normal("Alarm detected")
                            break

NOTES:
This is simply a hack to get the program to check the cheap china cams for the alarm status of motion being detected. the existing routines were trying to find the status for a URL that doesn't exist on the cheaper cams.
I didn't add any support for you to be able to SET your motion detection from the Kodi arena... You still have to set that on the camera.
I also don't believe the sound detection will function on the cheaper china cams like the one I have. Maybe if I get some time and a better DEV env I could work it out... But for now I wanted to share.

Once your done with all your changes you must zip it back up (using standard zip) and place it back in the same directory you got it from.
Then go into Kodi and find it in your list... Install it.

This code is untested... But should be pretty close.

Here is the URL to get the alarm (motion) status from your cheap china cam:
http://192.168.X.XXX/get_status.cgi?user...Collin1133

Good luck.
Reply


Messages In This Thread
RE: Foscam HD - by George - 2014-03-27, 17:30
Code changes for the cheap China Cameras - by vtwin4Christ - 2015-12-07, 11:03


Logout Mark Read Team Forum Stats Members Help
Foscam HD - Video feed with camera controls, and motion/sound detection preview1
This forum uses Lukasz Tkacz MyBB addons.