A little help with syntax for Bambu Lab printer?

Hey guys, trying to follow a config i saw on the internet. Its a sensor to tell when a 3d print will end. I am getting line 110: expected dictionary for dictionary value ‘sensors’ error and cannot figure it out.

# P1S time to finish print job
  - platform: template
    sensors:
      p1s_finish:
        friendly_name: p1s_finish_time
        icon: mdi:clock-end
        state: >
          {% set remaining = states('sensor.p1s_remaining_time') | float(0) %}
          {% if remaining > 0 %}
            {{ (now() + timedelta(hours=remaining)).strftime('%I:%M %p') }}
          {% else %}
            "N/A"
          {% endif %}

You’re mixing old and new sensor yaml configs.

if you want to stick to the legacy template format change “state:” to “value_template:” and “icon:” to “icon_template:”.

# P1S time to finish print job
  - platform: template
    sensors:
      p1s_finish:
        friendly_name: p1s_finish_time
        icon_template: mdi:clock-end # I think this should work
        value_template: >
          {% set remaining = states('sensor.p1s_remaining_time') | float(0) %}
          {% if remaining > 0 %}
            {{ (now() + timedelta(hours=remaining)).strftime('%I:%M %p') }}
          {% else %}
            "N/A"
          {% endif %}

thanks so much, that was it, really appreciate your help!

1 Like

just as a follow-up, when the printer is not in use, it says “N/A”. is there any way to get rid of that?