MQTT Siren

Hi,

Up to now I’ve always avoided the great pain of trying to figure out the HA templating documentation, but now I have no choice.
I want to configure a siren with multiple tones, but I’m completely lost. I suppose it starts with the cmd and state payload which would be something like

{
   "state":"ON",
   "tone":"motion"
}

or

{
   "state":"ON",
   "tone":"smoke"
}

But then how does the value template look like?
This is my autodiscovery message so far , but I’m unable to fill the blanks.

    _config_msg_siren_json["expire_after"] = _expire_after;
    _config_msg_siren_json["name"] = siren_name;
    _config_msg_siren_json["command_topic"] = siren_command_topic;
    _config_msg_siren_json["state_topic"] = siren_state_topic;
    _config_msg_siren_json["availability_topic"] = _availability_topic;
    _config_msg_siren_json["available_tones"][0] = "motion";
    _config_msg_siren_json["available_tones"][1] = "smoke";
    _config_msg_siren_json["payload_on"] = ;
    _config_msg_siren_json["payload_off"] = ;
    _config_msg_siren_json["state_on"] = ;
    _config_msg_siren_json["state_off"] = ;
    _config_msg_siren_json["state_value_template "] =;
    _config_msg_siren_json["unique_id"] = siren_unique_id;
    _config_msg_siren_json["device"]["identifiers"] = _client_id;
    _config_msg_siren_json["device"]["name"] = _client_name;
    _config_msg_siren_json["device"]["model"] = DEVICE_MODEL;
    _config_msg_siren_json["device"]["sw_version"] = SOFTWARE_VERSION;

If someone could help me with the value template that would be great.

Assuming this is via mqtt (you neglected to say).

You could just define mqtt switches for each tone:

There are examples at the bottom of the page.

Then in your automations it would just be a matter of turning on or off the switch for the tone you want.

I considered that but I wanted to make the most of the siren implementation :slight_smile: (MQTT Siren - Home Assistant). I don’t understand why they made it this difficult, so I agree with you there are better ways. I will go with the simple on/off siren which works fine and then use an MQTT Select for the tone. Thanks for thinking along.

I found that using a service call will provide the option to send the tone (Siren - Home Assistant). It is then send as a key/value pair to the command topic.