Template helper binary sensor does not update

Hi,

I have a problem with a template helper binary sensor that does not update.

I have two Shelly PM Mini Gen3 devices connected to HA via the Shelly integration. One monitors my washing machine, the other my tumble dryer. This works fine and I get nice charts for the corresponding power sensors sensor.pm_mini_gen3_waschmaschine_power and sensor.pm_mini_gen3_waeschetrockner_power.

For use in automations, I added two template helper binary sensors that should indicate if each of the appliances is running:

template:
  - binary_sensor:
      - name: "Waschmaschine in Betrieb"
        delay_on:
          minutes: 1
        delay_off:
          minutes: 1
        state: >
          {{ states('sensor.pm_mini_gen3_waschmaschine_power')|float(0) >= 6 }}

and

template:
  - binary_sensor:
      - name: "Wäschetrockner in Betrieb"
        delay_on:
          minutes: 1
        delay_off:
          minutes: 1
        state: >
          {{ states('sensor.pm_mini_gen3_waeschetrockner_power')|float(0) >= 4 }}

Both sensors are added to HA as expected. However, the one for the washing machine does not update. For an example, see attached chart (1).

The “Waschmaschine in Betrieb” sensor never updates, even though the template condition is clearly met. I also evaluated the template in the developer tools, and it seems to be working fine. For example:

While the washing machine is off: see attached chart (3).

And while the washing machine is running: see attached chart (4).

The binary sensor for the tumble dryer is working fine: see attached chart (2).

I checked the logs and did not find anything related. I restarted HA multiple times. HA is on the latest version, 2026.1.3.

Any ideas what causes this or how to fix it?

Thanks :slight_smile:

As I can add only one media attachment, all pictures in one:

Where exactly are you adding these binary sensors? In general there should only be 1 template: key with both sensors under that. Elsewise double check that your sensor id is accurate.

1 Like

In the config folder (where the configuration.yaml is located), I have a subfolder called packages. In the packages folder, I have these two files:

  • sensor_waschmaschine_in_betrieb.yaml and
  • sensor_waeschetrockner_in_betrieb.yaml.

The content of those files is exactly as posted above.

In the last two lines of configuration.yaml, I include the packages folder:

homeassistant:
  packages: !include_dir_named packages

In HA’s Packages documentation, I read:

[1] Platform based integrations (light, switch, etc) can always be merged.

[2] Integrations where entities are identified by a key that will represent the entity_id ({key: config}) need to have unique ‘keys’ between packages and the main configuration file.

For example if we have the following in the main configuration. You are not allowed to re-use “my_input” again for input_boolean in a package:

input_boolean:
  my_input:

[3] Any integration that is not a platform [1], or dictionaries with Entity ID keys [2] can only be merged if its keys, except those for lists, are solely defined once.

As binary_sensor under the Template integration is a list, I thought it should fall under the exception mentioned in [3] and thus be ok. I thought this was also the conclusion of this discussion: Allow integration template: in packages - #19 by ardysusilo.

Was I misled?

Update: I just moved the definition of the binary template sensors directly into configuration.yaml:

template:
  - binary_sensor:
      - name: "Wäschetrockner in Betrieb"
        delay_on:
          minutes: 1
        delay_off:
          minutes: 1
        state: >
          {{ states('sensor.pm_mini_gen3_waeschetrockner_power')|float(0) >= 4 }}
      - name: "Waschmaschine in Betrieb"
        delay_on:
          minutes: 1
        delay_off:
          minutes: 1
        state: >
          {{ states('sensor.pm_mini_gen3_waschmaschine_power')|float(0) >= 6 }}

I also removed the packages entry from configuration.yaml and rebooted HA. The behaviour stays the same - binary_sensor.waschmaschine_in_betrieb does not update:

Update: I also double-checked the sensor id. I can just copy the whole template string {{ states('sensor.pm_mini_gen3_waschmaschine_power')|float(0) >= 6 }} from the sensor definition and paste it into the template editor in developer tools. I can see it correctly change from false to true there when the washing machine is running, and back to false afterwards.

Mentioning that your using packages helps, in that case your original configuration and files should work.

If the template works in the template editor then maybe try checking the sensors state in Settings>Devices & services>Helpers, click on the sensor, check it’s state, and then click the cog in the upper right hand corner and verify the sensor id.

Thank you for your input. The state in Settings > Devices & Services > Helpers was the same as in the Developer Tools and in the History.

I had to add unique_ids to the binary sensors in order to view their settings in the UI by clicking the cog (found this info here: This entity does not have a unique ID? - Home Assistant). The sensor id (entity id) shown when clicking the cog was again binary_sensor.waschmaschine_in_betrieb - as expected.

In the mean time, the problem seems to be solved - although I don’t know how. I removed the sensor definition from the YAML config, played around with some other parts of HA, and then gave it another shot today - and it worked right away. Not completely satisfactory, but if it stays that way, I won’t complain. :upside_down_face:

Thank you for your help!