Hikvision Still Image - Telegram

Yeah, i agree with this. As i test i hit the trigger button maybe 20 times in rapid succession, each notification came through successfully.

I am going to try remove the delay on the sensor and shift the delay onto the automation.

Trying all the automations with your recommended settings and i get the below errors.

Line Crossing 2 Automation:

Log Details (ERROR)
Sun Dec 22 2019 10:49:03 GMT+0200 (South Africa Standard Time)
Error sending file: Image_process_failed. Args: (Telegram Group ID, <_io.BufferedReader name='/share/security/studyCam/studycam_2019_12_22_10_49.jpg'>), kwargs: {'caption': 'Motion Detected', 'parse_mode': 'Markdown', 'disable_notification': False, 'disable_web_page_preview': None, 'reply_to_message_id': None, 'reply_markup': None, 'timeout': None}

Log Details (ERROR)
Sun Dec 22 2019 14:38:19 GMT+0200 (South Africa Standard Time)
Error sending file: Image_process_failed. Args: (Telegram Group ID, <_io.BufferedReader name='/share/security/studyCam/studycam_2019_12_22_14_38.jpg'>), kwargs: {'caption': 'Motion Detected', 'parse_mode': 'Markdown', 'disable_notification': False, 'disable_web_page_preview': None, 'reply_to_message_id': None, 'reply_markup': None, 'timeout': None}


Line Crossing 3 Automation:

Sun Dec 22 2019 21:34:16 GMT+0200 (South Africa Standard Time)
Can't send file with kwargs: {'message': 'Motion Detected', 'caption': 'Motion Detected', 'url': 'http://user:[email protected]/ISAPI/Streaming/channels/101/picture'}

Can I ask a silly question
Why do you have it in node red as well.

OH! This is actually an excellent question, because it could be the cause for the sporadic messages.

Your bot can’t be accessed by 2 different methods like this. I had issues when trying to use 2 different node-red telegram bot implementations (telegram and chat-bot). The errors indicated that one of them couldn’t login because it was already logged in.

I didn’t even notice this earlier in the thread. Good catch.

disconnect one of the bot notifications (HA or Node Red) and try again.

I know it wasn’t a silly question
i was trying to be as polite as possible

sometimes the answer is right in front of you
and i still can’t see it

I added it to NodeRed when the HA automation stopped working. During testing i make sure to remove the Telegram integrations on the one or the other that i wasn’t testing at the time.

If both run at the same time the HA logs fill up with the below error.

ERROR (updater) [telegram.ext.updater] Error while getting Updates: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running (409)

I am losing steam trying to resolve this issue. It all worked flawlessly for over a month and now nothing.

Can i suggest something
break it up into 2 parts

  1. use the downloader to download the snapshot to the local file
  2. send the file to telegram

Giving this a shot now. I will just let the automation run for a day downloading the file to the directory, if that works fine i will then tie it into Telegram. Thanks for the suggestion.

Let me know how you go
I may want to pinch your code for the telegram.
Once i get the person detection implemented. I have too many trees blowing in the wind to use motion detect as a reliable trigger

It seems like my issue is 95% the camera’s fault.

I get the below 503 when using the downloader.

downloading 'http://user:[email protected]/ISAPI/Streaming/channels/101/picture' failed, status_code=503

So i will tinker around with the camera a bit more. Thanks for all the suggestions.

Stick the url in the browser to do your testing from there
I’ve got a HIK in my van I can always test one

I cannot use this on one of my cameras (that has the latest firmware for it), but it works fine on revisions below that
This, however, works fine no matter what firmware the camera is on.
http://hass:[email protected]/Streaming/channels/1/picture

I know I mentioned it before, but it seems like it was glossed over.

I was thinking the 101 was a bit peculiar
Usually it’s just 1 or 2 for main stream or substream

Sorry, i did not ignore your previous comment, i just forgot to reply to it.
Te URL is correct for accessing the Hikvision camera, it works, but it just prompts for credentials.
If i use your method in the URL i get a 401 response.

And Merry Christmas from sunny South Africa. :smiley:

I know. I do too. What I’m saying is that if I use a different URL, the one I provided, it works.

The more i dig into this problem, the more I feel that it is a bug with this combination of automation and camera.

I have the below config setup for the camera after a factory reset:

camera:
    - platform: generic
      name: Study Camera
      stream_source: "rtsp://admin:[email protected]:554/Streaming/Channels/102"
      still_image_url: http://10.0.0.21/ISAPI/Streaming/channels/101/picture
      username: admin
      password: pass

For stream_source i need to specify the user and password in the URL or the stream fails, there are many topic regarding this on the forum.

For the still image, i can rely on the Username and Password config variables to handle the authentication. I am then successfully able to add the still image onto lovelace with the below config:

      - type: picture-entity
        entity: camera.study_camera
        aspect_ratio: 50%

The image successfully updates every 10 seconds.
However, when attempting either of my automations above, they fail around 95% of the time motion is detected. Yet as before, they are 100% successful if i manually trigger them.

I am currently using the below automation and have had 100% success so far (5 out of 5 triggers sent successfully)

  - entity_id: binary_sensor.study_camera_line_crossing
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - data:
      data:
        photo:
        - password: pass
          url: http://10.0.0.21/ISAPI/Streaming/channels/101/picture
          username: admin
      message: Message
      title: Motion Detection
    service: notify.telegram_notifications

The only change i have done is move the username and password from the URL into their own config variable. I will report back after a few days to confirm all is working.

1 Like

Hi, how is it running now?
Just asking cause im struggeling with same issues like u and dont have a solution yet :frowning:
State change is reported but no message is send to telegram :frowning:
Edit what I figgured out now is that if I just send a textmessage everything is working.
So the error happens with getting the picture of the camera.
Could it be that the camera is so bussy with recording and detection that it needs too long to provide the picture? is it possible to define a timeout fot getting it maybe?

Hi Tom,
It has been rock solid for quite some time now.
My issue back in December, I am almost 100% sure, was resolved by a factory reset of the camera.
I have since switched my automations over to NodeRed, but previously it was working fine using Home Assistant only.
If you are in a position for completely factory reset the camera, i would say give that a shot first before messing around constantly with Home Assistant.

It hat definitive to do with the camera. I just added the link from a reolink camera and everything was was working. I just set up the camera so i will test if reseting it helps.