Template Not Listening for State Change Events

I have a water pump on a smart switch. I want the switch to turn on in either of the following two situations:

A. Automated turn-on requires all three conditions to be true:
1. Water Pump Schedule helper is ON AND
2. input_boolean switch for Automating the Water Pump is ON AND
3. binary_sensor for monitoring the temperature of the water that is being pumped is ON (because the temp of the water is lower than my set water temp)

OR

B. Manual turn-on requires that the user has clicked a UI button tied to an input_boolean to manually turn on the water pump.

For some reason that I can’t figure out, my template is only listening for state changes tied to the schedule and the input_boolean for manual turn-on. Why isn’t the template listening for state changes to the binary_sensor or the input_boolean that’s tied to running the automation?

binary_sensor:
  - platform: template
    sensors:           
      house_call_for_hot_water:
        friendly_name: "House Call For Hot Water"
        value_template: >
            {{ (states('schedule.house_water_heating_schedule') == 'on' 
               and states('input_boolean.run_house_hot_water_schedule') == 'on'
               and states('binary_sensor.monitor_house_hot_water_temp_range') == 'on')
               or states('input_boolean.house_manual_hot_water_on') == 'on'
            }}

Well first, someone will be along shortly to say please post the actual code and not screenshots, because they are much harder to work with.

And second - from what I can see that template is doing exactly what it should be.
BUT - you haven’t shown us the output of input_boolean.casita_manual_hot_water_on only the schedule state and the binary sensor.

From looking at the screenshots - I can see the hot water schedule is off, so your first set of and conditions will be false, I’d hazard a guess that the manual hot water boolean is off too, hence the false state.

I’d also additionally recommend that if you creating NEW template sensors, you follow the steps to create them in the new (not really new more than a year old now) way, and not the old way of using - platform: template

binary_sensor:
  - platform: template
    sensors:           
      house_call_for_hot_water:
        friendly_name: "House Call For Hot Water"
        value_template: >
          {{ ['schedule.house_water_heating_schedule',
              'input_boolean.run_house_hot_water_schedule',
              'binary_sensor.monitor_house_hot_water_temp_range' ]
            | map('states') | select('eq','on') | list | count == 3
            or is_state('input_boolean.house_manual_hot_water_on', 'on') }}

Sorry, you were so fast to look at my question that when I realized that I hadn’t uploaded my code about 2 minutes after I had posted it you had already loaded my question.

But, I’m afraid you misunderstood my question, and it’s likely that the screenshots do a much better job of demonstrating my problem than my code . . .

Yes, the output of the template is correct. The problem is that the template is only looking for state changes for two of my four entities. As you can see on the bottom right of the first screenshot, the template isn’t tracking changes for two of my four entities.

I’ve just tried your solution, and it is an improvement: now the template is tracking state changes for all of the entities in the AND block, but it isn’t tracking state changes to

input_boolean.house_manual_hot_water_on

See bottom right of this screenshot:

1 Like

@mobile.andrew.jones . Ahhh. I get it now. I misunderstood the purpose for the list of listeners on the Developer Tools Template page. I thought that the list was suppose to contain all of the entities that are being used in the template. Now I understand that the list only includes those entities that, if changed could change the value of the template.

You were right that that my template was doing exactly what it should be, although your solution is more sophisticated.