How to change target_sensor based on other conditions?

I’m using HA as a thermostat and it works well - no major issues.

I have created a min/max average sensor based on the Living Room and Bedroom temperatures.
This min/max average sensor (average_temp_sensor) is used as the target_sensor for the thermostat. Usually means we get a good averaged target temp.

I have a small issue where I have a log burning stove in the living room which only really heats up the living room when lit. This understandably skews the average_temp_sensor when the living room gets warm and subsequently turns off the thermostat/heating. This means the bedroom can get quite cold and uncomfortable later in the evening.

I’d like to figure out a way around this.

Is it possible to do any of the following

Create a switch called “Fire lit” that we can turn “on” which changes the “target_sensor”?

Create a template sensor (custom_target_temp) that can be modified via an automation? Use custom_target_temp within the thermostat config
eg. It defaults to use the average_temp_sensor value
Above “Fire lit” switch is turned on which changes it to use bedroom_temp_sensor value

I could also go a step further and put a sensor by the fire and automate based on that temperature.

Either way, is what I’m looking to do possible?
To change a template sensor value via an automation?

Template sensor, but you don’t need the automation. Build the logic into the template to output the state of the chosen sensor. If you need more help just shout.

Speed up testing by using Developer Tools / Template.

How close am I?

      custom_temp_sensor:
	    value_template: >-
            {% if states('sensor.living_room') | float > 18 %}
                {{ states('sensor.bedroom') }}
            {% else %}
                {{ states('sensor.average_temp_indoor') }}
            {% endif %}
        unit_of_measurement: '°C'
        unique_id : custom_temp_sensor

That’s the idea, yes. Would recommend using modern format config for the template sensor:

Got it working.
I went down the route of the automation and input boolean as I was creating that anyway
I’ve got a temperature sensor located close to the fire and when that gets above a certain temperature it turns the “fire” input boolean “on”.
Using that state I’ve created a template to pick the bedroom temperature or the average.
Looks to be working as hoped.

      custom_temp_sensor:
        value_template: >-
          {% if is_state('input_boolean.fire', 'on') %}
            {{ states('sensor.bedroom') }}
          {% else %}
            {{ states('sensor.average_temp_indoor') }}
          {% endif %}
        unit_of_measurement: '°C'
        unique_id : custom_temp_sensor