Customized Meteogram

I’m rather fond of meteograms, as they provide lots of meteorological data in a compact form. The Lovelace UI provides already a weather forecast card. I found two additional ways to include externally generated live visualizations in HA:

  1. Pre-formated png file tailored for your region, like https://www.yr.no/place/Germany/Berlin/Dahlem/avansert_meteogram.png. For a simple version omit the advanced_. The forecast period is always 48 hours. This service of the Norwegian Meteorogical Institute comes for free, it may not cover all regions of interest.

  1. Fully editable layout and content: https://api.meteograms.com/ This web-service complies an individual meteogram according to your specification including image height and width on the fly. It allows me to exactly fit it into my HADasbboard layout. Furthermore, it lets you choose between different data providers around the world, in my case DWD.

To get started with the API, call the website and play around with the “Options Editor”, and see the result in the “Live Preview” for free.

To get serious, you need to subscribe to a starter plan, and you have to provide a credit card. This starter subscription is basically stateless, it comes without “User login”. You rather have to remember your credentials, e.g. by clicking “Save Settings” and store the URL provided. This is your entry point to future editor access.

The Live Preview offers a direct URL. It starts with https://nodeserver.cloud3squared.com/getMeteogram… followed by your secret API-token. The parameter list is very long, as it contains all editor settings. Use this URL in your picture entity card or camera/iframe visualization.

8 Likes

Thanks for the overview of options. After dwelling into Meteogram, I can just confirm that it’s extremely powerful. It can be configured to show exactly what one needs.

I’d like to add how to practically get it into Home Assistant:

Add the following to configuration.yaml

camera:
  - platform: generic
    name: Meteogram
    # Configuration page in Meteogram: https://api.meteograms.com/?hashkey=[your unique ID]
    still_image_url: https://nodeserver.cloud3squared.com/getMeteogramX/[your uniqueID from Meteogram]

And then add a Lovelace Camera card

  - type: picture-entity
    entity: camera.meteogram
    show_name: false
    show_state: false

However, I have a question: After my first month of using Meteogram, I was charged for 5000 API requests. While it’s only 5 £, it’s still annoying. 500 requests are free per month, i.e. an update every second hour. That should be enough for my (and most peoples) need, but I can’t figure out how to change the update rate. It might be the parameter scan_interval: 5200, but from reading the forum, I have doubt that it will work. Any ideas?

I use a camera widget in HADashboard with “refresh: 3600”, i.e. update every hour.

For Lovelace I propose using a local JPG file as an intermediary:

  • Trigger an automation with a service call “camera.snapshot” every hour, reading your URL and writing the JPG to file.
  • Create a camera under the “platform: local_file” to display the JPG.
  • Use a picture-entity card with your camera. It follows the file updates.

Check your API Consumption by calling https://tokens.cloud3squared.com/retrieveUpcoming/

1 Like

Hi, did you manage the charging issue?

I completely missed that @heinrich had responed with a suggested solution. It took me some time to figure out how to put his advice into practice.
What I did:

Step 0: Already had Meteogram setup as a camera.

Step 1: Allow HA to write to /tmp by adding the following to configuration.yaml:

homeassistant:
    allowlist_external_dirs:
    - /tmp

Further reading: https://www.home-assistant.io/docs/configuration/basic/

Step 2: Add an automation to capture the Meteogram camera.

alias: Meteogram update
description: ''
trigger:
  - platform: time_pattern
    hours: '*'
    minutes: '0'
    seconds: '0'
condition: []
action:
  - service: camera.snapshot
    data:
    filename: '/tmp/snapshot_meteogram.jpg'
    entity_id: camera.meteogram
mode: single

Step 3: Create a new camera that reads from the file
configuration.yaml

camera:
  - platform: local_file
    file_path: '/tmp/snapshot_meteogram.jpg'

Further reading: https://www.home-assistant.io/integrations/local_file/

Step 4: Execute the automation created (so that a snapshot is made)

Step 5: Setup Lovelace to read from the Meteogram Snapshot with a picture entity card

However, I’m currently stuck with no local file being produced (I checked using SSH). Need to troubleshoot this further. I can already now conclude that this is a cumbersome workaround.

2 Likes

This worked for me:

- service: camera.snapshot
    data:
      entity_id: camera.camXX
      filename: /config/www/meteogram.jpg

- platform: local_file
    name: show_meteogram
    file_path: '/config/www/meteogram.jpg'

You may have to create the folder “www” beforehand and restart HA. details here

It was a year since I last posted here, and since then I’ve been thinking how to make the setup simple yet efficient. I now have a setup I’m happy with and thought I would share it, so more people can benefit from the excellent Meteograms.
No file management is needed, no automation setup needed, just an addition to configuration.yaml, yet it’s possible to control how often the Meteogram is updated (keeping within the free quota). The secret sause to this is to make some acrobatics with the template URL.

Add the following to configuration.yaml

camera:
  - platform: generic
    # Admin: https://api.meteograms.com/?hashkey=XXXXXXX
    name: Meteogram
    still_image_url: '{{ "https://meteogram.cloud3squared.com/getMeteogram?hashkey=XXXXXX"+ "&" + (((now().hour*60 + now().minute)/90)|round(0,"floor")|string) }}' 
    #The number before round (90) states number of minutes between refetch
    limit_refetch_to_url_change: true

The free plan for Meteograms includes 1500 units, and with my configuration of the Meteogram, each time Home assistant fetches an update, 3 units are consumed (since my Meteogram uses data from multiple sources).

To calculate how often I can update the Meteogram without exceeding the free quota, I’ve used this formula:
44640 (number of minutes per month) / 1500 (free quota) * 3 (number of units per update) = 89

Hope this helps someone!

1 Like

Update: With the release of HA 2022.04, the configuration in my previous post is deprecated. Instead, you should set it up via the UI:

  1. Configuration->Integrations-> Add integration
  2. Generic camera
  3. Configure the generic camera
    1. Still image URL:
      {{ "https://meteogram.cloud3squared.com/getMeteogram?hashkey=XXXXX"+ "&" + (((now().hour*60 + now().minute)/90)|round(0,"floor")|string) }}
    2. Authentication: basic
    3. Frame rate: Leave as default (has no impact)
    4. Tick "Limit refetch to url change: "
    5. Other settings can be left empty
  4. Submit
5 Likes