Template condition - one entity status + second entity numeric value combined together

Hi gyus,
I am trying to make a template or somehow to make this idea working.
I have a entity which gives me the actual power i Watts of my heating.
This is called

sensor.shelly

The other entity gives me status of my switch, that controls the heating if it´s ON or OFF.

switch.sonoff_10018775f2

What I need to have is a template, which will give me:

1, If the sonoff switch is OFF and in the same time the shelly sensor value is above 2000, it will give me a text: Heating the boiler in red text (or whatever I can put there).
That will exactly tell me, that the heating is not controlled by home assistant, but by the heating itslef depending on the hot water sensor which triggers the heating independently.
But if I know, that the Sonoff switch is OFF and there is above 2000 Watts on the shelly sensor, the water is heating in the boiler.

2, Otherwise, if these both conditions are not fulfilled, it gives me text Boiler not heating in green text.

Somebody any idea?

Thanks!

Try this binary sensor template to get the state, from your logic:

template:
  - sensor:
      - name: "Boiler"
        state: "{{ 'Heating' if is_state('switch.sonoff_10018775f2','off') and states('sensor.shelly')|float(0) > 2000 else 'Not Heating' }}"
        icon: "mdi:boiler"

Personally I’d do it with a binary sensor (you have two states):

template:
  - binary_sensor:
      - name: "Boiler Heating"
        state: "{{ is_state('switch.sonoff_10018775f2','off') and states('sensor.shelly')|float(0) > 2000 }}"
        icon: "mdi:boiler"

However this may be more difficult to change into coloured text as the state will be on/off.

Hej man,
thanks a lot for your help - it helped me a lot.
I was confused about how to write the state and now it´s clear.

Thanks!