Can't attach static image from webcam to telegram using Dlink DCS-935L


I got lucky today at my local Staples and snagged two Dlink DCS-935L IP Cameras. I have them up and running, and I can see them in HA with a static image that is changed every 10 seconds using the generic MJPEG stream. I am now trying to add Telegram in, as one of the webcams I have in my porch and would like it to send a message/picture when my doorbell is pressed. I have the automation working, and can successfully send a text only notification with Telegram and syncs to my devices. But, when I try to add the photo, I get this error in my HA log:

16-09-10 19:35:23 homeassistant.core: BusHandler:Exception doing job
Traceback (most recent call last):
  File "/home/hass/.homeassistant/deps/telegram/", line 90, in __init__
    self.mimetype = InputFile.is_image(self.input_file_content)
  File "/home/hass/.homeassistant/deps/telegram/", line 170, in is_image
    raise TelegramError('Could not parse file content')
telegram.error.TelegramError: Could not parse file content

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/hass/lib/python3.5/site-packages/homeassistant/", line 852, in job_handler
  File "/srv/hass/lib/python3.5/site-packages/homeassistant/", line 717, in _execute_service
  File "/srv/hass/lib/python3.5/site-packages/homeassistant/", line 572, in __call__
  File "/srv/hass/lib/python3.5/site-packages/homeassistant/components/notify/", line 106, in notify_message
  File "/srv/hass/lib/python3.5/site-packages/homeassistant/components/notify/", line 102, in send_message
  File "/srv/hass/lib/python3.5/site-packages/homeassistant/components/notify/", line 126, in send_photo
    photo=photo, caption=caption)
  File "/home/hass/.homeassistant/deps/telegram/", line 121, in decorator
    result = func(self, *args, **kwargs)
  File "/home/hass/.homeassistant/deps/telegram/", line 147, in decorator
    result =, data, timeout=kwargs.get('timeout'))
  File "/home/hass/.homeassistant/deps/telegram/utils/", line 227, in post
    data = InputFile(data)
  File "/home/hass/.homeassistant/deps/telegram/", line 94, in __init__
    self.mimetype = mimetypes.guess_type(self.filename)[0] or DEFAULT_MIME_TYPE
  File "/usr/lib/python3.5/", line 289, in guess_type
    return _db.guess_type(url, strict)
  File "/usr/lib/python3.5/", line 114, in guess_type
    scheme, url = urllib.parse.splittype(url)
  File "/usr/lib/python3.5/urllib/", line 861, in splittype
    match = _typeprog.match(url)
TypeError: expected string or bytes-like object

This is my lines in automation.yaml

- alias: 'Back Door Notify'
      platform: state
      entity_id: binary_sensor.2_door_chime_sensor_2_1
      state: 'on'
    service: notify.webcam_telegram
      message: "Someone is at the back door!"
      title: "Home Assistant"
          - url:
            username: xxxxxx
            password: xxxxxx

Does anyone have any idea what I am doing wrong, or can’t I parse the URL to get the snapshot?


1 Like

Finally I’m able to help somebody! I made this yesterday. I doesn’t win any prizes, but it does the job. The next thing I want to do is create 5 pics, 1 second apart and telegram it. Should be easy with copy/paste but that not very elegant.

take_pic: curl -o /home/hass/snapshot.jpg -A cgi http://admin:[email protected]/image/jpeg.cgi


  • alias: ‘Test Telegram’
    • platform: state
      entity_id: input_boolean.test_telegram
      to: ‘on’
    • service: shell_command.take_pic
    • delay 00:00:10
    • service: notify.telegram
      title: Send
      message: Send Image
      - file: /home/hass/snapshot.jpg

Hi @jilsx

Thank you for your help. I was able to get it to work wonderfully with my camera. I ended up for ease of use placing the shell_command right into my configuration.yaml file for now, but it works. Telegram seems to be sending me the message about 10 minutes later for some reason though; i’ll have to look into that.

I was able to get the automation to work with with this:

- alias: 'Back Door'
      platform: state
      entity_id: binary_sensor.2_door_chime_sensor_2_1
      state: 'on'
    - service: shell_command.take_pic_porch
    - delay: 0:02
    - service: notify.webcam_telegram
        title: Home Assistant
        message: Someone is at the back door!
            - file: /home/hass/.homeassistant/snapshots/snapshot_porch.jpg
              caption: Back Porch Doorcam

Did you ever get your consecutive telegram’ed pictures working? I was thinking of doing the same thing and linking it to a motion sensor and automation rule.

1 Like

I’ve ended up with the following:

  • Send 1 pic via telegram
  • Send 10 pics (on second apart) via mail. I found this a little more elegant (to use my prior words). Probably can do it with Telegram and HASS alone, but I’m already spending way to much time figuring out how that would work. Still getting used to the syntax.

The shell command I’m using is:


month=$(date +"%m")
day=$(date +"%d")

hour=$(date +"%H")
minute=$(date +"%M")
second=$(date +"%S")


mkdir -p “$folder”

for num in {1…10}
curl -o $folder/$num.jpeg -A cgi http://admin:[email protected]/image/jpeg.cgi
sleep 1

mutt -s “Motion Detected” [email protected] -a $folder/*.jpeg < /tmp/mailmessage.txt

1 Like

Just an update. Still haven’t figured out why there is such a huge delay between when the doorbell is pressed and the picture is taken and when I get the message. One thing I did do though that seems to “speed” up the process a bit is I have my automation set to send me a text notification of someone at the door, and then a second one for the picture. The text one comes in instantly and the photo about a minute later.