Carte pour station essence

Bj

type: custom:button-card
entity: sensor.station_intermarche_XXXXXXXXXXXXXXXX_e10
show_icon: false
hold_action:
  action: more-info
tap_action:
  action: toggle
aspect_ratio: 3/1
name: false
show_name: false
show_state: false
styles:
  card:
    - background-color: '#4e5e78'
    - border-radius: 2%
    - padding: 5%
    - opacity: 0.7
  grid:
    - grid-template-areas: >
        ". . . . ." "price street_1 street_1 street_1 ." "price street_2
        street_2 street_2 ." "price street_3 street_3 street_3 distance" "time .
        . . km" ". . . . ." 
    - grid-template-columns: 2fr 1fr 1fr 1fr 1fr
    - grid-template-rows: min-content 1fr 1fr 1fr 1fr min-content
  custom_fields:
    price:
      - align-self: start
    street_1: null
    street_2: null
    street_3: null
    time:
      - justify-self: start
      - margin-top: '-35px'
      - font-size: 13px
      - margin-left: 10px
    km:
      - align-self: start
      - justify-self: start
      - margin-top: '-25px'
      - font-size: 13px
    distance:
      - align-self: start
      - justify-self: end
      - margin-right: 45px
      - margin-top: '-25px'
custom_fields:
  price:
    card:
      type: custom:button-card
      name: |
        [[[
        if (states['sensor.station_intermarche_XXXXXXXXXXXXXXXX_e10'].state > 1)
          return ` ${states['sensor.station_intermarche_XXXXXXXXXXXXXXXX_e10'].state}`;
        else 
          return '0,00';
        ]]]
      styles:
        card:
          - font-family: DJBGetDigital
          - color: yellow
          - font-size: 40px
  street_1:
    card:
      type: custom:button-card
      name: >-
        [[[ return
        `${states['sensor.station_intermarche_XXXXXXXXXXXXXXXX_e10'].attributes.station_name}`
        ]]]
      styles:
        card:
          - background-color: transparent
          - box-shadow: none
  street_2:
    card:
      type: custom:button-card
      name: >-
        [[[ return
        `${states['sensor.station_intermarche_XXXXXXXXXXXXXXXX_e10'].attributes.postal_code}
        ${states['sensor.station_intermarche_XXXXXXXXXXXXXXXX_e10'].attributes.city}` ]]]
      styles:
        card:
          - background-color: transparent
          - box-shadow: none
  street_3:
    card:
      type: custom:button-card
      name: >-
        [[[ return
        `${states['sensor.station_intermarche_XXXXXXXXXXXXXXXX_e10'].attributes.address}
        ${states['sensor.station_intermarche_XXXXXXXXXXXXXXXX_e10'].attributes.city}` ]]]
      styles:
        card:
          - background-color: transparent
          - box-shadow: none
  time: |
    [[[
      if (states['sensor.station_intermarche_XXXXXXXXXXXXXXXX_e10'].state > 1)
        return 'Ouvert';
      else 
        return 'Fermé';
    ]]]
  km: >-
    [[[ return `${states['sensor.station_intermarche_XXXXXXXXXXXXXXXX_e10'].state} km`
    ]]]
  distance:
    card:
      type: custom:button-card
      icon: mdi:navigation-variant
      name: false
      show_name: false
      tap_action:
        action: navigate
        navigation_path: /map
      styles:
        card:
          - background-color: '#242e42'
          - height: 25px
          - width: 25px
          - box-shadow: none
        icon:
          - width: 15px

Merci pour la proposition !

2 petits détails :

  • sur le prix, ça ne fonctionne pas pour le gpl car il est à moins d’1€/L , il faut plutôt faire ce test : .state > 0.1)
  • Le toggle sur le tap_action n’a pas de sens est peut être retirer :
tap_action:
  action: none