thomasloven / lovelace-template-entity-row

🔹 Display whatever you want in an entities card row.
MIT License
210 stars 16 forks source link

Glance Card #41

Closed jazzyisj closed 3 years ago

jazzyisj commented 3 years ago

Usage case: I have an alarm clock sensor used in several places (entities, glance, and picture glance cards) where the state is in 24h time. I tried to make a template-entity-row to convert the state to 12h time for the front end. I created template sensors instead to get the job done, but it would have been nice to do it right lovelace without having to create additional sensors.

Picture glance error.

image

thomasloven commented 3 years ago

Please provide your configuration.

Why are you using it in a picture-glance card anyway?

image

And more importantly; HOW are you using it in a picture-glance card? They don't even have a type: option.

jazzyisj commented 3 years ago

Why are you using it in a picture-glance card anyway?

I use the same element in a few other places in the front end so it was done with an include to keep the code common between them (I do this with several entities). Like I mentioned, it actually works fine as long as an entity is declared except for the state.

And more importantly; HOW are you using it in a picture-glance card?

Just like I would use any other entity in a picture glance. See the dummy entity row below.

  - type: picture-glance
    entity: sensor.alarm_clock_status
    entities:
      - type: custom:dummy_entity_row # this the dummy entity row works fine
        name: Alarm Clock Settings
        entity: sensor.dummy # as long as this entity is declared here
        icon: mdi:cog
        tap_action:
          action: call-service
          service: browser_mod.popup
          service_data:
            deviceID: this
            title: Alarm Clock Settings
            large: false
            card: !include /config/lovelace/include/entities/alarm_clock_settings.yaml
        double_tap_action:
          action: none
        hold_action:
          action: none

      # this is how I actually would use it since I use the same entity in a few places
      - !include /config/lovelace/include/entity/alarm_clock_auto.yaml

      # this was the contents of the include file above
      - type: custom:template-entity-row
        entity: sensor.alarm_clock_auto_display  # if this isnt declared we get property of substr error
        name: Auto Alarm
        icon: mdi:alarm
        state: >
          {{ states('sensor.alarm_clock_auto') if states('sensor.alarm_clock_auto')|lower in ['off','unknown','unavailable','none']
              else as_timestamp(states('sensor.date') ~ ' ' ~ states('sensor.alarm_clock_auto'))|timestamp_custom('%_I:%M %p') }}        
        tap_action:
          action: call-service
          service: browser_mod.popup
          service_data:
            title: Auto Alarm Clock
            deviceID: this
            large: false
            card: !include /config/lovelace/include/entities/alarm_clock_settings_auto.yaml
        double_tap_action:
          action: call-service
          service: input_boolean.toggle
          service_data:
            entity_id: input_boolean.alarm_clock_auto_workdays
        hold_action:
          action: call-service
          service: input_boolean.turn_off
          service_data:
            entity_id: input_boolean.alarm_clock_active_auto

image

Just for reference, here is a screenshot of the same element in another glance card. This elements in this screen shot do not use the template above. Like I mentioned before, I ended up creating a new template sensor to use in the front end to accomplish the time conversion in the state because the template-row-entity wouldn't display the template state in a glance card. So this issue really isn't holding me back at this point.

image

thomasloven commented 3 years ago

Well, picture-glance does not support custom elements.

jazzyisj commented 3 years ago

OK. Thanks for looking at it.