iCSee camera (automation) some tips

Hi.

about cheapest iCSee camera.
some tips.

some tips how to add cam to hass:

  • add cam as Generic Camera
  • add title image like http://homeassistant.local:8123/local/cam-outdoors.png (see details below)
  • add rstp url as rtsp://192.168.1.49:554/user=admin_password=admin_channel=1_stream=1.sdp?real_stream
    where l: admin p: admin
  • use for automation NODE-RED

NODE-RED:
note: please add ffmpeg package if you use hass os

  • enable Alarm server in camera configuration
  • set ip addres and port HASS
  • add flow
[{"id":"f554d78497bfa9b6","type":"debug","z":"d5c119a54699eca1","name":"debug 51","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":560,"y":60,"wires":[]},{"id":"e26ef121319774dc","type":"tcp in","z":"d5c119a54699eca1","name":"","server":"server","host":"","port":"15002","datamode":"single","datatype":"buffer","newline":"","topic":"","trim":false,"base64":false,"tls":"","x":140,"y":80,"wires":[["4cf774deb97fe2f9"]]},{"id":"4cf774deb97fe2f9","type":"function","z":"d5c119a54699eca1","name":"dvr-alarm-server","func":"var data = msg.payload.slice(20);\nmsg.payload = JSON.parse(String.fromCharCode(...data));\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":340,"y":60,"wires":[["f554d78497bfa9b6","ea86aaab4ba99a92"]]},{"id":"ea86aaab4ba99a92","type":"switch","z":"d5c119a54699eca1","name":"HumanDetect","property":"payload.Event","propertyType":"msg","rules":[{"t":"eq","v":"HumanDetect","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":520,"y":100,"wires":[["c704a8f66fc0560b"]]},{"id":"d875af1754de2349","type":"debug","z":"d5c119a54699eca1","name":"debug 52","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":860,"y":60,"wires":[]},{"id":"c704a8f66fc0560b","type":"switch","z":"d5c119a54699eca1","name":"Event start","property":"payload.Status","propertyType":"msg","rules":[{"t":"eq","v":"Start","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":710,"y":100,"wires":[["d875af1754de2349","ac3ea8c3d3c165f1"]]}]

so, now you can catch any motion here.

Next step and about title image http://homeassistant.local:8123/local/cam-outdoors.png
as I said before, do not use native snap URL - it’s kill 80 cam port’s
so,
drop exec node and provide run command

ffmpeg -y -i rtsp://192.168.1.49:554/user=admin_password=admin_channel=1_stream=1.sdp?real_stream -vframes 1 -f image2pipe -vcodec png -

next step pass output to file node


add inject node to periodical polling

And finally, you can pass motion to telegram.
Connect switch “Event start” node to telegram bot.

enjoy

WBR, Oleg
image

UPD: the last iCSee FW fix issues with webcapture

2 Likes

how did you add your icsee camera to the ha? I’ve tried several ways and I couldn’t… the closest I got was local access only. I recently managed to add the camera to Google Home, but I can’t get Google Home devices to appear on the ha like Nabu casa. what I achieved was to make the ha devices appear on Google Home

More than, now this camera works without any issue with my ATV. I can trigger motion for example in HomeKit app.

It looks like some ICSee cameras do work ok with onvif, but in some it isn’t even possible to enable it!

For those, a viable option is to use the DVRIP stream in go2rtc, which can communicate through port 34567 (the one used by ICSee).

And for ptz, I just made a small integration that also uses the same protocol as ICSee.

I just put it in 2 other places in this forum so sorry if you already saw it, but here it is just in case

2 Likes

Cool. Thank you. Btw about PTZ - I am working via ONVIF commands. It’s work. But with some tricks.

Very ugly!

#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import requests
import time
import aiohttp

command_up = """<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><ContinuousMove xmlns="http://www.onvif.org/ver20/ptz/wsdl"><ProfileToken>MainStream</ProfileToken><Velocity><PanTilt x="0" y="-0.1" xmlns="http://www.onvif.org/ver10/schema"/></Velocity></ContinuousMove></s:Body></s:Envelope>"""
command_dn = """<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><ContinuousMove xmlns="http://www.onvif.org/ver20/ptz/wsdl"><ProfileToken>MainStream</ProfileToken><Velocity><PanTilt x="0" y="0.1" xmlns="http://www.onvif.org/ver10/schema"/></Velocity></ContinuousMove></s:Body></s:Envelope>"""
command_right = """<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><ContinuousMove xmlns="http://www.onvif.org/ver20/ptz/wsdl"><ProfileToken>MainStream</ProfileToken><Velocity><PanTilt x="-0.1" y="0" xmlns="http://www.onvif.org/ver10/schema"/></Velocity></ContinuousMove></s:Body></s:Envelope>"""
command_left = """<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><ContinuousMove xmlns="http://www.onvif.org/ver20/ptz/wsdl"><ProfileToken>MainStream</ProfileToken><Velocity><PanTilt x="0.1" y="0" xmlns="http://www.onvif.org/ver10/schema"/></Velocity></ContinuousMove></s:Body></s:Envelope>"""
command_stop = """<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><Stop xmlns="http://www.onvif.org/ver20/ptz/wsdl"><ProfileToken>MainStream</ProfileToken><PanTilt>true</PanTilt><Zoom>false</Zoom></Stop></s:Body></s:Envelope>"""

@service
def send_tilt_command(command, timeout=0.1):
    """yaml
name: simple onvif command for iCsee camps
description: simple ovif command for iCsee camps
fields:
  command:
     description: move cam up, fire fires an event
     example: up
     required: true
     selector:
       select:
         options:
           - up
           - dn
           - left
           - right

  timeout:
     description: timeout for stop moving. DEFAULT 0.1
     example: 0.5
     required: false
     selector:
       int:
"""
    xml = command_stop
    if command == "up":
        xml = command_up

    if command == "dn":
        xml = command_dn

    if command == "left":
        xml = command_left

    if command == "right":
        xml = command_right

    url = "http://login:[email protected]:8085/onvif/ptz_service"
    # set what your server accepts
    headers = {'Content-Type': 'application/xml'}

    async with aiohttp.ClientSession() as session:
       async with session.post(url, data=xml, headers=headers) as resp:
         print(resp.status)
         print(resp.text())

    task.sleep(timeout)

    async with aiohttp.ClientSession() as session:
       async with session.post(url, data=command_stop, headers=headers) as resp:
         print(resp.status)
         print(resp.text())

btw, no 34567 port here!

orangepi@orangepi:~$ nmap 192.168.1.49
Starting Nmap 7.80 ( https://nmap.org ) at 2023-05-30 09:36 EEST
Nmap scan report for 192.168.1.49
Host is up (0.0055s latency).
Not shown: 997 closed ports
PORT STATE SERVICE
80/tcp open http
554/tcp open rtsp
8085/tcp open unknown

Try with nmap -p0-65535 192.168.1.49 (it will take a while)

1 Like

Hi! I am a “happy” owner of these cameras. Connected using go2rtc and added @mateine integration for management. Everything seems to be ok! It remains only to catch the motions. Could you explain in more detail about the node-red.

  1. The alarm server on the camera is enabled
  2. “Set the HASS IP address and port” - this item is not very clear, should it be written on the camera or in a node-red somewhere?
    and the last couple of paragraphs with the launch node - where to connect it?

[{"id":"f554d78497bfa9b6","type":"debug","z":"d5c119a54699eca1","name":"debug 51","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":560,"y":60,"wires":[]},{"id":"e26ef121319774dc","type":"tcp in","z":"d5c119a54699eca1","name":"","server":"server","host":"","port":"15002","datamode":"single","datatype":"buffer","newline":"","topic":"","trim":false,"base64":false,"tls":"","x":140,"y":60,"wires":[["4cf774deb97fe2f9"]]},{"id":"4cf774deb97fe2f9","type":"function","z":"d5c119a54699eca1","name":"dvr-alarm-server","func":"var data = msg.payload.slice(20);\nmsg.payload = JSON.parse(String.fromCharCode(...data));\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":340,"y":60,"wires":[["f554d78497bfa9b6","ea86aaab4ba99a92"]]},{"id":"ea86aaab4ba99a92","type":"switch","z":"d5c119a54699eca1","name":"HumanDetect","property":"payload.Event","propertyType":"msg","rules":[{"t":"eq","v":"HumanDetect","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":520,"y":100,"wires":[["c704a8f66fc0560b"]]},{"id":"d875af1754de2349","type":"debug","z":"d5c119a54699eca1","name":"debug 52","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload.StartTime","statusType":"msg","x":840,"y":60,"wires":[]},{"id":"c704a8f66fc0560b","type":"switch","z":"d5c119a54699eca1","name":"Event start","property":"payload.Status","propertyType":"msg","rules":[{"t":"eq","v":"Start","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":690,"y":100,"wires":[["d875af1754de2349","66a04380f5c14a2c"]]}]

I could add alarms support to the integration. Those would work even in cameras that don’t support an alarm server

2 Likes

it would be wonderfull !

1 Like

What is that sofware? is that xmeye or something else?

idk. i’ts a native webcam interface.

1 Like

Error 127 can be solved by adding ffmpeg to the System Packages of Node RED

1 Like

example:

1 Like

You think it’s possible to have a alarm sensor without nod red ?

where did you had this ?

yes, but it’s we can achieve only via developing a new custom component.
kk, i’ll be looking how

sorry but all icsee camera could’nt work with onvif on home assitant ?

no. You do not understand me clearly.

  1. iCsee cams (AFAIK) has a strange implementation of ONVIF.
  2. HASS trying to speak with iCsee via ONVIF protocol, but fail
  3. more than, HASS (in my situation) send a strange command what rebooting the cam

you can send some (sic!) standard ONVIF commands manually. An example was attached here.