as you can see, the icons display in the regular color, independent of the state. I would like these icons to change in yellow when On, and stay regular when Off.
just like the switches of the same devices:
of course the latter are switches and have that builtin, but maybe we can achieve this with the sensors too? Ive tried device_class but that is only for binary_sensors.
would be a nice feature for the custom-ui if not already available. hot-Icon when ‘On’, cold-icon when ‘Off’ @andrey@NotoriousBDG would you know if this can be achieved? Maybe theming? Ive also tried several value_templates, but they only change the value obviously, not the icon. I don’t know technical term for these coloring icons so finding a solution is a bit difficult… Maybe icon_template would be an option?
(ps the Off-badge in the picture are badges for extra_badge.scripts forcing the switches Off if the Hub doesn’t respond correctly. They don’t indicate the real state)
Thanks,
Marius
not at all.
There’s a bit of unregularity now and then in the results of my zwave sensors which i read off the Zwave Hub through mqtt. Also, i have several automations that use the states of these switches, and their power measurements. Some of these are system critical, so i must be 100% sure of the correct state they show.
some of the sensors, switches and automations of course are ‘derived’ or calculated based on the mqtt topics. So they burden the system by constantly processing these values, rather then only change on state_change. Also, retain values are very helpful for continuous state-streams (like power) but especially in the case of states they are only sent, well, on state changes.
In between restarts and reboots, that has proven to be a bit of a puzzle…showing/ or even rereading the correct state.state
Its a bit of a complicated thing, of which im not sure yet to have found the answer, though with the enormous help of @NotoriousBDG, i feel i’ve reached some ease…
I have a bunch of switches that combine templated sensors and several custom-ui extra_badges and value_templates…
Anyways, State, power and usage are the topics that are subscribed, so i need to have mqtt sensors for these separately. As a base for the other sensors and switches. They help me pindown the moment of miscommunication if en when that happens.
I suppose I still don’t understand why the state topic can’t be read as a binary sensor if it only publishes on/off values. For power and usage, sure. I wouldn’t suggest reading those as binary since they obviously aren’t, but state still seems binary in nature to me and it just looks like you’re essentially trying to mimic a binary sensor without using a binary sensor, based on the information I have.
yes, at first i set the customization per sensor, but than i changed that into a global customization in customize_glob.
Havent tried any other states, but that shouldn’t matter, it will work, just check the state machine for your use,and you will see immediately.
I did customize my scripts the same way in Glob, and works like a charm:
“script.*_force_off”:
icon: mdi:power
renders:
so not only changing color, but also changing icon.
You have to check the status from entity_id, what is display. Some entity_id show on/off then use that state in customize.yaml
From customize
templates:
rgb_color: “if (state === ‘Online’) return [251, 210, 41]; else return [54, 95, 140];” <== this show the state Online and actually refer from entity_id it show home or not_home
sensor.yaml
From sensor.
value_template: ‘{% if is_state(“device_tracker.raspberry_pi”, “home”) %}Online{% else %}Offline{% endif %}’
Just to be sure, do you have custom UI installed and enabled?
Also, you can get rid of the extra template sensor and use the same custom UI to change the displayed value of the device tracker directly if you want.
the odd thing is, my device is in fact home, so the template must be wrong.
If i take out the state template, it shows fine. Nice green theme, albeit Home…
If you use state in templates it changes the actual state so you would need to use Online and Offline in the theme template. If you just want to change what the device tracker shows as without changing the actual state, use _stateDisplay instead of state.