Trouble getting specific data from sensor

Currently made a python script that updates a sensor like below:

I’m then using a markdown lovelace card to ‘attempt’ :smiley: to display some of the channels like BBC One, TWO, ITV, Channel 4 and 5.

currently i’m using:

{% set tv_guide = state_attr('sensor.test_tv_guide', 'full_listing') %} 

{% for chan in tv_guide %}
  {{ chan.channel }}: {{ chan.show }} - {{ chan.time }}
{% endfor %}

Which displays all the data as expected like below:

image

Is there a better way to access and display this?

I’m using list-card to display tabular info like this.

1 Like

Did not know the list-card and requires a parser but that is a nice card indeed.
List-trouble at the moment is ‘attributes’ and I too am using markdown. My formatting is a bit different though as using table tr/td
Example, this for my kid’s homework
image

Thanks thats neat! (While i migrate to this), i’m trying to filter the json, for only channels BBC One etc

Can all be done in the card, the code becomes just ‘more’ … would be nicer to have a BBC-only sensor though :slight_smile:

adding code of card…there is more complexity possible

type: markdown
content: >
  <div>YOUR TITLE </div>
    <table>
    {% set dates = state_attr('sensor.[sensorname]','date')%}
    <tr>
    <td><h4>Date<h3></td>
    <td><h4>Course</td>
    <td><h4>Work</td>
    </tr>
    {% for i in range(0, dates | count, 1) %}
    {% if i == 0 %}<tr><td colspan="5"><b>{{ strptime(dates[0],"%Y/%m/%d").strftime("%A %d") }}</td></tr>
    {% endif %}
  {% if dates[i] > dates[i-1] %} <tr><td colspan=3><p><b>{{ strptime(dates[i],
  "%Y/%m/%d").strftime("%A %d")  }}</p></td></tr> {% endif %}
    <tr>
    {%- if state_attr('sensor.[sensorname]','done')[i] == '1' -%}
    <td>  
    <mark>
    {{ dates[i].split("/",1)[1] }}</mark></td>
    {% else %}
    <td>  
    <span>
    {{ dates[i].split("/",1)[1] }}</span></td>
    {%- endif -%}
    <td>{{ state_attr('sensor.[sensorname]','title')[i] }}</td>
    <td>{{ state_attr('sensor.[sensorname]','description')[i]}}</td>
    <td></td>
    </tr>
  {% endfor %}
card_mod:
  style:
    .: |
      ha-card ha-markdown {
        padding:0px
        padding:0px
      }
    ha-markdown $: |
      h1 {
          font-weight: normal;
          font-size: 24px;
      }
      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: auto;
        outline: 0px solid #393c3d;
        margin-top: 10px;
      } caption {
          text-align: center;
          font-weight: bold;
          font-size: 1.2em;
      } td {
          padding: 5px 5px 5px 5px;
          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: lightgreen;
          color: #222627;
          border-radius: 5px;
          padding: 5px;
      }
      span {
          background: orange;
          color: #222627;
          border-radius: 5px;
          padding: 5px;
      }
      span {
          padding: 5px;
      }
      tr:nth-child(n+2) > td:nth-child(2) {
        text-align: left;
      }`

and this is the attrib of the sensor

date:
  - 2023/02/06
  - 2023/02/06
  - 2023/02/06
  - 2023/02/06
  - 2023/02/06
  - 2023/02/07
  - 2023/02/07
  - 2023/02/07
  - 2023/02/07
  - 2023/02/07
  - 2023/02/07
  - 2023/02/07
  - 2023/02/07
  - 2023/02/09
title:
  - ANGLAIS SI
  - ED.PHYSIQUE & SPORT.
  - EDUCATION MUSICALE
  - HISTOIRE-GEOGRAPHIE
  - SCIENCES VIE & TERRE
  - ESPAGNOL LV2
  - ESPAGNOL LV2
  - ESPAGNOL LV2
  - FRANCAIS
  - FRANCAIS
  - FRANCAIS
  - MATHEMATIQUES
  - PHYSIQUE-CHIMIE
  - MATHEMATIQUES
description:
  - >-
    For the essay on Monday, don't forget to bring in your copy of The
    Outsiders, with post-it notes to find your quotes easily, your bookmark (if
    you wish so), paper and -as Lucas very rightly suggested, your brain! Scrap
    paper will be provided
  - Blocs de step
  - Travailler le chant et rythme, apprendre la leçon , apporter l'exposé
  - >-
    Faire l'activité cartographique. Coller la feuille sur le cahier. Colorier
    aux crayons de couleur.
  - sur feuille correctement présentée, réaliser la consigne 3 du TP9.
  - HACER LAS ACTIVIDADES DE LA FICHA SOBRE LA FORMA PROGRESIVA
  - >-
    MEMORIZAR LA FORMACIÓN DE LA FORMA PROGRESIVA (mémoriser la formation de la
    forme progressive)
  - MEMORIZAR LAS IDEAS PRINCIPALES DE LA LECCIÓN
  - N'oubliez pas d'acheter le livre Dracula
  - >-
    Pour ceux qui étaient au secourisme : réalisez sur une feuille l'exercice
    d'écriture que vous trouverez sur le polycopié des modalisateurs.
  - >-
    réviser les règles d'orthographe vues lors des dictées préparées +
    orthographe du vocabulaire de la peur
  - Exercices n°2 et n°3 uniquement de la fiche des problèmes sur les équations
  - étudier le chapitre 4
  - >-
    Réviser le chapitre sur les fractions et les équations pour une
    interrogation bilan.
done:
  - '1'
  - '1'
  - '1'
  - '1'
  - '1'
  - '1'
  - '1'
  - '1'
  - '0'
  - '1'
  - '1'
  - '1'
  - '1'
  - '0'
friendly_name: homework

so taking your example above, swap dates for channelnames and then set the sensor up as channelname that way i can pull it in? Problem is im not setting the sensor up via config yaml, im using REST API to update the sensor from a python script that runs on a local docker

Also, would love to turn this into a HA Sensor and set it up, just struggling to understand the documentation on it :smiley: