Html5 push notifications with image

Thnx for script! Where do you exactly specify the dir of the Dahua snapshot with HA api?

This is not script. It is from HA automation.
use in automation.yaml or configuration.yaml(if yaml files not seperated)

1 Like

@tmjpugh can u share exemple how can use timestamp?

Honestly I never figured out correct format.

I did recently find correct format but forgot to test
https://docs.python.org/3/library/time.html#time.strftime

Try something like below

- alias: 'Notify Gate Closed'
  trigger:
    - platform: state
      entity_id: binary_sensor.entry_gate
      from: 'on'
      to: 'off'
  action:
    - service: notify.notify
      data:
        title: 'GATE'
        message: 'Closed'
        data:
          tag: alert
          url: 'https://my_HAserver.com'
          image: "https://my_HAserver.com/api/camera_proxy/camera.mycamera?api_password=MyHAPassword"
          vibrate:
            - 300
            - 100
            - 400
          renotify: 0
          timestamp: '%m%d%H%M%S'

I think you should get output like 12/27 13:15:00 in this case for example. I will test and post a working example

%d	Day of the month as a decimal number [01,31].	 
%H	Hour (24-hour clock) as a decimal number [00,23].	 
%I	Hour (12-hour clock) as a decimal number [01,12].	 
%j	Day of the year as a decimal number [001,366].	 
%m	Month as a decimal number [01,12].	 
%M	Minute as a decimal number [00,59].	 
%p	Locale’s equivalent of either AM or PM.
%S	Second as a decimal number [00,61].

More example at link above

@tmjpugh ohhhh sorry. But i use hass.io and i cant use your fix “htmlv2”
inside log it say:

2017-12-27 18:50:31 ERROR (SyncWorker_14) [homeassistant.util.package] Unable to install package pywebpush==1.1.0: Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-p9_btscv/cryptography/setup.py';f=getattr(tokenize, 'open', open)(_file_);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, _file_, 'exec'))" install --record /tmp/pip-woppokek-record/install-record.txt --single-version-externally-managed --prefix  --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-p9_btscv/cryptography/
2017-12-27 18:50:31 ERROR (MainThread) [homeassistant.setup] Not initializing notify.html5v2 because could not install dependency pywebpush==1.1.0
2017-12-27 18:50:31 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform notify.html5v2: Could not install all requirements.
2017-12-27 18:50:31 ERROR (MainThread) [homeassistant.components.notify] Unknown notification service specified

HTML5v2 no longer needed
This was fix somewhere around 0.57

Just use normal component. No need for custom component

I’m still not able to pull a screenshot from my IP camera. HA does save a jpg in the local folder but it doesn’t attach the picture.

This is my automation.yaml:

- alias: Pic Notification
  initial_state: 'on'
  hide_entity: True
  trigger:
  - platform: state
    entity_id: binary_sensor.door_window_sensor_158d00332db7b2
    from: 'off'
    to: 'on'
  action:
    - service: camera.snapshot
      data_template:
        entity_id: camera.dahua_ipc
        filename: "/config/www/snapshots/camera.dahua_ipc.jpg"
    - service: notify.html5
      data:
        title: 'TEST'
        message: 'There is someone at the door'
        data:
          tag: alert
          image: "https://ipaddres:8123/local/snapshots/camera.dahua_ipc.jpg"

You must be able to access image directly from web(internet not local) from provided link.
If password is used for HA you must include that in url as shown in example

1 Like

@goprojojo did you solve your problem? and did you use hass.io?

@tmjpugh

i tried this:

- service: notify.html5
      data:
        title: 'TEST'
        message: 'teste'
        data:
          tag: alert
          image: "http://weknowyourdreams.com/images/cobra/cobra-13.jpg" 

but not Works… i receive the notify but the image not shows. but i use hass io

Your image is http
https may be required but not sure

Which browser you try?

1 Like

I am tried with chrome on my cell android and my pc.
I receive the notification but not image. I use hass.io

My guess is problem is image being used.
I will find example image so you may test

Also FYI
Timestamp field currently not working.
Current work around is add timestamp in the message field as below

- data:
    message: '{{ as_timestamp(now()) | timestamp_custom(''%H:%M'', true) }} - Covers are 
              going to be closed.'
  service: notify.my_notifier

Refer to link below for details on timestamp

Guys, is it possible to expand notification to see full image? My image is cropped vertically inside of notification. I tried to pull with 2 fingers, but no success. When i click on the notification it’s just gone.

No sorry, still looking for a proper script to pull image from my hikvision or dahua cameras. Hope someone has the same setup and can share the script?

1 Like

Having issue with notification image, do I still need html5.py and change this in py?

HTML5_SHOWNOTIFICATION_PARAMETERS = (
    'actions', 'badge', 'body', 'dir', 'icon', 'image', 'lang', 'renotify',
    'requireInteraction', 'tag', 'timestamp', 'vibrate')

I have the same problem, why image is not supported?

1 Like

no need to change html5.py
the following notification extract, sends a snapshot from my www(local) folder

  - service: notify.html5_juan_samsung_phone
    data:
      title: "Magda has arrived"
      message: "Magda is here."
      data:
        tag: alert
        image: "https://myserverip/local/travel_time/street_view_magda_gps.jpg"

When I try to send a RTSP image it doesn’t work now, there is some reason?

{
    "title": "!!! ALLARME COLLINA !!!",
    "message": "Allarme attivato, tra 2 minuti partono le chiamate.",
    "data": {
        "data": [
            {
                "image": "https://sulparo.duckdns.org:8123/api/camera_proxy/camera.cam_0_rtsp?api_password=*******"
            }
        ],
        "actions": [
            {
                "action": "Disabilita",
                "title": "Disabilita Allarme"
            }
        ]
    }
}

Do you have api_password enabled?

Does image open in web browser? If work in browser should be OK