Newbie Templates for custom Sensor

Hi there,
I tried out some tutorials but every time I get an error of my configuration.

What I need: converting the value of a entity from switch to cover or open close

I have an tasmota device in my garage with 1 relay to control open/close/stop on a Hörmann motor.
A second pin is connected to an reedswitch which is configured in tasmota as switch (switch type dosn’ matter, right?)
So if the door is closed, the switch 2 is on, and if open I get off. I want to see Open and close and have this in one card at the UI , and if I tap on it the switch 1 Relais schould be closed. There is a pulse time set on tasmota, so relais1 releases after 8seconds, that’s the time that the door need to open or close.

So what I understand is first to make a template with a custom sensor. Right? Every template I tried, did bring me an error in my config. I think having some trouble with the spaces.

At my configuration.yaml I have an include to an template.yaml

Code of the configuration.yaml


# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Text to speech
tts:
  - platform: google_translate

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

# Amazon Echo example configuration.yaml entry
emulated_hue:
  listen_port: 80
  # Amazon Echo/Alexa stopped working on different ports. Search for "Philips Hue Bridge V1 (round)" in the Alexa App to discover devices.

homeassistant:
  customize: !include customize.yaml

sensor: !include sensor.yaml

template: !include template.yaml

My templates.yaml is empty now, after getting errors

The filename is template.yaml

Is it right that there are spaces in front of customize: and no spaces at template:
Did the spaces mean, that’s a sub of homeassistant:

I find the first solution

   sensor:
   
     - name: "Zustand Garagentor"
       
       state: >
         {% if is_state('switch.garagentor2','on') %}
          Geschlossen
         {% else %}
          Offen
         {% endif %}

That gives me a translation of the status on/off to Offen/Geschlossen

Now I need to combine the new sensor and the switch1 to a card on the UI. If I tap or hold…I would use the action switch.
How can I do that

Better solution would be like this

cover:
  - platform: template
    covers:
      garage_door:
        device_class: garage
        friendly_name: "Garage Door"
        value_template: "{{ states('switch.garagentor2')|float > 0 }}"
        open_cover:
          service: switch.garagentor1.toggle
        close_cover:
          service: switch.garagentor1.toggle
        stop_cover:
          service: switch.garagentor1.toggle

The action in the open_cover close_cover stop_cover section isn’t valid. What’s wrong?

Try this:

open_cover:
  service: switch.toggle
  target:
    entity_id: switch.garagentor1

1 Like