Sonoff GK-200MP2-B IP Camera

yes, as the app will set-up the camera’s network.

1 Like

thanks for your feedback.
There was something wrong with the access point apparently. Used another AP and it worked fine

I have some good news. I watched a video where EpicLPer was making progress on connection via the UART port on the camera. I then joined in on his GitHub repo and started a wiki page to document the network protocol this camera uses.

As of tonight I have a working proof-of-concept scapy.py Automaton that initialises the communication channel, then has the camera nod its head repeatedly up/down/left/right.

It’s crude but then so is the network protocol!

Essentially: (C = client, S = server/Sonoff camera)
C => broadcast to local LAN on port 32108
S => replies to the client’s originating port from the (new?) port its listening on with a cookie
C => returns the cookie to the server’s listening port directly
S => replies with a slightly modified version of the cookie indicating success
C => sends a ‘client initialising’ packet - client command index reset to 0
S => sends acknowledgement
S => sends a ‘server initialising’ packet - server command index reset to 0
C => sends acknowledgment

From this point on if there’s a gap of > 1250 msec a “Keepalive” exchange is triggered:

S => sends “Marco”
C => replies with “Polo”
C => sends “Marco”
S => replies with "Polo

This will keep the channel open until the client sends a command which the server will acknowledge as above, with the command index incrementing by one each time.

This works even if the camera is isolated from the WAN (it still makes DNS requests of the local DHCP-supplied resolver), and the RTSP streams can be opened while the camera motion is triggered as above.

I have not yet figured out if it’s possible to enable the RTSP stream / set the password without using the app however, but hopefully others might be interested and can help take this reverse engineering further?

Cheers
Mike

5 Likes

It looks like the RTSP password can indeed be set programatically - so is anyone interested in collaborating on a proof of concept integration with Home Assistant?

2 Likes

Really interesting ! I have this camera but the cloud app is very boring and I would like to add this camera into my Home Assistant setup.
But I don’t know how I can help you.

Hi Benny - I’m looking for someone with experience of writing HA integrations, to work on the communication with the camera. I’ve used the RTSP feed to import video into a Lovelace card from the Sonoff camera, but that doesn’t give any options to send pan/tilt commands to the camera nor (as far as I’m aware) to enable the audio path? I’m hoping that a custom integration would be able to:

  1. Discover cameras on the local LAN
  2. Set up RTSP feeds for the cameras (ideally, avoiding the app, but not necessary)
  3. Enable the camera angle to be changed, and perhaps other functions set up as well
  4. React to motion alerts and feed those into HA to trigger automations?

Currently my code works stand-alone in Python, and I’m not sure how easy it’ll be to incorporate within HA, thus the hope someone with more integration experience can lend a hand.

@michthom I took a quick look at your repo. It seems like you got a root shell on the camera, correct? Would this enable you to find out the telnet password for the camera? And if so, would you please share this password (user root)?

I can only connect my device via ethernet, not wifi. I don’t want to take it apart because I don’t want to brick it, but it’d be nice to telnet into it and see if I can fix the wifi configuration so that it will work in my network.

Hi @prankousky - to be clear the repo is not mine, its EpicLPer’s - and his YouTube videos as well. As far as I’m aware he’s got root via the serial connection, but the telnet port (while open) isn’t usable as there seems to be no valid password for the root account when connecting via telnet. I’m also using just the network-based approach, and have no direct login via any of the ports that I found to be open, which are:

  • 23 (telnet)
  • 554 (RTSP)
  • 7101 (??)
  • 7103 (??)
  • 8081 (HTTP?)
  • 65530 (??)
1 Like

Some got the PTZ working on homeassistant?

Hello @jmvaz - not in Home Assistant yet, but I’ve got discovery and independent control of multiple Sonoff cameras working in Python now. Here they are doing the Independence Dance!

I would already be happy with being able to switch on/off the movement detection from within HomeAssistant, based on the ‘Alarm’ state of the house.
Panning and Tilting I can do manually using the eWeLink app when needed (mainly when getting an movement detection alarm).
So the automating of the detection en/dis abling would help my case since there’s no automated alternative for it.

2 Likes

Hi. Thank you for link to EpicLPer work.
I have this camera and can add support to my component:

2 Likes

Hi Alexey
I’ll put my code into a GitHub repo and invite you to collaborate if you’d like, let’s see what we can make work?!

Supported (only PTZ now) in latest master version of SonoffLAN:

4 Likes

hey that is great work thanks! Can you tell me what the purpose for th created binary_sensor?

I am looking forward to when you camera entity will be created. Until then i can manage with this.

image

1 Like

All unsupported ewelink devices displayed as binary sensor always off. To know what they are.

Hey!

Did any of you come into the issue with this Sonoff camera being not available to HA after running for several hours?

After around 10 hours of running I get the following errors in the log:

Timeout reading image.
Logger: haffmpeg.tools
Source: __main__.py:356 
First occurred: 20:41:15 (100 occurrences) 
Last logged: 21:01:32

Timeout reading image.
Error on receive image from entity: Unable to get image
Logger: homeassistant.components.image_processing
Source: components/image_processing/__init__.py:128 
Integration: Przetwarzanie obrazu (documentation, issues) 
First occurred: 20:41:10 (106 occurrences) 
Last logged: 21:01:54

Error on receive image from entity: Unable to get image

Any clue what is the cause of that and how to fix it? I’m running out of ideas…

What is the refresh time duration for Picture Entity Card ?
Is there a delay like wyze ?

Nice card you got there. Mind sharing the code for it? I have working scripts but no idea how to integrate them in the UI.

Same happened to me for the video. Although controlling the camera still worked. Without doing anything it started working again. One thought I had was that I may have had too many open HA tabs.