Templete help

Thanks for taking the time to look will look at it in the dev tools now

Hi that has got that section of code working so thanks.
However the last section is now the issue

   states:
      'true':
        type: custom:mushroom-template-card
        primary: Expected time left
        secondary: >-
          {{ (states('sensor.washing_machine_expected_time_left') |
          float| timestamp_custom(' %H:%M:%S ', False)) }}
        icon: mdi:clock
        entity: sensor.washing_machine_expected_time_left
        icon_color: blue
        fill_container: true
        layout: vertical

With the same error of but no default was specified which I don’t understand now

are you sure it’s the same error, verbatim?

ValueError: Template error: float got invalid input 'unavailable' when rendering template 'square: false columns: 2 type: grid cards: - type: custom:state-switch entity: template template: >- {% if as_timestamp(states('input_datetime.washing_stopped'), default=0) < as_timestamp(states('input_datetime.washing_started'), default=0) %} true {% else %} false {% endif %} states: 'true': type: custom:mushroom-template-card secondary: >- {{ as_timestamp(states('input_datetime.washing_expected_time_to_stop'), default=0) | timestamp_custom(' %H:%M:%S ', True) }} icon: mdi:clock icon_color: blue layout: vertical fill_container: true primary: Expected End Time - type: custom:state-switch entity: template template: >- {% if (as_timestamp(states('input_datetime.washing_stopped'), default=0) < as_timestamp(states('input_datetime.washing_started'), default=0)) and (states('sensor.washing_machine_expected_time_left') | float(0) > 0 ) %} true {% else %} false {% endif %} states: 'true': type: custom:mushroom-template-card primary: Expected time left secondary: >- {{ (states('sensor.washing_machine_expected_time_left') | float| timestamp_custom(' %H:%M:%S ', False)) }} icon: mdi:clock entity: sensor.washing_machine_expected_time_left icon_color: blue fill_container: true layout: vertical' but no default was specified

this is the error code it comes up with

you said it was the same error, but it’s clearly not, right?

in the dev tools template what do you get when you do this:

{{ states('sensor.washing_machine_expected_time_left') }}

NO errors and a output like this

square: false
columns: 2
type: grid
cards:
  - type: custom:state-switch
    entity: template
    template: >-
      
        false 
      
  states:
      'true':
        type: custom:mushroom-template-card
        secondary: >-
           01:00:00 
        icon: mdi:clock
        icon_color: blue
        layout: vertical
        fill_container: true
        primary: Expected End Time
   - type: custom:state-switch
    entity: template
    template: >-
      
        false  
      
      states:
      'true':
        type: custom:mushroom-template-card
        primary: Expected time left
        secondary: >-

        unavailable

        icon: mdi:clock
        entity: sensor.washing_machine_expected_time_left
        icon_color: blue
        fill_container: true
        layout: vertical

updating the thread. since we took some of this into chat.

the sensor is returning ‘unavailable’ so obviously that’s not going to work… so there’s a problem before it gets to this code.

1 Like