Alarm mode - 2 questions

@Isage

in the 2nd function node

image

paste this code, it should report the battery level to you, tell me if it works

var inputTopic = msg.topic;
var inputPayload = JSON.parse(msg.payload);

// Names of devices given in Gladys and in Zigbee2Mqtt
var nomAppareilGladys = "Sirène_1";            // nom du device dans Gladys
var nomIdAppareilGladys = "Sirène_1-power";    // nom de l'ID externe de la fonctionnalité
var nomAppareilZ2M = "Sirène_1";                   // nom device dans Zigbee2Mqtt 

// Logic to change the topic and the payload based both on the input topic and input payload
if (msg.topic === "zigbee2mqtt/" + nomAppareilZ2M) {
     
    // if there is the value "state" in the json sent in the payload of zigbee2mqtt
    if (inputPayload.hasOwnProperty('battery')) {
        // adaptation of the Gladys topic to zigbee2mqtt 
        msg.topic = "gladys/device/mqtt:" + nomAppareilGladys + "/feature/mqtt:" + nomIdAppareilGladys + "/text";
        // adaptation of the zigbee2mqtt payload to Gladys 
        var payloadValue = inputPayload.battery;             // to be adjusted
        msg.payload = payloadValue;
    } else {
        // If the 'power' key is not present, set the output to "defaut"
        msg.payload = "defaut";
    }    
}

return msg;

It’s ok

However, how do I trigger the siren?
When I operate this switch, nothing happens

click on the debug node

you should see messages coming in

copy/paste them here after enabling/disabling

Can you take a screenshot of your flow, please
and of the content of your « mqtt » nodes as well

Normally, since the topic is #, the debug listens to all incoming inputs so when you toggle it in Gladys it should output something in the debug

Here’s the debug output when I activate the toggle in Gladys

What’s the address to connect to Gladys? It looks properly connected — if you have another device, like a smart plug, in your MQTT integration you can toggle it once to see if it generates a message in the Node-RED debug.

https://plus.gladysassistant.com/dashboard/

You can’t do it locally for now, I suppose…

192.168.1.57

? can I connect locally; it’s already the case on my iPad, why?

I don’t have anything else besides the siren on MQTT, sorry

To be sure about the IP I didn’t want to miss it just in case, so the parameters on the « Mqtt In » node seem to be correct; you should see messages arriving in the debug when enabling MQTT devices.

When I activate my MQTT device (sirene_1)

I get this message in debug
image

08/11/2023 13:55:05node: 1908d429c1d0cf06

gladys/device/mqtt:sirene_1/feature/mqtt:sirene_1-state/state : msg : Object

{ topic: « gladys/device/mqtt:sirene_1/fe… », payload: « 1 », qos: 0, retain: false, _msgid: « 2fbbc8c085c57ced » }

Good point — something is indeed coming out of the debug!
Can you click the arrow on the left to expand the message and take a screenshot to see the full thread, please?

I don’t see which arrow you’re talking about

The one on the left before the symbol {

sorry

image