Template for _stateDisplay binary_sensor?

HI,

on https://github.com/andrey-git/home-assistant-custom-ui/blob/master/docs/templates.md#change-on-state-to-activated @andrey instruction for templating the binary_sensor state display are as follows:

binary_sensor.motion_sensor:
templates:
# null will make the regular state-based logic to run.
_stateDisplay: if (state === ‘on’) return ‘activated’; else return null;

Is it also possible to show the value of another template?

I am trying to have it show the number of people home and show the value of the badge that has that number:

binary_sensor.grand_family_home:
  show_last_changed: true
  templates:
    icon_color: >
      if (state === 'on') return 'rgb(251, 210, 41)';
      return 'rgb(54, 95, 140)';
    _stateDisplay: >
      return {{states.sensor.home_badge.state}}

Unfortunately the sensor just shows Detected, as device_class Occupancy , which i have given it indeed because of the nice little icon:
14

the badge is : 21

leaving the device_class out and manually templating the icon works fine for the icon, but the state wont be displayed as desired:

15

My understanding is binary sensors will only display on/off. If you wish to change the text of state you will need to use the template sensor.

nope, not true. read the link provided. change the stateDisplay is perfectly possible. My quest here is to do that with a template instead of a fixed text.
58

binary_sensor.people_home:
  show_last_changed: true
  templates:
    icon: >
      if (entities['sensor.home_badge'].state === '0') return 'mdi:account-off';
      if (entities['sensor.home_badge'].state > '1') return 'mdi:account-multiple-check';
      return 'mdi:account';
    icon_color: >
      if (state === 'on') return 'rgb(251, 210, 41)';
      return 'rgb(54, 95, 140)';
    _stateDisplay: >
      if (state === 'on') return 'Occupied' ;
      return 'Vacant' ;

btw the binary_sensor here is a template binary_sensor, so it would really be in line with the rest of the sensor logic to be able to do that with a template :wink:

changing display to make it a little less serious:
59