How to show text-only in Lovelace?

well, it doesn’t work. Tried all these formats.

My python script creates this sensor.summary, and sensor.orphans_sensor, which have a text file as attribute indeed, and is customized via the custom-card and hence can be over 255 characters.

In regular HA this is then displayed in a card.

you think it might be [[states.sensor.orphans_sensor.attributes.text]] ?

check this:
54

the parser is complaining about the https links in the comments of the html file…who would have thought that

it doesnt like #'s either:

how to comment out in these files?

in the template editor, does {{ states.sensor.orphans_sensor.attributes }} have an entry for “text” ?
if so, the syntax in the useful-markdown-card content would be [[ sensor.orphans_sensor.attributes.text ]].

Regarding the parsing errors, are these coming from the state-card_value-only that you tried to reference in lovelace.yaml? i think that file will only work with the custom_ui and the original front-end.

yes, that is:

yes it is the html file, but I need that for my regular HA frontend, which still shows nicely because of it;-)

you can keep the state-card_value-only, just don’t reference it in the lovelace.yaml… it’s in the wrong format and language for lovelace.

so, it seems you can replicate your original card content with the useful-markdown-card inside lovelace, just a little different syntax in the configuration.

so I changed it in the python not to use the custom-card,

left_over_card = '*=========== Orphans ===========\n'\
                 '{}'\
                 '*========== Entity count =========\n'\
                 '!- {} entities to list\n'\
                 '+- {} groups processed\n'\
                 '*=========== Settings ===========\n'\
                 '/- targetting group: {}\n'\
                 '$- ignoring {} items:\n' \
                 '%|-> {}\n'\
                 '$- ignoring {} domains:\n' \
                 '%|-> {}'\
                 .format(left_overs,
                         len(entity_ids),
                         len(groups),
                         target_group,
                         len(ignore_items),
                         ignore_items_unlist,
                         len(ignore_domains),
                         ignore_domains_unlist)

hass.states.set('sensor.orphans_sensor', len(entity_ids), {
    'custom_ui_state_card': 'state-card-value_only',
    'text': left_over_card,
  # 'unit_of_measurement': 'Orphans'
    })

hass.states.set('sensor.orphans_sensor_lovelace', len(entity_ids), {
   # 'custom_ui_state_card': 'state-card-value_only',
    'text': left_over_card
  # 'unit_of_measurement': 'Orphans'
    })

and use this in lovelace:

  - type: custom:useful-markdown-card
    content: >
       [[states.sensor.orphans_sensor_lovelace.attributes.text]]

still no such luck:

37

while it should show this:

… not wrong html in the way anymore, just cant find the right lovelace config

leave the custom card attribute in the python script, that is for the legacy frontend… lovelace doesn’t card about that and will have no effect.

in the lovelace content line, remove “states”… it is not exposed that way in the useful-markdown-card. should be [[ sensor.orphans_sensor_lovelace.attributes.text ]] or [[ sensor.ophans_sensor.attributes.text ]] as you had originally.

at least I know the card is installed correctly:

35:wink:

et voila!

40

that was it!. cool now we’re getting somewhere. Thank you so much!

Now how to color my lines and entities…

hmmm…doesn’t look like it will support colors: :confused:

Markdown is a simple way to format text that looks great on any device. It doesn’t do anything fancy like change the font size, color, or type — just the essentials, using keyboard symbols you already know.
https://commonmark.org/help/

yes, that’s why I was hesitant to try that.
Remarkable though is that when clicking for more-info, all correct formatting is displayed, so I know the legacy custom card is working and recognized in Lovelace.

Only need to develop a way to show it in the frontend on first view…
maybe @thomasloven will be able to have a look at that anytime in the future…
convert the custom-card-value_only I posted to a Lovelace usable one, or, maybe easier, have Lovelace simply show it in the frontend (the way the more-info already does)

You can use a little bit of html in the markdown card

- type: markdown
  content: >
    <font color="blue">Red</font>
    <font color="green">Blue</font>
    <font color="red">Green</font>

markdown%20color

2 Likes

HI!
thanks for that suggestion, I’ll have a look if that would work. The thing is, Id just need a card to display what was being offered to it… By using html in the markdown card, id be editing already formatted text, which seems unnecessar.

As you can read above, the more-info does show correctly, so it should be possible?

I think you may need to split each section of color into it’s own hidden entity if you want to make it easy for yourself.

Hello Mariusthvdb, i’m in the same situation as you with the new lovelace ui and the summary.py script.

I would like to know what should i do to make it works.

For now i have added useful-markdown-card.js in my www folder and i have tipped this in my lovelace.yaml:

  - url: /local/useful-markdown-card.js
    type: js    

      - type: vertical-stack
        cards:        
          - type: custom:useful-markdown-card
            content: >
               [[states.sensor.summary]]

Resulting in the same error you had before:

Could you please help me on what to do next?

Thanks.

create spaces before and after the entity

[[ sensor.name.state ]]

in this particular case:

[[ sensor.summary.attributes.text ]]

It’s because you have states in your name: states.sensor.summary. In your case it should just read sensor.summary.state. State is required at the end to let the card know you want the state out of it, not another attribute.

For some reason, the dev decided to omit the states object from the calls. Personally, I think we should create an issue with the card and have him add it back. So far, it’s only led to confusion as it’s the only place in HA that omits the states object.

it should read: [[ sensor.summary.attributes.text ]] because the sensor has the text he wants in the the attribute text…

if show_card:
    hass.states.set('sensor.summary', '', {
        'custom_ui_state_card': 'state-card-value_only',
        'text': summary
    })

agreed, we should , maybe @thomasloven reads along? or need we file an issue?

You’re assuming you know what sensor.summery is. Sensors don’t have a text attribute normally. That is what you are setting. Not everyone has your setup. We have to assume that he just has a normal summary sensor.

EDIT: Unless summery.py sets that. Then by all means, he’ll need the .attribute.text.

no in this case he specifically asked me about my python script summary.py, which creates the sensor.summary:

generally speaking you are right of course ;-}

I chose to ommit it for three reasons

  • becuase states is the only object that is accessible anyway
  • to drive home the point further that this is not the same kind of templates as in the HA configuration
  • because it simplified the code a little bit

At this point, I’m kind of unwilling to change it because it would break so many peoples configurations.

Thank you guys for your help, it works:

Do you now know how to disable the unwanted typo (+,!,*) and bring back the color lika before?

Thanks