rianadon / timer-bar-card

A progress bar display for Home Assistant timers
Other
396 stars 15 forks source link

Card Templater and value template for active_state field #136

Open SAOPP opened 8 months ago

SAOPP commented 8 months ago

Hello!

I’ll ask a question here, I haven't quite figured it out, with the help of Card Templater, will it be possible to set the current state of my binary sensor for a timer bar card?

My example is below:

          - type: custom:timer-bar-card
            entity: binary_sensor.tod
            active_state: 'off' <--- "{{ states('binary_sensor.tod') }}"
            end_time:
              attribute: after
            bar_height: 4px
            # invert: true
            text_width: 50px
            bar_direction: rtl
            bar_radius: 4px
            modifications:
            - elapsed: 0%
              bar_foreground: "#03a9f4"
            - elapsed: 50%
              bar_foreground: orange
            - elapsed: 90%
              bar_foreground: red
            mushroom:
              primary_info: none
              icon_type: none
              layout: horizontal
              color: green
            card_mod:
              style: |
                ha-card {
                  background-color: transparent !important;
                  border: none !important;
                  margin-top: -27px;
                  margin-left: 50px;
                  margin-right: 50px;
                }

I want to set on or off state of my sensor in one card, instead of adding few conditional card and time bar cards.

rianadon commented 8 months ago

Yes I think it should be possible. Does something like

type: custom:card-templater
entities:
  - binary_sensor.tod
card:
  type: custom:timer-bar-card
  sync_issues: ignore # Because templates take time to render
  entities:
    - entity: binary_sensor.tod
      active_state_template: {{ states('binary_sensor.tod') }}
     ....

not work?

SAOPP commented 8 months ago

Hello! I missed it up! I will check it, I solved it with two a few conditional cards right now...