Code Monkey home page Code Monkey logo

Comments (8)

karwosts avatar karwosts commented on June 25, 2024

Your template seems fine to me in a markdown card:

image

from frontend.

erkr avatar erkr commented on June 25, 2024

Your template seems fine to me in a markdown card:

Thanks for verifying, but it only fails for entities where the device class is missing.

from frontend.

karwosts avatar karwosts commented on June 25, 2024

Yes I see what you mean. It seems markdown card subscribes its template with an additional argument strict: true, and developer tools does not.

Related: #17824

from frontend.

karwosts avatar karwosts commented on June 25, 2024

So it seems that strict mode for devtools was replaced with an option report_errors, but report_errors seems to catch less things than strict mode.

Perhaps that should be reported as a core bug, that report_errors should be able to report everything that strict mode would catch. I assume that was its intention but I don't know.

from frontend.

erkr avatar erkr commented on June 25, 2024

@karwosts
Nice it seems your identifiers the source of this issue.
But one remark. Rejectattr and selectattr should not raise errors when those attributes don't exist (to my knowledge)?! They will simply not be selected or rejected (like dev tools and template sensors). That is why I raised the issue here.

from frontend.

ildar170975 avatar ildar170975 commented on June 25, 2024

Rejectattr and selectattr should not raise errors when those attributes don't exist (to my knowledge)?! They will simply not be selected or rejected (like dev tools and template sensors).

My first experiments with selectattr / rejectattr were on 2021 - and on that time I learned that I must check for an attribute existence before using selectattr/rejectattr.

from frontend.

erkr avatar erkr commented on June 25, 2024

My first experiments with selectattr / rejectattr were on 2021 - and on that time I learned that I must check for an attribute existence before using selectattr/rejectattr.

I agree it is not very robust, But How to do that in filter expressions?! When I lookup a value with state_attr(), I have to check, but in a filter I want to include/exclude entities that match.
I checked several places where I can execute templates (dev tools, template sensors, state switch card etc) and the same filtering works for all, except the markdown card.

Update: @ildar170975 thanks for your hint. This combo of filters works in the markdown as well:

selectattr('attributes.device_class', 'defined') |selectattr('attributes.device_class','eq','connectivity')

It complicates my full template, as I also want the entity's that don't have a device_class attribute (so need to merge two lists). But it's a workaround. Still hope the issue gets solved though.

from frontend.

erkr avatar erkr commented on June 25, 2024

Other simple example:

{% set entities = states | rejectattr('attributes.device_class','ne','connectivity')| map(attribute='entity_id') | list    -%}
{{ entities }}

auto entities card works fine:
image
Markdown card with the same template fails:
image

from frontend.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.