Sonoff GK-200MP2-B IP Camera

If using rtsp, use this:

1 Like

Do we know if it’s possible to confgure this ip camera without the application?
Thanks

Hi all. I had my Sonoff GK-200MP2-B IP Camera working perfectly, with PTZ scripts set up in the same way as @Eeeeeediot displayed on 20 Jun and card layout Oct 20. Around 2 months ago, the PTZ’s stopped working. :frowning: not sure if it was a card layout change or something.
The camera still displays on the card as usual (be it with a 7 second delay) but as soon as I select any of the PTZ buttons (Left,Right,Up,Down) nothing happens.

I’ve run the scripts directly from the configuration scripts area and still, nothing happens. But something is happening…

The logbook says in this sequence:
CameraPTZ Left started by Mike
then…
CameraPTZ Left turned on by Mike
then around 15 seconds later…
CameraPTZ Left turned off by Mike

Nothing happens.

I’ve looked at my scripts in the UI and my device id is not in quotes… ‘123456’
It just shows
image

No matter if I enter quotes and save the script,
image

when I go back in to view the script, the device id is no longer in quotes and blue… its orange again.

So I went into my scripts.yaml and put the quotes in… ‘123456’
Saved it. Reloaded scripts and even restarted home assistant.
image

The script.yaml shows ‘123456’ still (in green). Great. But… The UI where it would show the service being called is now blank. WTH?

After hours of troubleshooting… I notice that if id do set my device id to ‘123456’ it keeps the quotes. However my device id begins with a Zero (0) and I’m inclined to think that, that has something to do with it. As soon as I enter my device id which is 0***** in quotes, it makes the quotes disappear. if I use any other number not beginning with a Zero, it keeps the quotes.

This is so frustrating/confusing. Any wiz that can help me understand what is going on, would be greatly appreciated.

Hi all. With very little sleep I return to let you know that I think I corrected the issue.
Had nothing to do with the leading Zero in my device id.

The horizontal stack of buttons, each called on an entity, for example: Left button Entity was script.cameraptz_left. Lower down, the tap action was set to call service, script.cameraptz_left as well.

I removed the entity as this is optional, from all the buttons and left the tap action to call the service. The buttons on the card appear to be working well again.
Not sure what caused this but glad it’s sorted.

What would be great now though, is if someone knew of a way to reduce the delay in the card.
I can confirm that as soon as I tap the button, and looking at the camera through eWeLink, the camera moves immediately after moving it. The card in HA though takes around 7 seconds to show the movement.

Anyways, hope my post helps anyone that encounters a similar issue to me.

Cheers

@MikeF9 I have ran into the exact same issue. PTZ buttons arent working :frowning: Feel like I’ve tried everything at this point. Created services through the UI, config.yaml and scripts.yaml. Nothing I do appears to work. I have also noticed my device id dropping to 123456 from ‘123456’.

Are you able to share you scripts & button code with me so I can give it a try?

Hi @apomper

So I’ve got my cameras finally working. They don’t always respond every time I try move them but a reboot of the camera seems to work.

Firstly, I’m using a Picture Elements Card Configuration which I had to setup with the code editor as the visual editor won’t allow it. The coding, for the one camera, is as follows:

type: picture-elements
camera_view: live
camera_image: camera.sonoff_main_camera
elements:
  - type: icon
    icon: 'mdi:arrow-left-drop-circle'
    tap_action:
      action: call-service
      service: script.main_camera_left
    style:
      bottom: 45%
      left: 5%
      color: white
      opacity: 0.5
      transform: 'scale(1.5, 1.5)'
  - type: icon
    icon: 'mdi:arrow-right-drop-circle'
    tap_action:
      action: call-service
      service: script.main_camera_right
    style:
      bottom: 45%
      right: 5%
      color: white
      opacity: 0.5
      transform: 'scale(1.5, 1.5)'
  - type: icon
    icon: 'mdi:arrow-up-drop-circle'
    tap_action:
      action: call-service
      service: script.main_camera_up
    style:
      top: 10%
      left: 46%
      color: white
      opacity: 0.5
      transform: 'scale(1.5, 1.5)'
  - type: icon
    icon: 'mdi:arrow-down-drop-circle'
    tap_action:
      action: call-service
      service: script.main_camera_down
    style:
      bottom: 10%
      left: 46%
      color: white
      opacity: 0.5
      transform: 'scale(1.5, 1.5)'
  - type: icon
    icon: 'mdi:arrow-expand-all'
    tap_action:
      action: more-info
    entity: camera.sonoff_main_camera
    style:
      top: 5%
      right: 5%
      color: white
      opacity: 0.5
      transform: 'scale(1.5, 1.5)'

My configuration.yaml file has the following:

camera:
  - platform: ffmpeg
    name: Sonoff Main Camera
    input: -rtsp_transport tcp -i rtsp://rtsp:[email protected]:554/av_stream/ch0

The scripts I have for the PTZ buttons are up, down, left and right. Example below…

main_camera_up:
  alias: Main Camera Up
  sequence:
  - service: sonoff.send_command
    data:
      device: *input your 6 digit camera number here including the ZERO if it's starts with a ZERO*
      cmd: up
  mode: single

To answer the issue with the dropping from ‘123456’ to 123456, I configured it in my scripts.yaml with the ’ and ’ and it also dropped it again, after saving the file and restarting HA, but itworks. In my visual editor of my script it looks like this.

image

The device number shows in a pinky red colour.

Let me know if you don’t come right.

And if anyone knows how to get rid of the, roughly, 7 second delay between pressing the up, down, left or right arrows, before you see the picture actually move, please share.

So the final product looks like this…

image

Thank you for the very detailed guide @MikeF9. I will give it a try shortly.
You can get rid of the delay by running WebRTC (also from AlexxIT). Link here

Edit.
I have used your exact script & button code and still nothing appears to work :frowning: Even with debug logging enabled for Sonoff & HA, no errors appear anywhere. Tried running the scripts directly from the scripts page also with no success.

My scripts.yaml has kept the ‘’ through restarts. The GUI version of the scripts has dropped the ‘’ but device ID is red just like yours.

service

I’m about to give up lol

Edit2:
Fire up my test VM and set everything up the same there. And, IT WORKED!. So it looks like I have something causing issues on my main HA server :frowning: At least I know where to troubleshoot now.
Thank you very much for your help.

Great to hear, and not so great that you can’t get it to work on your production server.

Hope you figure it out.

Question, are you using the picture elements card now? Are you not using the WebRTC card with PTZ?
I’m playing around with it and it’s working, just would prefer the PTZ buttons on the WebRTC card to display the same way as they do on the Picture Elements Card

Hi @MikeF9. Your setup made me interested in this camera. Also saw your comment on the WebRTC thread. A few questions before I order this:

  1. Were you able to expose the motion detection binary sensor entity of the camera to HA?
  2. Have you tried adding the camera to HA using the ONVIF integration? (I have another camera and the motion detection binary sensor was automatically exposed to HA using the ONVIF integration; PT (not Z) controls are also managed using the integration.
  3. Using the WebRTC custom card, do you get audio as well from the camera on HA?
  4. Can you please share your WebRTC custom card config with the PTZ controls?

Hi there

As of yet I haven’t been able to expose the motion sensor to HA. It would be great it we could because then I’ d setup a script to record and forward myself the video via my Telegram Bot.

I haven’t used the ONVIF Integration. Please let me know if you’ve tried and if it worked.

The WebRTC card allows one way audio for now, I did mention it on @AlexxIT WebRTC forum. Realtime camera streaming without any delay - WebRTC, that it would be great to have two way audio.

If you go to the link above, @AlexxIT has all the details you need to set the card up.

My card looks as follows:

type: 'custom:webrtc-camera'
url: 'rtsp://rtsp:[email protected]:554/av_stream/ch0'
intersection: 0.75
ui: true
webrtc: true
ptz:
  opacity: 0.8
  service: sonoff.send_command
  data_left:
    device: "Your cameras 6 digit Unique Number"
    cmd: left
  data_right:
    device: "Your cameras 6 digit Unique Number"
    cmd: right
  data_up:
    device: "Your cameras 6 digit Unique Number"
    cmd: up
  data_down:
    device: "Your cameras 6 digit Unique Number"
    cmd: down

Hope this helps

Thanks, @MikeF9. I just ordered the camera on Ali and it will arrive first week of June. Been researching on how to expose the camera’s motion sensor to HA and found this:

Have you tried this? Looks like a possible solution with no risk of bricking the camera.

Same problem here, any luck directly connecting it to motioneye?

I did, yes. From memory it was something to do with the trailing slash - also it didn’t show up a preview straight away. So leave it a few minutes when you change something to check if it actually works.

Hi Mike,
my I bother you with a quick question?
I followed the setup that you described, using @alexxIT 's awesome integration as seen on github.
When I click on the control buttons in the card, I get Failed to call service sonoff/send_command. Service not found.
I assume I need to define the sonoff/send_command somewhere?
Thoughts ?
thanks,
chrisV

Hi Chris

Are you referring to the WebRTC integration or just using the picture element card?

I no longer use the picture element card and am using @AlexxIT ’s WebRTC HASS integration.

Hi @MikeF9
yes, I am using AlexxIT’s WebRTC HASS integration as well.
The reaction of the camera is a lot better.
The Picture Element Card has too long delays on my camera (close to 10 seconds)

So, the video part of the WebRTC HASS integration works, but I can’t get the controls to work (see screenshot below)

Do I need to install a separate service that you know of?
thank you
chrisV

BTW, this is how my scripts.yaml looks like
(and it is “included” in configuration.yaml")

left:
  sequence:
    - service: sonoff.send_command
      data:
        device: 'my 6 digit device id'  # use quotes, this is important
        cmd: left

right:
  sequence:
    - service: sonoff.send_command
      data:
        device: 'my 6 digit device id'  # use quotes, this is important
        cmd: right

up:
  sequence:
    - service: sonoff.send_command
      data:
        device: 'my 6 digit device id'  # use quotes, this is important
        cmd: up

down:
  sequence:
    - service: sonoff.send_command
      data:
        device: 'my 6 digit device id'  # use quotes, this is important
        cmd: down

You have installed the Sonoff LAN integration from @AlexxIT hey?

The sonoff.send_command is a service that’s built into that integration on HACS

ah… I need to install that one as well?
No I haven’t… I thought that was for something else
thanks !
I will take a look at it
chrisV

yes, that was it !
It was not clear to me that you need to install 2 HACS repos from AlexxIT’s store. (webRTC Camera and Sonoff Lan)

It all works beautifully now
1AM… time to bed
chrisV