nathan-gs / ha-map-card

A Map Card for Home Assistant
https://community.home-assistant.io/t/map-card-a-slightly-improved-map-card/693088
MIT License
30 stars 9 forks source link

History for WMS & TileLayers #56

Closed thybag closed 3 months ago

thybag commented 3 months ago

Allows WMS/Tile layers to have their time/date driven by the date picker or an external entity as with entity history.

Simple example with WMS driven by date_section date range picker

type: custom:map-card
history_date_selection: true
entities:
  - zone.home
wms:
  - url: https://geo.irceline.be/rioifdm/wms
    history: time
    options:
      layers: pm25_hmean
      transparent: true
      format: image/png
      opacity: 0.7
      tiled: true
      attribution: <a href="https://www.irceline.be/">IRCELINE</a>

More advanced example with tile_layer

type: custom:map-card
history_date_selection: false
entities:
  - zone.home
tile_layers:
  url: >-
    https://wmts.marine.copernicus.eu/teroWmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=&LAYER={layer}&STYLE=&FORMAT=image/png&TILEMATRIXSET={tileMatrixSet}&TILEMATRIX={z}&time={time}&TILEROW={y}&TILECOL={x}
  history:
    property: time
    source: input_number.test_number_value
    suffix: months ago
  options:
    layer: >-
      GLOBAL_MULTIYEAR_WAV_001_032/cmems_mod_glo_wav_my_0.2deg_PT3H-i_202311/VHM0
    tileMatrixSet: EPSG:4326
    noWrap: true

Work todo

Fixes https://github.com/nathan-gs/ha-map-card/issues/44

thybag commented 3 months ago

Hi @nathan-gs, I think this should now be good to review. Unsure if the CI issues are anything i need to take note of / address as part of this PR.

The WMS/Layer history feature should support everything the map and entity level ones do, with the addition of needing to set the attribute being used as this could be time/date or something else in theory, as well as a flag to force midnight on dates (days ago uses current time for example so won't work correctly with some WMS/Tile layers if using that to drive them).

I've also now allowed single WMS/Tile layers to be set, rather than them needing to be a lits.

Readme should be updated, so hopefully the added docs all make sense.

Cheers, Carl

nathan-gs commented 3 months ago

@thybag not sure why the HACS validation flow keep running, would you mind testing (it's hard to test for me)

nathan-gs commented 3 months ago

If you pull from main, normally the test failures should disappear.

thybag commented 3 months ago

Looks like that sorted it 👍

nathan-gs commented 3 months ago

Thank you @thybag for this very cool addition, available in v1.2.0