Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable opacity based on time from history_end #73

Open
mpipeling opened this issue Jun 29, 2024 · 5 comments · Fixed by #79
Open

Variable opacity based on time from history_end #73

mpipeling opened this issue Jun 29, 2024 · 5 comments · Fixed by #79
Labels
enhancement New feature or request

Comments

@mpipeling
Copy link

Native HA map card plots points & connecting lines in history with increasing opacity over time [inversely] such that more recent points/path are darker (see below)

I can't find a way to (dynamically) adjust the opacity in ha-map-card [can use a fixed opacity for the entire path with history_line_color: rgba(255,0,255,0.6), for example]

Appears native HA map card creates "gradualOpacity" variable based on "pointIndex" & "opacityStep"

Is it possible to have this functionality in ha-map-card?

[NATIVE]
image
vs.
[HA-MAP-CARD]
image

@nathan-gs nathan-gs added the enhancement New feature or request label Jul 4, 2024
nathan-gs pushed a commit that referenced this issue Sep 2, 2024
* Add a variable 'gradualOpacity' to handle Opacity over time, solving #73
@nathan-gs
Copy link
Owner

Fixed in v1.5.0

@nathan-gs nathan-gs linked a pull request Sep 3, 2024 that will close this issue
@ildar170975
Copy link
Contributor

ildar170975 commented Sep 3, 2024

@nathan-gs
1.5.1:
image

Strange, I see no difference between "default settings" & "gradual_opacity: 0.5".
Please check this:

  - type: custom:map-card
    title: default
    entities:
      - <<: &ref_entity_settings
          entity: person.ildar
          display: marker
          history_start: 12 hours ago
          history_end: now
          color: red
    <<: &ref_card_settings
      tile_layer_url: "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"
      card_size: 15

  - type: custom:map-card
    title: "gradual_opacity: 0.5"
    entities:
      - <<: *ref_entity_settings
        gradual_opacity: 0.5
    <<: *ref_card_settings

image

@ildar170975
Copy link
Contributor

ildar170975 commented Dec 24, 2024

@nathan-gs
Added some more details regarding the prev. comment.
Please have a look at this picture:
image

These are 4 similar cards:
-- 2 cards for a device_tracker entity, 2 cards for a associated person entity;
-- 2 cards w/o gradual_opacity defined, 2 cards with gradual_opacity = 0.9

Card-mod was used to hide a map & a marker (security reasons):

  - type: custom:map-card
    title: device_tracker - default
    entities:
      - entity: device_tracker.xxx
        <<: &ref_entity_settings
          display: marker
          color: red
    <<: &ref_card_settings
      history_start: 12 hours ago
      history_end: now
      card_size: 8
      card_mod:
        style:
          map-card-entity-marker $: |
            .marker :first-child {display: none}
          .: |
            .leaflet-tile-pane {display: none}

  - type: custom:map-card
    title: person - default
    entities:
      - entity: person.xxx
        <<: *ref_entity_settings
    <<: *ref_card_settings

  - type: custom:map-card
    title: "device_tracker - gradual_opacity: 0.9"
    entities:
      - entity: device_tracker.xxx
        <<: *ref_entity_settings
        gradual_opacity: 0.9
    <<: *ref_card_settings

  - type: custom:map-card
    title: "person - gradual_opacity: 0.9"
    entities:
      - entity: person.xxx
        <<: *ref_entity_settings
        gradual_opacity: 0.9
    <<: *ref_card_settings

Strangely the gradual_opacity does not seem to work for a person entity.
But if use_base_entity_only: true is set for the person entity - then the opacity seems to be applied:
image

Note that the device_tracker entity is the only entity used inside the person entity.

@shaiger
Copy link

shaiger commented Jan 22, 2025

I have a strong suspicion that if I present multiple (moving) entities, which also results in more sections, I need to increase the value for gradual_opacity beyond 1.
This is not very convenient to reproduce, but I'll try to add a few screenshots later.
Perhaps consider to check if opacity is restarted between entities, and how sections are sorted (per entity or in overall).
There us a product question here: if opacity is determined only by time (for all entities), or per entity. Given this is a per entity config, I assumed it's per entity.

@nathan-gs
Copy link
Owner

It's per entity:
https://github.com/nathan-gs/ha-map-card/blob/main/src/models/EntityHistory.js#L48-L91

It follows very similar logic to the native ha frontend card.

@nathan-gs nathan-gs reopened this Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants