Jon_Miles
(Jon Miles)
December 14, 2018, 5:49pm
1
I have a fan that will send an MQTT topic to show whether it is running or not.
I do not want to control the fan, just have it report its state, which does quite happily.
but I cannot find a device class for a fan binary sensor.
is there a way to swap between the two fan icons to show whether it is running or not?
mdi:fan
mdi: fan-off
Many thanks
arsaboo
(Arsaboo)
December 14, 2018, 5:53pm
2
Jon_Miles
(Jon Miles)
December 14, 2018, 6:01pm
3
Thank you arsaboo, I did look at that, but i was lost…
I have split the configuration into subdirectories, so have a binary sensors folder, where would i need to record templates.
and how do i use templates to change the icon?
thank you again
arsaboo
(Arsaboo)
December 15, 2018, 4:15pm
4
You can use it in sensors
or in customize
(see here for an example).
Jon_Miles
(Jon Miles)
December 15, 2018, 9:47pm
5
Sorry i am being really thick here.
I have tried:
binary_sensor.rad_fan:
templates:
icon: >
if (state === ‘on’) return ‘mdi:fan’;
return ‘mdi:fan-off’;
in a file in the binary_sensors directory
I have tried adding it to the end of the sensor its self:
platform: mqtt
name: “Rad Fan”
state_topic: “bedroom/Radfan”
payload_on: “On”
payload_off: “OFF”
icon_template:
icon: >
if (state === ‘on’) return ‘mdi:fan’;
return ‘mdi:fan-off’;
neither of which will shoe the icon.
really sorry
nickrout
(Nick Rout)
December 15, 2018, 10:17pm
6
On is not the same as on, case matters.
Jon_Miles
(Jon Miles)
December 15, 2018, 10:24pm
7
sorry should have said, tried both
nickrout
(Nick Rout)
December 15, 2018, 10:27pm
8
Also I think === is wrong.
Jon_Miles
(Jon Miles)
December 15, 2018, 10:29pm
9
i took that from the files that arsaboo shared
nickrout
(Nick Rout)
December 15, 2018, 10:33pm
10
Scratch that response I was reading the wrong page
Jon_Miles
(Jon Miles)
December 15, 2018, 10:35pm
11
ah ok, not helping iat the moment that i lost all my previous work when the pi died!!!