Concatenate Sensor Values

I am looking to concatenate the value of several sensors into one new sensor. So for example,
pick4_1 = 8
pick4_2 = 9
pick4_3 = 2
pick4_4 = 2

new sensor = 8922

I expect to need to do this in a new value template. But am not sure exactly how to express it. The closest I could get was:

  - platform: template
    sensors:
      pick4:
        value_template: "{{ states('sensor.pick_4_number_1'),states('sensor.pick_4_number_2'),states('sensor.pick_4_number_3'),states('sensor.pick_4_number_4')}}"
        friendly_name: 'Pick 4 Lotto'

However, this returns as (‘8’, ‘9’, ‘2’, ‘2’)

Any modification from this point results in an unavailable value or just total nonsense. Someone please point me in the right direction. Thanks!

 value_template: "{{ states('sensor.pick_4_number_1') ~ states('sensor.pick_4_number_2') ~ states('sensor.pick_4_number_3') ~ states('sensor.pick_4_number_4')}}"

THANK YOU! Worked perfect!

1 Like