Mabaelst
(Bart Teuwen)
April 28, 2026, 10:30pm
1
hello everyone,
I have this code and have been looking for a few hours to see what is wrong here, but I can’t find it.
input_boolean:
nachtmodus2:
name: Nachtmodus2
template:
- binary_sensor:
- name: "Nachtmodus Icon2"
unique_id: Nachtmodus-Icon2
state: "{{ is_state('input_boolean.nachtmodus', 'on') }}"
picture: >
{% if is_state('input_boolean.nachtmodus', 'on') %}
/local/custom_icons/zon1.svg
{% else %}
/local/custom_icons/maan1.svg
{% endif %}
the files are in this folder
config\www\custom_icons.
can someone help me further and tell me what is wrong? thanks in advance.
NavNav
April 28, 2026, 10:43pm
2
Looks like a naming mismatch?
change input_boolean.nachtmodus to input_boolean.nachtmodus2
Mabaelst
(Bart Teuwen)
April 28, 2026, 10:48pm
3
thanks for your response, I have now changed it to
input_boolean:
nachtmodus2:
name: Nachtmodus2
template:
- binary_sensor:
- name: "Nachtmodus Icon2"
unique_id: Nachtmodus-Icon2
state: "{{ is_state('input_boolean.nachtmodus2', 'on') }}"
picture: >
{% if is_state('input_boolean.nachtmodus2', 'on') %}
/local/custom_icons/zon1.svg
{% else %}
/local/custom_icons/maan1.svg
{% endif %}
but it makes no difference
NavNav
April 28, 2026, 10:56pm
4
input_boolean:
nachtmodus2:
name: Nachtmodus2
template:
- binary_sensor:
- name: "Nachtmodus Icon2"
unique_id: nachtmodes_icon2
state: {{ is_state('input_boolean.nachtmodus2', 'on') }}
attributes:
entity_picture: >
{% if is_state('input_boolean.nachtmodus2', 'on') %}
/local/custom_icons/zon1.svg
{% else %}
/local/custom_icons/maan1.svg
{% endif %}
Try this above.
That state template needs to be surrounded by quotes and the picture configuration variable doesn’t go under attributes.
Are you reloading the Template entities or restarting HA after making the changes?
What do you mean by “it makes no difference”… how are you testing it?
The entity picture is working as expected for me when I use the configuration that you posted with some random .svg files:
The exact config used
input_boolean:
nachtmodus2:
name: Nachtmodus2
template:
- sensor:
- name: "Nachtmodus Icon2"
picture: |
{% if is_state('input_boolean.nachtmodus2', 'on') %}
/local/custom_icons/ball_of_yarn.svg
{%else%}
/local/custom_icons/bandit_mask_dj.svg
{%endif%}
unique_id: nachtmodus_0002
state: "{{is_state('input_boolean.nachtmodus2', 'on')}}"
1 Like
Mabaelst
(Bart Teuwen)
April 28, 2026, 11:26pm
6
Thanks for your reply. I keep restarting it.
What do you mean by “it makes no difference”… how are you testing it?
Yes, I adjusted what my supervisor asked me to do, but it doesn’t change anything.
I think I’ve tried everything already, but I can’t get it to work.
mekaneck
(Rick)
April 29, 2026, 3:07am
8
Did you try what @Didgeridrew suggested?
input_boolean:
nachtmodus2:
name: Nachtmodus2
template:
- binary_sensor:
- name: "Nachtmodus Icon2"
unique_id: nachtmodes_icon2
state: "{{ is_state('input_boolean.nachtmodus2', 'on') }}"
picture: >
{% if is_state('input_boolean.nachtmodus2', 'on') %}
/local/custom_icons/zon1.svg
{% else %}
/local/custom_icons/maan1.svg
{% endif %}
Mabaelst
(Bart Teuwen)
April 29, 2026, 7:24am
9
Thank you for your reply. This doesn’t work at all; I immediately get this error:
Mabaelst
(Bart Teuwen)
April 29, 2026, 9:31am
10
What I find so strange is that this code:
input_boolean:
nachtmodus:
name: Nachtmodus
template:
- binary_sensor:
- name: "Nachtmodus Icon"
unique_id: Nachtmodus-Icon
state: "{{ is_state('input_boolean.nachtmodus', 'on') }}"
icon: >
{% if is_state('input_boolean.nachtmodus', 'on') %}
local:maan1
{% else %}
local:zon1
{% endif %}
with the folder path: config\custom_icons does work
but this one with the folder path: config\www\custom_icons
input_boolean:
nachtmodus2:
name: Nachtmodus2
template:
- binary_sensor:
- name: "Nachtmodus Icon2"
unique_id: Nachtmodus-Icon2
state: "{{ is_state('input_boolean.nachtmodus', 'on') }}"
picture: >
{% if is_state('input_boolean.nachtmodus', 'on') %}
/local/custom_icons/zon1.svg
{% else %}
/local/custom_icons/maan1.svg
{% endif %}
does not work.
Does anyone perhaps have another idea?
petro
(Petro)
April 29, 2026, 11:41am
11
Share the whole file. You’ve shown us 15 lines and the error is calling out line 24. I.e. You’re hiding the problem from us.
123
(Taras)
April 29, 2026, 12:17pm
12
Where does this YAML code exist?
The error message indicates you are using packages.
Mabaelst
(Bart Teuwen)
April 29, 2026, 12:21pm
13
Thank you for your response.
This is the complete code and is located at:
config\Packages\Helpers\input_boolean\nachtmodus
petro
(Petro)
April 29, 2026, 12:22pm
14
… post the entire code for
Mabaelst
(Bart Teuwen)
April 29, 2026, 12:54pm
15
input_boolean:
nachtmodus2:
name: Nachtmodus2
template:
- binary_sensor:
- name: "Nachtmodus Icon2"
unique_id: Nachtmodus-Icon2
state: "{{ is_state('input_boolean.nachtmodus', 'on') }}"
picture: >
{% if is_state('input_boolean.nachtmodus', 'on') %}
/local/custom_icons/zon1.svg
{% else %}
/local/custom_icons/maan1.svg
{% endif %}
This is the entire code and it is in this folder: config\Packages\Helpers\input_boolean\nachtmodus
and the filename is: nachtmodus2.yaml
petro
(Petro)
April 29, 2026, 12:55pm
16
That’s not possible. The error is calling out line 24. That file only contains 15 lines. You are looking at the wrong file, or that’s not the error you are getting.
1 Like
NathanCu
(Nathan Curtis)
April 29, 2026, 1:10pm
17
Possible shadowed automation? Another copy in the registry I just had to excise one out of mine. It was a royal pain…
petro
(Petro)
April 29, 2026, 1:30pm
18
This is a config file, not automation
1 Like
NathanCu
(Nathan Curtis)
April 29, 2026, 1:39pm
19
Sorry template but it is still entirely possible to setup a template binary sensor in the UI with the same name and ent ID and then accidentally shadow it with yaml…
Ask me how I know.
petro
(Petro)
April 29, 2026, 2:03pm
20
No, that’s not possible. You’re mixing up 2 separate systems.
The error explicitly points to a yaml file, it explicitly points to a line number. The only way this will occur is if the file is being read and it has that many lines. Regardless if a mirrored entity shares the same entity_id in the ui.
1 Like
123
(Taras)
April 29, 2026, 2:16pm
21
Is that the only package file or are there others?
Please post the section of your configuration.yaml file that references all of your package files.