I want to customize the icon color of a input_button depending on a different entity with similar name for a bulk of input_buttons. The input_buttons are named something like input_button.room_name_of_job and the other entity on which state the icon color should depend on is named something like switch.room_name_of_duty. Maybe someone of you can help me, otherwise I have to set customize it for every single input_button.
The config for one entity looks like this
input_button.schlafzimmer_heizung_boost: templates: icon_color: > if (['unavailable', 'unknown'].includes(state)) return '#bf0056'; if (entities['switch.schlafzimmer_bosch_thermostat_boost'].state === 'on') return '#ff8100'; return 'grey';
But I would like to move this into the customize_glob file. So I need a if statement which take the string input_button.schlafzimmer_heizung_boost, replaces “input_button.” with “switch”, and replaces “heizung_boost” with “bosch_thermostat_boost” and checks the state of the entity with the created string. Is this somehow possible?
Edit: I am using custom UI.
Edit 2: Corrected the code to actually work for one entity.