How to rename workday sensor state

I am using the workday sensor and it’s states are: On/Off.

I’d like to rename the state to Yes and No (instead of On / Off).

I’ve tried using this template sensor with no results (still getting On/Off):

template:
  - sensor:
      workday:
        value_template: "{% if is_state('binary_sensor.workday.sensor', 'on') %}Yes{% else %}No{% endif %}"

What am i typing wrong?

Try this:

template:
  - sensor:
    - name: workday
      state: >-
        {% if is_state('binary_sensor.workday.sensor', 'on') %}
          Yes
        {% else %}
          No
        {% endif %}
1 Like

:+1:

Or short: {{ 'Yes' if is_state('binary_sensor.workday.sensor', 'on') else 'No' }}

1 Like

I built my own, incorporates custom holidays and excludes weekends. FWIW.

    date_workday:
      value_template: >
        {% set date = states('sensor.date') %}
        {% set today = as_timestamp(date)  | timestamp_custom("%A") %}
        {% set holidays = [
        '2021-01-01',
        '2021-05-31',
        '2021-07-05',
        '2021-09-06',
        '2021-11-25',
        '2021-12-23',
        '2021-12-24',
        '2022-01-01',
        ] %}
        {% if today == 'Saturday' %}
          off
        {% elif today == 'Sunday' %}
          off
        {% elif date in holidays %}
          off
        {% else %}
          on
        {% endif %}
1 Like

That is the solution, thank you!

Slightly OT:

If you want to display if today and tommorow are working days, a new binary workday sensor has to be written with an additional line offset_days: 1.

Thanks to everyone that contributed!