I have a similar configuration setting the state of an eTRV valve. I have this to choose the state in the gui
input_select:
bedroom_trv_state:
name: Bedroom TRV Valve State
options:
- Closed
- Normal
- Open
initial: Open
Then you have to trigger an automation to send the mqtt message with the payload.
I use appdaemon, so my (severely edited) code is
def initialize
self.listen_state(self.select_changed, self.input_select)
def select_changed(self, entity, attribute, old, new, kwargs):
if new == "Open":
newstate = "0"
elif new == "Closed":
newstate = "1"
elif new == "Normal":
newstate = "2"
else:
self.error("Invalid new state {}".format(new))
return
self.log("Sending mqtt message topic {} with payload {}".format(
self.valve_state_topic, newstate),
level = "DEBUG")
self.call_service("mqtt/publish", topic = self.valve_state_topic,
payload = newstate, qos = "2", retain = "true" )
My YAML is very poor, but if you want to use that instead, I think you need a state trigger with an action to call the mqtt publish service, something like this
automation:
trigger:
platform: state
entity_id: input_select.valve
action:
- service: mqtt/publish
data:
- topic:
- payload:
But my YAML is not up to filling in the blanks. You will probably need a template to fill in the payload. Hopefully this gives you a start.