Build Template Cover from Lock

Hi There. I am trying to build a cover template from a lock. I am trying to make use of the new Tile Card ‘Features’ so I can open and close my lock from the front-end tile but it’s only been built for covers so far. Here is my code I am trying to put in configuration.yaml - The new lock ‘cover’ is showing up as unavailable. Any help would be much appreciated :slight_smile:

- platform: template
    covers:
      basement_door:
        device_class: door
        friendly_name: "Basement Door Lock Cover"
        value_template: "{{ states('binary_sensor.basement_open')|float > 0 }}"
        open_cover:
          - condition: state
            entity_id: lock.basement
            state: "unlocked"
          - service: lock.unlock
            target:
              entity_id: lock.basement
        close_cover:
          - condition: state
            entity_id: lock.basement
            state: "locked"
          - service: lock.lock
            target:
              entity_id: lock.basement

If you look in your log you will see errors about trying to convert strings to floating point numbers. The |float filter only takes numbers. You are feeding it 'on' or 'off' (the states of a binary sensor).

Change this:

value_template: "{{ states('binary_sensor.basement_open')|float > 0 }}"

To this:

value_template: "{{ is_state('binary_sensor.basement_open', 'on') }}"

Or this:

value_template: "{{ states('binary_sensor.basement_open')|bool }}"

Thank you that half works… I am getting it to send the state to the cover when the lock goes from closed to open, but not the other way. Any guidance on what else I would need to add into the template line to capture that part?

The template covers both states. If the template resolves to false (binary sensor off) then the cover is closed, if it resolves to true (binary sensor on) then the cover is open.