Export cards to png/jpeg

Is there a way to export a card to png/jpeg ?

Example use is notifictions to phones ( signal messager, telegram etc ) so a well as text, a plot can be sent as well.

There is no way to do this at the moment.

Don’t forget to vote for your own request.

1 Like

Another use case is showing the card on the Android home screen using the camera widget. We no longer have WebView widgets but this will be close enough.

This would also be cool to use in an email notification or push message.

1 Like

another use case could be displaying it on esphome device if there was an option to schedule the export (i.e. autosave at specified intervals)

1 Like

I imagine the best way to do this would be with a snapshot service call to export the required image. You could easily automate this with a time trigger if you want it done automatically rather than on demand when sending a notification.

Not sure how feasible this request is but it would be really handy.

1 Like

At the moment it requires an additional container to get this functionality. Having this internally in home-assistant would simplify things for me a lot. I use screenshots in morning agenda notifications and e-ink Homeplate dashboard.

1 Like

would you be able to provide more info on your setup how you take that screenshot?

Sure, I followed this project
https://community.home-assistant.io/t/homeplate-e-ink-dashboard-with-inkplate-10
Basically, the only part you’ll need is that container

It will create a snapshot of any dashboard’s tab, you’ll point it to. They you can just send it using preferred notification service, supporting URL Links to png images (e.g. telegram).

Exporting cards to PNG or JPEG sounds like a handy feature, especially for messaging apps. I remember needing to send plots and charts through messages too. One thing that helped was using JPG compress to keep the file sizes manageable without sacrificing quality. It’s like finding the perfect fit for your digital messages.

1 Like

card to image or card to virtual camera would be very powerful for notifications.

  • display meter/graph info in PIP apps on Apple TV or Android TV
  • Enrich mobile phone notifications
  • Maybe allow external embedding of an periodically updated image in an external website / embed

There are quite a few ways this could be used.

1 Like

This would be a very handy feature. We have a weather station at a remote location that leverages homeassisstant and uses esphome as a weather sensor for windspeed, temperature, rainfall measurements. We’d like to provide a snapshot of the windrose card at regular intervals, sent to another server. This limits our bandwidth usage at the remote location, which needs LTE (ie. expensive internet)
.

If your bandwidth is limited and expensive you would be better off sending text data than an image. Then generate the graphs from this data.

I have created a very hacky way to achieve what I needed.

  • Created a cli tool, in golang, that uses playwright-go to webscrape home assistant
Connect to Home Assistant and take a screenshot by CSS selector

Usage:
  bin/ha_ss [options]

Options:
  -css string
    	Home assistant CSS selector
  -headless
    	Headless mode (default true)
  -password string
    	Home assistant password
  -path string
    	Output screenshot path (default "output.png")
  -restport int
    	If set, startup REST server at given port
  -url string
    	Home assistant page URL
  -username string
    	Home assistant username

Environment variables:
  $HEADLESS - Headless mode
  $HA_CSS - Home assistant CSS selector
  $HA_PATH - Output screenshot path
  $HA_USERNAME - Home assistant username
  $HA_PASSWORD - Home assistant password
  $HA_RESTPORT - If set, startup REST server at given port
  $HA_URL - Home assistant page URL
  • Created a basic addon that runs the above in home assistant as a REST server addon

I then create in configuration.yaml a REST command :

rest_command:
  screenshot:
    url: http://localhost:3500
    method: post
    headers:
      accept: "application/json, text/html"
    payload: '{"url": "{{ url }}", "css": "{{ css }}", "filename": "{{ filename }}"}'
    content_type:  'application/json; charset=utf-8'
    timeout: 120

This enables automations to take a screenshot and attach to a notification

alias: Car - next green time to charge
description: ""
triggers:
  - entity_id:
      - binary_sensor.octopus_energy_a_xxxxxxx_greenness_forecast_highlighted
    attribute: next_start
    trigger: state
conditions: []
actions:
  - action: rest_command.screenshot
    data:
      url: http://homeassistant.local:8123/lovelace/overview
      css: >-
        div.card:nth-child(4) > hui-card:nth-child(1) >
        octopus-energy-greenness-forecast-card:nth-child(1)
      filename: greenness-forecast.png
  - action: notify.gaselectricity
    data:
      message: >-
        Next octopus greenness forcast is {{
        state_attr('binary_sensor.octopus_energy_a_xxxxxxx_greenness_forecast_highlighted',
        'next_start')|as_local()|as_timestamp()|timestamp_custom('%a %b %-d,
        %I:%M %p') }} to {{
        state_attr('binary_sensor.octopus_energy_a_xxxxxxx_greenness_forecast_highlighted',
        'next_end')|as_local()|as_timestamp()|timestamp_custom('%a %b %-d, %I:%M
        %p') }} - see https://octopus.energy/smart/greener-days
      data:
        attachments:
          - /config/screenshots/greenness-forecast.png
mode: single

( notify.gaselectricity sends a message to a signal group )

It would be great to progress this, eg move to an integration and provide a service call instead of REST … I’ve yet to look at how to do this myself.

What I have so far is here GitHub - plord12/webscrapers: Private set of webscrapers for various tasks … at least needs more docs.