Alarm mode - 2 questions

Ok, ‹ -state › was missing in the code
gladys/device/mqtt:sirene_1/feature/mqtt:sirene_1/state
=>
gladys/device/mqtt:sirene_1/feature/mqtt:sirene_1-state/state

replace the code with

var inputTopic = msg.topic;
var inputPayload = msg.payload;

// Logic to change the topic and payload based on both the input topic and payload

// ****************************************************************************************************************************/
if (inputTopic === "gladys/device/mqtt:sirene_1/feature/mqtt:sirene_1-state/state" && inputPayload === "0") {
  // adaptation of the topic and payload from Gladys to zigbee2mqtt 
  msg.topic = "zigbee2mqtt/Sirène_1/set";
  msg.payload = {
    warning: {
      mode: "emergency",       // mode              : stop, burglar, fire, emergency, police_panic, fire_panic, emergency_panic
      level: "high",           // level             : low, medium, high, very_high
      strobe_level: "high",    // strobe_level      : low, medium, high, very_high
      strobe: "true",          // strobe            : true, false 
      strobe_duty_cycle: "5",  // strobe_duty_cycle : 1 to 10
      duration: "10"           // duration          : duration in seconds
    }
  };
}
// ****************************************************************************************************************************/

// ****************************************************************************************************************************/
if (inputTopic === "gladys/device/mqtt:sirene_1/feature/mqtt:sirene_1-state/state" && inputPayload === "1") {
  // adaptation of the topic and payload from Gladys to zigbee2mqtt 
  msg.topic = "zigbee2mqtt/Sirène_1/set"; 
  msg.payload = {
    warning: {
      mode: "emergency",       // mode              : stop, burglar, fire, emergency, police_panic, fire_panic, emergency_panic
      level: "high",           // level             : low, medium, high, very_high
      strobe_level: "high",    // strobe_level      : low, medium, high, very_high
      strobe: "true",          // strobe            : true, false 
      strobe_duty_cycle: "5",  // strobe_duty_cycle : 1 to 10
      duration: "10"           // duration          : duration in seconds
    }
  }; 
}
// ****************************************************************************************************************************/
return msg;

There was a ’ that had slipped in front of the 1st line of code, I fixed it in the message above, you need to replace the code again, sorry :wink:

Can you redo the test and include a screenshot (at 100% it’s more readable) of the debug output (remember to clear it first), please?

There was one at the end too!!! (I had put it between quote ’ ’ at the start
image
then
image
the quotes stayed :woozy_face:
I’ve modified it so paste it back! sorry again …we’ll get there :blush:

same for the payload click on the arrow to the left to expand and recapture
But it’s rather positive this indicates that your MQTT settings seem to be good on both sides :+1:

So which one do I copy?

I retrieved the one above that you must have modified:

Here is the debug

paste this one

That’s right

Debug:

so the toggle part of your device is good and it sends the correct messages
now enable the 2nd debug, redeploy the flow and redo the toggle action, then send the debug trace with the messages expanded and having cleared the debug beforehand

You didn’t expand the payload, so I can’t see what it’s sending :wink:

Sorry, I hadn’t seen the second little arrow :roll_eyes:

no big deal :blush:
That didn’t trigger the alarm, I suppose?
So the message is being sent correctly — if the siren name on the Zigbee2Mqtt side is correct, then it’s probably the message content that’s not right.

I think it’s the « strobe », the « strobe_duty_cycle » and the « duration » that are not correct
try setting them to:

  strobe: true,          // strobe            : true, false 
  strobe_duty_cycle: 5,  // strobe_duty_cycle : 1 to 10
  duration: 60           // duration          : duration in sec

or copy the code

var inputTopic = msg.topic;
var inputPayload = msg.payload;

// Logic to change the topic and payload depending on both the input topic and input payload

// published by gladys : "gladys/master/device/mqtt:" + "Sirène_1" "/feature/mqtt:" + "sirène_1-state" "/state"
// listened to by gladys : "gladys/device/mqtt:" + "Sirène_1" "/feature/mqtt:" + "sirène_1-state" "/state"

// ****************************************************************************************************************************/
if (inputTopic === "gladys/device/mqtt:sirene_1/feature/mqtt:sirene_1-state/state" && inputPayload === "0") {
  // adaptation of Gladys topic and payload to zigbee2mqtt 
  msg.topic = "zigbee2mqtt/Sirène_1/set";
  msg.payload = {
    warning: {
      mode: "emergency",       // mode              : stop, burglar, fire, emergency, police_panic, fire_panic, emergency_panic
      level: "high",           // level             : low, medium, high, very_high
      strobe_level: "high",    // strobe_level      : low, medium, high, very_high
      strobe: true,          // strobe            : true, false 
      strobe_duty_cycle: 5,  // strobe_duty_cycle : 1 to 10
      duration: 10           // duration          : duration in sec
    }
  };
}
// ****************************************************************************************************************************/

// ****************************************************************************************************************************/
if (inputTopic === "gladys/device/mqtt:sirene_1/feature/mqtt:sirene_1-state/state" && inputPayload === "1") {
  // adaptation of Gladys topic and payload to zigbee2mqtt 
  msg.topic = "zigbee2mqtt/Sirène_1/set"; 
  msg.payload = {
    warning: {
      mode: "emergency",       // mode              : stop, burglar, fire, emergency, police_panic, fire_panic, emergency_panic
      level: "high",           // level             : low, medium, high, very_high
      strobe_level: "high",    // strobe_level      : low, medium, high, very_high
      strobe: true,          // strobe            : true, false 
      strobe_duty_cycle: 5,  // strobe_duty_cycle : 1 to 10
      duration: 10           // duration          : duration in sec
    }
  }; 
}
// ****************************************************************************************************************************/

return msg;

again the payload and the warning :crazy_face:

and I just saw that in the code at line 15 the 1st mode was set to « emergency » it needs to be changed to « stop »

![image|690x121](upload://1PEK2KezRbsk8DWB4DkE4

sorry…

That’s what you call a botched copy :blush:

Oops, it’s for me :melting_face: