/ha_ll_notify

Lovelace notification / alert component for Home Assistant

Primary LanguageCSSMIT LicenseMIT

Lovelace Notify (ll_notify)

ll_notify is a Home Assistant component that allows you to easily add notifications and alerts to a Lovelace dashboard.

screen recording

Install

Install manually

Note - be sure to clone it into a directory named "ll_notify"!

cd config/custom_components
git clone git@github.com:rr326/ha_ll_notify.git ll_notify

# Double-check
if [[  -d 'll_notify' ]]; then echo "Success" ; else echo "Error! Make sure the directory is called 'll_notify'" ; fi

Install with HACS

  1. Open HACS.
  2. Click "Integrations".
  3. Click on the 3 dots in the top right corner.
  4. Select "Custom repositories".
  5. Paste https://github.com/rr326/ha_ll_notify into the "Repository" field.
  6. Select Integration from the "Category" field.
  7. Click the "Add" button.
  8. Click the "+ Explore & download repositories".
  9. Search for "Lovelace Notify".
  10. Click the "Download this repository to HACS" button.

Configure

# config/configuration.yaml

ll_notify:  # required
  defaults: # optional
    notifier:
      position: bottom-right

After installing and configuring, restart Home Assistant.

Defaults - Full list of defaults here.

Test

In your Home Assistant Dashboard, go to Developer Tools > Services. Under services, select "ll_notify.success". Click "Fill Example Data" from the box below. Then click the "Call Service" button. If a notification appears on the screen, you are set.

If not, in your dashboard open your browser developer tools window. At the top of the window you should see something like, 'll_notify: Successfully loaded.' If not, make sure you installed it properly. Check your HA logs. Or file an issue here.

Example - Using in a Dashboard

# In a dashboard

# Simple
  - type: button
    name: Success
    tap_action:
        action: call-service
        service: ll_notify.success
        service_data:
            message: "Test success"
            wait: 2

# Complicated - with "callbacks"
  - type: button
    name: Success w/ callbacks
    tap_action:
        action: call-service
        service: ll_notify.success
        service_data:
            message: "Success w/ callbacks"
            wait: 1
            after_close:
                - action: call_service
                domain: ll_notify
                service: ping
                service_data:
                    field1: val1
                - action: fire_event
                event_name: fake_event
                event_data:
                    field1: val1
                - action: js_fire_event
                event_name: fake_js_event
                event_data:
                    field1: val1

Services

ll_notify exposes several services and you can trigger notifications wherever you like.

  • ll_notify.success
  • ll_notify.error
  • ll_notify.warning
  • ll_notify.dismiss_all

These are very simple to use, as documented above. (dismiss_all requires no service_data.)

Advanced

  • ll_notify.message
  • ll_notify.notify
  • ll_notify.alert
  • ll_notify.confirm

These are just a bit more complicated. See Actions below, and read about the parameters on the AlertifyJS website. ll_notify will simply pass through service_data to Alertify.

Actions / "callbacks"

Alertify uses callbacks after a notification is dismissed, or after a confirm dialog is accepted or rejected. ll_notify instead implements 3 types of actions:

  1. call_service - Call a Home Assistant service
  2. fire_event - Fire a HomeAssistant event
  3. js_fire_event - Fire a Javascript event, solely in the browser.

You can trigger one action, or multiple actions. See the example dashboard above.

Missing Alertify features

Every AlertifyJS feature has not been implemented.

Alertify's notifications are implemented fully and are quite easy to use.

Aleritify's alerts and confirm dialogs are also implemented. You can set all the properties by sending key:value pairs in service_data, but most of the methods are not implemented.

Alertify's prompt is not implemented at all.

AppDaemon

If you used AppDaemon, check out my AdPlus helper functions. It makes adding a lovelace notification easy:

self.ll_error('Whoops - your alarm failed to turn on. Better check it out!')