This much shorter version will do everything you tried to:
- binary_sensor:
- name: Garage Door State
unique_id: garage_door_state
device_class: garage_door
state: "{{ is_state('binary_sensor.door_sensor_1','on') }}"
availability: "{{ has_value('binary_sensor.door_sensor_1') }}"
Apart from the indentation issue you were also missing the multi-line character “>” after icon: Like you had for state:.
You can give the binary sensor a pretty name with spaces and capital letters, this will be converted to binary_sensor.garage_door_state for you.
Also templates for binary sensors should return true or false. The device class will translate that to Open or Closed.
There’s also no need for an icon template, the device class will supply open and closed garage icons. You just need to pick the correct device class.
See: https://www.home-assistant.io/integrations/binary_sensor/#device-class
The availability template will make the state unavailable instead of off if the door sensor is neither on nor off.
Finally you probably don’t even need a template sensor. You can do this from the frontend by clicking on binary_sensor.door_sensor_1 then clicking on the cog icon at the top of the pop-up card:
You can change the name and entity id to whatever you want too. But be careful if you have already used the entity id elsewhere in automations or scripts. You will need to change them too.
