iorifly
(Renato Barbosa)
October 18, 2018, 12:31am
1
Hello, dear!
I am trying to put several switch template … But I get criticism. informs you that you are wrong. Where am I wrong?
- platform: template
switches:
luz_externa:
friendly_name: Luz Externa Entrada
value_template: "{{ is_state('input_boolean.sonoff_switch_8', 'on') }}"
turn_on:
service: input_boolean.turn_on
data:
entity_id: input_boolean.sonoff_switch_8
turn_off:
service: input_boolean.turn_off
data:
entity_id: input_boolean.sonoff_switch_8
icon_template: >-
{% if is_state('input_boolean.sonoff_switch_8', 'on') %}
mdi:circle-outline
{% else %}
mdi:circle-outline
{% endif %}
Luz_Piscina:
friendly_name: Luz Piscina
value_template: "{{ is_state('input_boolean.sonoff_switch_5', 'on') }}"
turn_on:
service: input_boolean.turn_on
data:
entity_id: input_boolean.sonoff_switch_5
turn_off:
service: input_boolean.turn_off
data:
entity_id: input_boolean.sonoff_switch_5
icon_template: >-
{% if is_state('input_boolean.sonoff_switch_5', 'on') %}
mdi:lightbulb-outline
{% else %}
mdi:lightbulb
{% endif %}
finity
October 18, 2018, 3:12am
2
what does the home-assistant.log say?
1 Like
iorifly
(Renato Barbosa)
October 18, 2018, 3:17am
3
In the validation part of the code I get the following message
invalid config for [switch.template]: [Luz_Piscina] is an invalid option for [switch.template]. Check: switch.template->switches->Luz_Piscina. (See ?, line ?). Please check the docs at https://home-assistant.io/components/switch.template/
JTPublic
(JT)
October 18, 2018, 3:24am
4
I think the input_boolean.turn_on and turn_off do not need the following “data:”, just
turn_on:
service: input_boolean.turn_on
entity_id: input_boolean.sonoff_switch_8
iorifly
(Renato Barbosa)
October 18, 2018, 3:27am
5
when I have only the first switch, everything works perfectly. The error only occurs when I try to add another swtich [pool light]
turn_on:
service: input_boolean.turn_on
entity_id: input_boolean.sonoff_switch_8
If I remove this lines … it does not know which entity needs to render ON.
JTPublic
(JT)
October 18, 2018, 3:29am
6
Maybe it’s the icon_template? try comment it and test?
iorifly
(Renato Barbosa)
October 18, 2018, 3:31am
7
I commented and same result …
switch:
- platform: tplink
host: 192.168.1.177
- platform: broadlink
host: 192.168.1.92
mac: 78:0f:77:5a:bd:dd
- platform: template
switches:
luz_externa:
friendly_name: Luz Externa Entrada
value_template: "{{ is_state('input_boolean.sonoff_switch_8', 'on') }}"
turn_on:
service: input_boolean.turn_on
data:
entity_id: input_boolean.sonoff_switch_8
turn_off:
service: input_boolean.turn_off
data:
entity_id: input_boolean.sonoff_switch_8
# icon_template: >-
# {% if is_state('input_boolean.sonoff_switch_8', 'on') %}
# mdi:circle-outline
# {% else %}
# mdi:circle-outline
# {% endif %}
Luz_Piscina:
friendly_name: Luz Piscina
value_template: "{{ is_state('input_boolean.sonoff_switch_5', 'on') }}"
turn_on:
service: input_boolean.turn_on
data:
entity_id: input_boolean.sonoff_switch_5
turn_off:
service: input_boolean.turn_off
data:
entity_id: input_boolean.sonoff_switch_5
# icon_template: >-
# {% if is_state('input_boolean.sonoff_switch_5', 'on') %}
# mdi:lightbulb-outline
# {% else %}
# mdi:lightbulb
# {% endif %}
JTPublic
(JT)
October 18, 2018, 3:35am
8
I tested on mine, no error, works fine:
- platform: template
switches:
climate_control:
value_template: "{{ is_state('input_boolean.climate_control', 'on') }}"
turn_on:
service: input_boolean.turn_on
entity_id: input_boolean.climate_control
turn_off:
service: input_boolean.turn_off
entity_id: input_boolean.climate_control
icon_template: >-
{% if is_state('input_boolean.climate_control', 'on') %}
mdi:lightbulb-outline
{% else %}
mdi:lightbulb
{% endif %}
climate_control2:
value_template: "{{ is_state('input_boolean.climate_control', 'on') }}"
turn_on:
service: input_boolean.turn_on
entity_id: input_boolean.climate_control
turn_off:
service: input_boolean.turn_off
entity_id: input_boolean.climate_control
icon_template: >-
{% if is_state('input_boolean.climate_control', 'on') %}
mdi:lightbulb-outline
{% else %}
mdi:lightbulb
{% endif %}
finity
October 18, 2018, 3:36am
9
change the capital letters in Luz_Piscina: to lower case: luz_piscina:
iorifly
(Renato Barbosa)
October 18, 2018, 3:37am
10
LOLOLOL
Thank you!!! I’m restarting to see if it will display. My God why did not I think of that.
JTPublic
(JT)
October 18, 2018, 3:39am
11
It’s the capital letters, change mine to capital letter and got the same error, strange.
BTW, may I ask why those switches? Wouldn’t the originial input_boolean works the same?
iorifly
(Renato Barbosa)
October 18, 2018, 3:42am
12
I can not change the status of the icon in inputboolean … Change color etc.
JTPublic
(JT)
October 18, 2018, 3:44am
13
Got it. Glad @finity figured that out.