Set slider to the value of an MQTT message

I have a pool control where i am using a sonoff 4chpro (tasmota). In home assistant, I have a slider that i use to set the temperature for the heater.

input_number:
  slider:
    name: Set pool temperature
    min: 60
    max: 95
    step: 1

I then have an automation to send this to the sonoff via MQTT

alias: AUTO-SetPoolTemperature
description: ""
trigger:
  - platform: state
    entity_id:
      - input_number.slider
condition: []
action:
  - service: mqtt.publish
    data:
      topic: cmnd/poolcontrol/Mem1
      payload_template: "{{states('input_number.slider')}}"
      retain: "true"
mode: single

On my dashboard i have a gauge next to the slider which shows the current temp setting of the pool.

cards:
  - type: gauge
    entity: input_number.slider
    needle: true
    severity:
      green: 86
      yellow: 80
      red: 89

Now i have a problem. On the sonoff (tasmota) i have a rule that sets the temperature back to 80 at midnight every night. Since this is all being done in tasmota, the slider and gauge on my dashboard don’t accurately reflect the current temp setting.

The tasmota publishes the state of mem1 (my temp setting) anytime it changes regardless of how it is changed. So when the temperature is set back to 80 at midnight, there is a retained MQTT message.

What i want to do is use that message value to adjust the setting on the gauge as well as the slider.

I found an example and tried (and failed ) to do this.

I created a sensor that takes the value of the mitt message:

mqtt:
     sensor:
        #to disply pool temperature using mqtt
          state_topic: 'poolcontrol/mem1'
          name: 'Current Temp Setting'
          unit_of_measurement: '°F'
          value_template: '{{ value_json.state }}'
          force_update: true

I then created an automation to set the value of the slider

  - platform: state
    entity_id:
    - input_number.slider
  condition: []
  action:
  - service: mqtt.publish
    data:
      topic: cmnd/poolcontrol/Mem1
      payload_template: '{{states(''input_number.slider'')}}'
      retain: 'true'
  mode: single

Once the value of the slider changes, that would drive the gauge to change.

I suspect my issue is in the automation but i can’t seem to figure out where to go from here.

I screwed this post up. The piece of code i copied wrong. It should be:

- id: '1689429753230'
  alias: SetTempSliderDefault
  description: ''
  trigger:
  - platform: mqtt
    topic: poolcontrol/mem1
    action:
  - service: input_number.select_value
    data_template:
    entity_id: input_number.slider
    value: '{{ states.sensor.slider.state }}'