Hi all, can someone please see why my new config is not working. I’m trying to move to the new template for my garage and gate. I use Sonoff SV for both, and monitor the state with a basic window/door sensor. Nothing too fancy, just a momentary on/off switch.
Old config:
cover:
- platform: template
covers:
garage_door:
friendly_name: "Garage"
value_template: "{{ states('binary_sensor.garage_door_window_door_is_open')|regex_replace('on','open')|regex_replace('off','closed') }}"
open_cover:
service_template: >
{% if is_state('binary_sensor.garage_door_window_door_is_open', 'off') %}
switch.turn_on
{% endif %}
entity_id: switch.sonoff_10008d36fa
close_cover:
service_template: >
{% if is_state('binary_sensor.garage_door_window_door_is_open', 'on') %}
switch.turn_on
{% endif %}
entity_id: switch.sonoff_10008d36fa
icon_template: >
{% if is_state('binary_sensor.garage_door_window_door_is_open', 'on') %}
mdi:garage-open
{% else %}
mdi:garage
{% endif %}
gate:
friendly_name: "Gate"
value_template: "{{ states('binary_sensor.gate_sensor_window_door_is_open')|regex_replace('on','open')|regex_replace('off','closed') }}"
open_cover:
service_template: >
{% if is_state('binary_sensor.gate_sensor_window_door_is_open', 'off') %}
switch.turn_on
{% endif %}
entity_id: switch.sonoff_10008d36e9
close_cover:
service_template: >
{% if is_state('binary_sensor.gate_sensor_window_door_is_open', 'on') %}
switch.turn_on
{% endif %}
entity_id: switch.sonoff_10008d36e9
icon_template: >
{% if is_state('binary_sensor.gate_sensor_window_door_is_open', 'on') %}
mdi:gate
{% else %}
mdi:gate
{% endif %}
New config:
template:
- cover:
- name: Garage
open_cover:
service: >-
{% if is_state('binary_sensor.garage_door_window_door_is_open', 'off') %}
switch.turn_on
{% endif %}
entity_id: switch.sonoff_10008d36fa
close_cover:
service: >-
{% if is_state('binary_sensor.garage_door_window_door_is_open', 'on') %}
switch.turn_on
{% endif %}
entity_id: switch.sonoff_10008d36fa
default_entity_id: cover.garage_door
icon: >-
{% if is_state('binary_sensor.garage_door_window_door_is_open', 'on') %}
mdi:garage-open
{% else %}
mdi:garage
{% endif %}
state: >-
{{ states('binary_sensor.garage_door_window_door_is_open') | regex_replace('on','open') | regex_replace('off','closed') }}
- name: Gate
open_cover:
service: >-
{% if is_state('binary_sensor.gate_sensor_window_door_is_open', 'off') %}
switch.turn_on
{% endif %}
entity_id: switch.sonoff_10008d36e9
close_cover:
service: >-
{% if is_state('binary_sensor.gate_sensor_window_door_is_open', 'on') %}
switch.turn_on
{% endif %}
entity_id: switch.sonoff_10008d36e9
default_entity_id: cover.gate
icon: >-
{% if is_state('binary_sensor.gate_sensor_window_door_is_open', 'on') %}
mdi:gate
{% else %}
mdi:gate
{% endif %}
state: >-
{{ states('binary_sensor.gate_sensor_window_door_is_open') | regex_replace('on','open') | regex_replace('off','closed') }}