Camera snapshots updated

A really quick one today to update my post about camera snapshot notifications in Home Assistant.

In that post I showed the shell command you could use to take a snapshot from any camera visible to Home Assistant. In the very next release, that functionality was added to the camera component so that you can call a service directly from within Home Assistant.

Instead of using a shell command:

  - service: shell_command.take_snapshot
      url: 'http://localhost:8123{{ }}'
      filename: '/tmp/snapshot.jpg'

You can now simply write:

  - service: camera.snapshot
      entity_id: camera.mjpeg_camera
      filename: "/tmp/snapshot.jpg"

And of course you no longer need the shell command defined.

There is one other thing you need to do to configure it. You need to add the path to the whitelist of directories to which Home Assistant can write. This goes into your configuration.yaml under the homeassistant section:

    - /tmp

I think this is a great change – it just feels cleaner to do it all directly within Home Assistant.

As it’s now a service, it’s also easy to test from the front end using the service call under developer tools:

There is another change in 0.57 that turned out to be a breaking change for my method of showing the snapshot and then hiding it when the notification is dismissed.

Instead of the state of a persistent notification being the full notification text, it is now set to “notifying” and the message and title are available as attributes. That means that instead of the notification dismissal trigger from my example being:

    platform: state
    entity_id: persistent_notification.doorbell
    from: "Doorbell rung"

It should be:

    platform: state
    entity_id: persistent_notification.doorbell
    from: "notifying"

I like this change as well. I wasn’t really happy with hard coding the text of the notification in the trigger as it forced you to change the trigger if you changed the text of the notification to keep it in sync with the notification. Again, I think the new way is much cleaner and satisfies the DRY principle.

I’ve edited the original blog post to reflect this change but I thought it was worth another quick post about the changes. They’re both changes for the better and highlight how quickly Home Assistant is evolving.

It’s always worth keeping an eye on the changelog for updates – not only are new platforms added with every release, the core functionality of the existing components keeps growing as well.

in Home Automation


  1. JoJo 12th September 2018
  2. seanbAuthor 12th September 2018

Add a Comment

Your email address will not be published. All comments will be reviewed.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Posts