How to show text-only in Lovelace?

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

you can’t unfortunately other than some basic html codings and options used in markdown . see @thomasloven 's post some posts above: How to show text-only in Lovelace?

You can take out the signs in the summary cards altogether if you don’t want to use it any longer in regular HA. Or create a second sensor that doesn’t have all those formatting characters.

Btw if you click this card, it will show up in more-info as we’re used to

Yeah, it makes sense. I’m just looking at it from a support standpoint

Hello Mariusthvd could you please explain me how to take out the signs in the summary card.

Thanks.

with a text editor :wink:

take all signs in the script like this:

groups_format = ['+- Home: {} -- {}',
                 '!|-> Offline: {} -- {}',
                 '!|-> Status - Critical device offline: {} -- {}',
                 '#- Playing: {} -- {}',
                 '#- Tracked: {} -- {}',
                 '=- Lights on: {} -- {}',
                 '#- Switches on: {} -- {}',
                 '#- Appliances on: {} -- {}',
                 '+- Active: {} -- {}']

becomes:

groups_format = ['Home: {} -- {}',
                 'Offline: {} -- {}',
                 'Status - Critical device offline: {} -- {}',
                 'Playing: {} -- {}',
                 'Tracked: {} -- {}',
                 'Lights on: {} -- {}',
                 'Switches on: {} -- {}',
                 'Appliances on: {} -- {}',
                 'Active: {} -- {}']

there are a few other places, just take these out and reload the script, you’ll see immediate effect of your changes

that being said, changing this into the Lovelace cards won’t be very easy, because its not a matte of simply adding some html code.

most of the Card is created dynamically, and all of the text in the sensor.summary bit needs the formatting inside the sensor definition and not in the final card setup… still have to look in to that.
For now I think I might be better of leaving it as it is, having a perfect view in regular HA view, and rewrite a new setup with the new Lovelace idiom in mind.
Have best of both world and see what proves to be best.

Must admit I already tend to use some of my regular Tiles setup less often because I have some nice cards in native Lovelace.

otoh, I really miss the custom-ui functionality in Lovelace, and find it hard to believe we can’t even color a graph line depending on state, or use a theme on an entity like that.