thomasloven / lovelace-template-entity-row

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

Im sure my formatting is wrong - [object Object] #127

Closed DeFlanko closed 4 days ago

DeFlanko commented 5 days ago
type: entities
entities:
  - entity: sensor.run_counter_garden
  - type: custom:template-entity-row
    state: {{states(sensor.run_counter_grass)| float(0) | multiply(5) | round(0) }}
    name: Garden ran for
  - entity: sensor.run_counter_flowers
    name: Flowers
  - entity: sensor.run_counter_grass
    name: Grass
state_color: true
title: 'Water Run times '

image

any guidance would be greatly appreciated as to what im doing wrong here...

image

ildar170975 commented 4 days ago
state: {{states(sensor.run_counter_grass)| float(0) | multiply(5) | round(0) }}

Since you tested the template in Dev tools - you could have noticed a difference in the card's code, it has errors - must be states('sensor.run_counter_grass'). Besides, the whole template must be a string:

state: >-
  {{ states('sensor.run_counter_grass')| float(0) | multiply(5) | round(0) }}

or

state: "{{ states('sensor.run_counter_grass')| float(0) | multiply(5) | round(0) }}"

or

state: '{{ states(''sensor.run_counter_grass'')| float(0) | multiply(5) | round(0) }}'
DeFlanko commented 4 days ago

THANK YOU! (kinda feel dumb now.. lol)

type: entities
entities:
  - type: custom:template-entity-row
    name: >-
      Garden ran for {{ states('sensor.run_counter_garden')| float(0) |
      multiply(5) | round(0) }} min
  - type: custom:template-entity-row
    name: >-
      Flowers ran for {{ states('sensor.run_counter_flowers')| float(0) |
      multiply(5) | round(0) }} min
  - type: custom:template-entity-row
    name: >-
      Grass ran for {{ states('sensor.run_counter_grass')| float(0) |
      multiply(5) | round(0) }} min
  - type: custom:template-entity-row
    name: Total Run time for all stations was {{ (states('sensor.run_counter_grass') | float(0) | multiply(5) | round(0)) + (states('sensor.run_counter_garden') | float(0) | multiply(5) | round(0)) + (states('sensor.run_counter_flowers') | float(0) | multiply(5) | round(0)) }} min 
state_color: true
title: 'Water Run times '

image

ildar170975 commented 4 days ago

kinda feel dumb now

welcome to the club )))