Function node to manually activate aqara smoke alarm buzzer

I have an Aqara smoke alarm where I want to use the buzzer as a siren for my alarm.

It should be possible to activate the buzzer manually,

To write (/set) a value publish a message to topic zigbee2mqtt/FRIENDLY_NAME/set with payload {"buzzer": NEW_VALUE}. The possible values are: mute, alarm

I need to do this with a function but cant figure out how to get this working.

I thought it was as simple as adding this in function node:

msg.payload = {"buzzer": alarm}
return msg;

and then send it to a mqtt exit node which have a zigbee2mqtt/FRIENDLY_NAME/set topic.

but somehow that doesnt work.
What am I doing wrong?

figured it out

needed ' '

msg.payload = {"buzzer": 'alarm'}
return msg;

Why don't you use a Change node instead of a Function?

I'm using bit of boths.
But my functions are simple, since I'm no good a programming.
But got a working alarm system up and running:

main remotes and notifications

Smoke detectors & using them for alarm sirens too


motion

door

Dashboard (danish)