delphiki / hass-pronote

Pronote integration for Home Assistant
58 stars 9 forks source link

Aide sur le style card-mod #38

Closed MickaelDENIS closed 11 months ago

MickaelDENIS commented 11 months ago

Bonsoir, Je cherche à pouvoir utiliser l'attribut background-color issu d'un item de la classe sensor.pronote_ENFANT_timetable_today Seulement cela n'affiche pas la bonne valeur.

Merci de votre aide

je pose ici le code de la carte , merci de me dire si ce n'est pas le bon endroit


type: markdown
content: >-
  {% set items =
  state_attr('sensor.pronote_xxxxx_maxime_timetable_today','lessons') %}
  <div>{{state_attr('sensor.pronote_xxxxx_maxime', 'full_name')|
  regex_replace('DENIS ','')}} - Emploi du temps du :
  {{as_timestamp(items[0].start_at) | int | timestamp_custom('%d/%m/%Y', true)}}
  </div>

  <table>   {% for i in range(0, items | count, 1) %}  <tr> 
    {%- if items[i].canceled != True -%} 
    <td style="background: {{ items[i].background_color }}; padding: 12px 12px; border-radius: 50px; ">&npsp;{{ items[i].background_color }}</td>
    <td><mark>{{ items[i].start_time}}</td> 
    <td><mark>{{ items[i].end_time }}</td></mark>
    <td>{{ items[i].lesson }}
  {% else %} <td><del>{{ items[i].start_time }}</td> <td><del>{{
  items[i].end_time}}</td> <td><del>{{ items[i].lesson }}</del>&emsp;{%- endif
  -%} {% if items[i].status != None %} <span> {{ items[i].status }}</td> {%
  endif %} <td> {{items[i].classroom }}</td> </tr> {% endfor %} </table> 
theme: Mushroom Square Shadow
card_mod:
  style:
    .: |
      ha-card ha-markdown {
        padding:0px
      }
      ha-card ha-markdown.no-header {
        padding:0px
      }
    ha-markdown$: |
      div {
          background-color:rgb(100, 100, 100);
          padding: 12px 12px;
          color:white;
          font-weight:normal;
          font-size:1.2em;
          border-top-left-radius: 5px; 
          border-top-right-radius: 5px; 
      }
      table{
        border-collapse: collapse;
        font-size: 0.9em;
        font-family: Roboto;
        width: 100%;
        outline: 0px solid #393c3d;
        margin-top:5px;
      } caption {
          text-align: center;
          font-weight: bold;
          font-size: 1.2em;
      } td {
          padding: 5px 10px 5px 10px;
          text-align: left;
          border-bottom: 0px solid #1c2020;
      }
      tr {
          border-bottom: 0px solid #1c2020;
      }

      tr:nth-of-type(even) {
          background-color: rgb(54, 54, 54, 0.3);
      }
      tr:last-of-type {
          border-bottom: transparent;          }*
      mark {
          background: #009767;
          color: #222627;
          border-radius: 5px;
          padding: 5px;
      }
      span {
          background: #EC4B34;
          color: #222627;
          border-radius: 5px;
          padding: 5px;
      }
      span {
          padding: 5px;
      }
      tr:nth-child(n+2) > td:nth-child(2) {
        text-align: left;
      }```
MickaelDENIS commented 11 months ago

ton dernier message sur le forum à répondu à cette question. merci