Combining Home Connect sensors in template

Hi! Can someone help me out with this?
Ik have this Home Connect integration and it does display every part of the Oven as a separate sensor. So like the sensor names are:

switch.oven_power (values: on or off)
switch.oven_program_preheating (on or off)
sensor.oven_program_progress (xxx%)

I wish to display the state of the oven in a picture-glance. So, I can show the state of the oven with the corresponding picture.
1 oven_off.png
2 oven_on.png
3 oven_pre.png
4 oven_baking.png
5 oven_finshed.png

The problem is, there are multiple sensors. So, I can’t use state_image with:
state_image:
“1”: /local/ oven_off.png
“2”: /local/ oven_on.png
“3”: /local/ oven_pre.png
Etc.

Is there someone who knows a solution for this?
I was thinking of a template that can combine the sensor entity’s and generate an new oven.entity with a state from 1 to 5 or something. From that state, I can use the picture glance with state_image: 1, 2, 3 etc.

Such a state could be calculated by IF switch.oven_power is on AND switch.oven_program_preheating is on AND sensor.oven_program_progress is < 1% THEN state must be 3. For example.
I can’t get my head around this how I should program such a template. Is there someone that understands the templating deeply enough to get me underway? I’ve been breaking my head on this all day.
I wish to use the standard out of the box home assistant tools, no custom components.

Thanks!

{% if is_state('sensor.oven_power','on') and is_state('sensor.oven_program_preheating','on') and states('sensor.oven_program_progress')|int < 1 %}
  3
{% elif ... %}
  ...
{% else %}
  ...
{% endif %}

Would this be correct?

sensor:
  - platform: template
    sensors:
      oven:
        friendly_name: "Oven"
        value_template: >-
          {% if is_state('switch.oven_power','off') %}
            1
          {% elif is_state('switch.oven_power','on') and is_state('switch.oven_program_preheating','off') and states('sensor.oven_program_progress','unavailable') %}
            2
          {% elif is_state('switch.oven_power','on') and is_state('switch.oven_program_preheating','off') and states('sensor.oven_program_progress','unavailable') %}
            2
          {% elif is_state('switch.oven_power','on') and is_state('switch.oven_program_preheating','on') and states('sensor.oven_program_progress')|int < 1 %}
            3
          {% elif is_state('switch.oven_power','on') and is_state('switch.oven_program_preheating','off') and states('sensor.oven_program_progress')|int > 1 %}
            4
          {% elif is_state('switch.oven_power','on') and is_state('switch.oven_program_preheating','off') and states('sensor.oven_program_progress')|int > 99 %}
            5
          {% else %}
            0
          {% endif %}

That template will never report 5 when the value exceeds 99. That’s because the previous test already checks if the value exceeds 1 and reports 4.

1 Like

I’m trying a simpler template below (skipping the preheating part). But I get an template running error in the /developer-tools/template/ It’s not telling why. Not getting it fixed today. I’ts late, need to continue another day. Maybe it has something to do with is_state

sensor:
  - platform: template
    sensors:
      oven:
        friendly_name: "Oven"
        value_template: >-
          {% if is_state('switch.oven_power','off') %}
            poweroff
          {% elif is_state('switch.oven_power','on') and is_state('sensor.oven_program_progress','unavailable') %}
            poweron
          {% elif is_state('switch.oven_power','on') and is_state('sensor.oven_program_progress')|int < 1 %}
            poweronalso
          {% elif is_state('switch.oven_power','on') and is_state('sensor.oven_program_progress')|int > 1 %}
            running
          {% else %}
            Finished
          {% endif %}

That’s not valid templating. You’d want states there, since you’re not checking if it’s a specific value.

Yeah! It’s working. This example can be used to drive state-image in a picture glance the lovelace frontend. I’ve been adding other sensors then I mentioned before in my request.
Maybe it’s nice to add it to the documentation for other users at. https://www.home-assistant.io/integrations/home_connect/
Aldough I understand there are mabye other ways to archive the goal if you’r really good at templating. I’m continuing to finetune it now.

sensor:
  - platform: template
    sensors:
      oven:
        friendly_name: "Oven"
        value_template: >-
          {% if is_state('switch.oven_power','off') %}
            Standby
          {% elif is_state('switch.oven_power','on') and is_state('switch.oven_program_600watt','off') and is_state('switch.oven_program_hotair','off') and is_state('switch.oven_program_pizzasetting','off') and is_state('switch.oven_program_preheating','off') and is_state('switch.oven_program_topbottomheating','off') %}
            Power-on
          {% elif is_state('switch.oven_power','on') and is_state('switch.oven_program_600watt','off') and is_state('switch.oven_program_hotair','off') and is_state('switch.oven_program_pizzasetting','off') and is_state('switch.oven_program_preheating','on') and is_state('switch.oven_program_topbottomheating','off') %}
            Preheat
          {% elif is_state('switch.oven_power','on') and is_state('switch.oven_program_600watt','on') %}
            Microwave
          {% elif is_state('switch.oven_power','on') and is_state('switch.oven_program_hotair','on') %}
            4Dhotair
          {% elif is_state('switch.oven_power','on') and is_state('switch.oven_program_pizzasetting','on') %}
            Pizza
          {% elif is_state('switch.oven_power','on') and is_state('switch.oven_program_topbottomheating','on') %}
            Toptobottom
          {% else %}
            Finished
          {% endif %}

And the corresponding picture-glance could look like this:

type: picture-glance
entities:
  - switch.oven_power
  - sensor.oven_program_progress
  - sensor.oven
  - binary_sensor.oven_door
entity: sensor.oven
state_image:
  Standby: /local/oven_uit.png
  Power-on: /local/oven_aan.png
  Preheat: /local/oven_preheat.png
  Microwave: /local/oven_microwave.png
  4Dhotair: /local/oven_hotair.png
  Pizza: /local/oven_pizza.png
  Toptobottom: /local/oven_topbottom.png
  Finished: /local/oven_duration.png
  unknown: /local/oven_uit.png
show_state: true

Also sharing the code for the dishwasher:

  - platform: template
    sensors:
      dishwasher:
        friendly_name: "Siemens vaatwasser"
        value_template: >-
          {% if is_state('switch.vaatwasser_program_auto1','on') %}
            Auto1
          {% elif is_state('switch.vaatwasser_program_auto2','on') %}
            Auto2
          {% elif is_state('switch.vaatwasser_program_auto3','on') %}
            Auto3
          {% elif is_state('switch.vaatwasser_program_autohalfload','on') %}
            Autohalfload
          {% elif is_state('switch.vaatwasser_program_eco50','on') %}
            Eco50
          {% elif is_state('switch.vaatwasser_program_expresssparkle65','on') %}
            Expresssparkle65
          {% elif is_state('switch.vaatwasser_program_glas40','on') %}
            Glas40
          {% elif is_state('switch.vaatwasser_program_glasscare','on') %}
            Glasscare
          {% elif is_state('switch.vaatwasser_program_intensiv45','on') %}
            Intensive45
          {% elif is_state('switch.vaatwasser_program_intensiv70','on') %}
            Intensive70
          {% elif is_state('switch.vaatwasser_program_intensivpower','on') %}
            Intensivepower
          {% elif is_state('switch.vaatwasser_program_kurz60','on') %}
            Kort60
          {% elif is_state('switch.vaatwasser_program_machinecare','on') %}
            Machinecare
          {% elif is_state('switch.vaatwasser_program_magicdaily','on') %}
            Dailymagic
          {% elif is_state('switch.vaatwasser_program_maximumcleaning','on') %}
            Maximumcleaning
          {% elif is_state('switch.vaatwasser_switch.vaatwasser_program_nightwash','on') %}
            Silent
          {% elif is_state('switch.vaatwasser_program_normal45','on') %}
            Normal45
          {% elif is_state('switch.vaatwasser_program_normal65','on') %}
            Normal65
          {% elif is_state('switch.vaatwasser_program_quick45','on') %}
            Quick45
          {% elif is_state('switch.vaatwasser_program_quick65','on') %}
            Quick65
          {% elif is_state('switch.vaatwasser_program_steamfresh','on') %}
            Steamfresh
          {% elif is_state('switch.vaatwasser_program_super60','on') %}
            Super60
          {% elif is_state('switch.vaatwasser_power','on') %}
            Power-on
          {% else %}
            Standby
          {% endif %}

And the corresponding picture-glance:

      - type: picture-glance
        entities:
          - switch.vaatwasser_power
          - sensor.vaatwasser_program_progresssensor.dishwasher
          - sensor.dishwasher
          - binary_sensor.vaatwasser_door
        entity: sensor.dishwasher
        state_image:
          Standby: /local/vaatwasser_off.png
          Power-on: /local/vaatwasser_on.png
          Auto1: /local/vaatwasser_Auto1.png
          Auto2: /local/vaatwasser_Auto2.png
          Auto3: /local/vaatwasser_Auto3.png
          Autohalfload: /local/vaatwasser_Autohalfload.png
          Eco50: /local/vaatwasser_Eco50.png
          Expresssparkle65: /local/vaatwasser_Expresssparkle65.png
          Glas40: /local/vaatwasser_ Glass40.png
          Glasscare: /local/vaatwasser_Glasscare.png
          Intensive45: /local/vaatwasser_Intensive45.png
          Intensive70: /local/vaatwasser_Intensive70.png
          Intensivepower: /local/vaatwasser_Intensivepower.png
          Kort60: /local/vaatwasser_Kort60.png
          Machinecare: /local/vaatwasser_Machinecare.png
          Dailymagic: /local/vaatwasser_Dailymagic.png
          Maximumcleaning: /local/vaatwasser_Maximumcleaning.png
          Silent: /local/vaatwasser_Silent.png
          Normal45: /local/vaatwasser_Normal45.png
          Normal65: /local/vaatwasser_Normal65.png
          Quick45: /local/vaatwasser_Quick45.png
          Quick65: /local/vaatwasser_Quick65.png
          Steamfresh: /local/vaatwasser_Steamfresh.png
          Super60: /local/vaatwasser_Super60.png
          Finished: /local/vaatwasser_finished.png
          unknown: /local/vaatwasser_off.png
        show_state: true

Well, to conclude, here also the template for the coffeemachine:

  - platform: template
    sensors:
      coffeemachine:
        friendly_name: "Siemens coffee"
        value_template: >-
          {% if is_state('switch.espresso_volautomaat_power','off') %}
            Standby
          {% elif is_state('switch.espresso_volautomaat_program_americano','on') %}
            Americano
          {% elif is_state('switch.espresso_volautomaat_program_caffelatte','on') %}
            Caffelatte
          {% elif is_state('switch.espresso_volautomaat_program_cappuccino','on') %}
            Cappuccino
          {% elif is_state('switch.espresso_volautomaat_program_coffee','on') %}
            Coffee
          {% elif is_state('switch.espresso_volautomaat_program_cortado','on') %}
            Cortado
          {% elif is_state('switch.espresso_volautomaat_program_espresso','on') %}
            Espresso
          {% elif is_state('switch.espresso_volautomaat_program_espressodoppio','on') %}
            Espressodoppio
          {% elif is_state('switch.espresso_volautomaat_program_espressomacchiato','on') %}
            Espressomacchiato
          {% elif is_state('switch.espresso_volautomaat_program_flatwhite','on') %}
            Flatwhite
          {% elif is_state('switch.espresso_volautomaat_program_galao','on') %}
            Galao
          {% elif is_state('switch.espresso_volautomaat_program_lattemacchiato','on') %}
            Lattemacchiato
          {% elif is_state('switch.espresso_volautomaat_program_milkfroth','on') %}
            Milkfroth
          {% elif is_state('switch.espresso_volautomaat_program_ristretto','on') %}
            Ristretto
          {% elif is_state('switch.espresso_volautomaat_program_warmmilk','on') %}
            Warmmilk
          {% elif is_state('sensor.espresso_volautomaat_program_progress','0') %}
            Ready
          {% elif is_state('switch.espresso_volautomaat_power','on') %}
            Power-on
          {% else %}
            Standby
          {% endif %}

And the code for picture-glance:

      - type: picture-glance
        entities:
          - switch.espresso_volautomaat_power
          - sensor.espresso_volautomaat_program_progress
          - sensor.koffiemachine
        entity: sensor.koffiemachine
        state_image:
          Standby: /local/koffie_standby.png
          Power-on: /local/koffie_on.png
          Americano: /local/koffie_Americano.png
          Caffelatte: /local/koffie_Caffelatte.png
          Cappuccino: /local/koffie_duration.png
          Coffee: /local/koffie_Cappuccino.png
          Cortado: /local/koffie_Cortado.png
          Espresso: /local/koffie_Espresso.png
          Espressodoppio: /local/koffie_Espressodoppio.png
          Espressomacchiato: /local/koffie_Espressomacchiato.png
          Flatwhite: /local/koffie_Flatwhite.png
          Galao: /local/koffie_Galao.png
          Lattemacchiato: /local/koffie_Lattemacchiato.png
          Milkfroth: /local/koffie_Milkfroth.png
          Ristretto: /local/koffie_Ristretto.png
          Warmmilk: /local/koffie_Warmmilk.png
          Ready: /local/koffie_ready.png
          Finished: /local/koffie_ready.png
          unknown: /local/koffie_standby.png
        show_state: true

I didn’t use all sensors of the machine.

Because some sensors didn’t work at all, they don’t get a value from Siemens.

Other sensors look great on first sight, but complicated the formula then using. For example the duration behaviour is not always useable or the same on every machine.

If you have a different machine, you can also have different sensors then in the example.

Probably also works on Bosch Home Connect.

You can modify the code for other Home Connect appliances. Other sensors mean other possabilities!

Make your own graphics (I can’t supply them, but you could screen copy them form the official siemens app for example…) Aldough the naming suggest lots of images, I actually recylce 1 PNG picture for all programs, I don’t have photo’s of them all :slight_smile:

hi there, do you have templates for other devices such as oven, cooker & glassdraft/downdraft? Also it would be nice if you share a example picture as i am fairly new to HA i am not sure if i should start reading into it or if i queue this for later

thx
PX80