Giter Site home page Giter Site logo

Comments (4)

laurentdinclaux avatar laurentdinclaux commented on July 25, 2024

Another fail (the badge shows properly, not the extra_data)

sensor.home_battery_load_watts:
            friendly_name: test
            extra_data_template: >
                ${attributes.amps + 'A'}
            extra_badge:
                entity_id: sensor.whizbangjr_amps  # Will take precedence over attribute and unit below.
                attribute: amps
                unit: A
                blacklist_states: 0

from home-assistant-custom-ui.

andrey-git avatar andrey-git commented on July 25, 2024

Those are JavaScript templates evaluated in your browser, not Jinja2 templates which are evaluated server-side and use a different syntax.

I added a clarification to the docs about this.

${attributes.amps + 'A'} should work however.

I just tested the following and it worked:

    light.study_lights:
      friendly_name: Light stretch-slider break-slider-toggle
      state_card_mode: break-slider-toggle
      stretch_slider: true
      amps: 11
      extra_data_template: >
        ${attributes.amps + 'A'}
extra_data_template: >
                return 'test';

worked fine too.

To make sure last version is loaded properly - open your browser's dev panel (Ctrl+shift+I or F12 on Chrome) - the CustomUI version should be printed in the console.

from home-assistant-custom-ui.

laurentdinclaux avatar laurentdinclaux commented on July 25, 2024

I'd rather display the sensor ( states.sensor.whizbangjr_amps.state ) data directly without having to use an extra badge or a static attribute. Is that possible ?

I tried to "console.log" the entities object but it doesn't seem to do anything.

extra_data_template: >
                console.log(entities); return 'test';

from home-assistant-custom-ui.

laurentdinclaux avatar laurentdinclaux commented on July 25, 2024

I found my way:

extra_data_template: >
                return entities["sensor.whizbangjr_amps"].state + "A";

from home-assistant-custom-ui.

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.