Help with Input Select automation / Mqtt thing :)

Hi:)

I tried to search the forum for examples for this, but I got nothing to work:(

The case is:

I have an heatpump, which is able to send and get MQTT messages.

I would like to make an input select option to choose which mode it should be in.

The topics are:

state_topic: "b4e62d65a99f/HP/2201"
command_topic: "b4e62d65a99f/HP/SET/2201"

The payloads are:

0.00 (refers to Off)
1.00 (refers to Auto)
4.00 (refers to Hot Water Only)

How should I put together a input select and automation to work bidirectional?

Regards

Jacob

There’s an example for bidirectional manner in the docs.

Thanks:) I got that up and running now.

How do I then set/publish the payloads 0.00 1.00. and 4.00 when switching the input selector? Can I make one automation for this or do I need to make an automation for each payload - and would this be biderectional also?

It’s also in the docs.
Read the last (Set Thermostat Mode) example.

Well I got it to work now - sort of.

But is there not a way to simplify the automation instead of splitting it up, like I did here?

input_select:
  heatpump_mode:
    name: Heatpump Mode
    options:
      - "Off"
      - "Auto"
      - "Varmt Vand"
    icon: mdi:target

automation:

- alias: Set Heatpump Mode Selector
  trigger:
    platform: mqtt
    topic: "heatpump/mode"
  action:
     service: input_select.select_option
     data_template:
      entity_id: input_select.heatpump_mode
      option: "{{ trigger.payload }}"

- alias: Set Thermostat Mode
  trigger:
    platform: state
    entity_id: input_select.heatpump_mode
  action:
    service: mqtt.publish
    data_template:
      topic: "heatpump/mode"
      retain: true
      payload: "{{ states('input_select.heatpump_mode') }}"

- alias: Heatpump Mode Off
  trigger:
    platform: state
    entity_id: input_select.heatpump_mode
    to: 'Off'
  action:
    - service: mqtt.publish
      data:
        topic: "b4e62d65a99f/HP/SET/2201"
        payload: "0.00"

- alias: Heatpump Mode Auto
  trigger:
    platform: state
    entity_id: input_select.heatpump_mode
    to: 'Auto'
  action:
    - service: mqtt.publish
      data:
        topic: "b4e62d65a99f/HP/SET/2201"
        payload: "1.00"

- alias: Heatpump Mode Varmt Vand
  trigger:
    platform: state
    entity_id: input_select.heatpump_mode
    to: 'Varmt Vand'
  action:
    - service: mqtt.publish
      data:
        topic: "b4e62d65a99f/HP/SET/2201"
        payload: "4.00"   `Preformatted text`