Get mqtt value from motion detector, if occupancy is ON or OFF

links i use

When I set my Smart Button i do like this, and it work -->

"mqtt in node"
zigbee2mqtt/Hue Dimmer - Vitus/action

When I try whit my PH motion sensor I have try whit /get but it dont work?

zigbee2mqtt/MotionSensor/get

If I try
zigbee2mqtt/MotionSensor/#

I get a list off objekt
-object
battery: 100
illuminance: 25581
illuminance_lux: 361
led_indication: null
linkquality: 52
motion_sensitivity: "high"
occupancy: false
occupancy_timeout: 0
temperature: 24.35

how do I get "occupancy: false" out as payload ?

There’s a great page in the docs (Working with messages : Node-RED) that will explain how to use the debug panel to find the right path to any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

BX00Cy7yHi

Im sorry. I cant get it to work.

I see the part is payload.occupancy, but I dont get where and how to put it in a node

Just send the msg into a change node like this

ahh.. Thx alot

now it work

hmm...

I dont understand why this dont work.

[{"id":"606fbab317657e8f","type":"debug","z":"fb88cea7421b6512","name":"debug 9","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":840,"y":1800,"wires":[]},{"id":"b02dc8d4f8a27890","type":"mqtt in","z":"fb88cea7421b6512","name":"Bevægelsessensor Indendørs Stue","topic":"zigbee2mqtt/Bevægelsessensor Indendørs Stue/#","qos":"2","datatype":"auto-detect","broker":"711011c119463c3b","nl":false,"rap":true,"rh":0,"inputs":0,"x":180,"y":1820,"wires":[["4be81d97b9a99749"]]},{"id":"4be81d97b9a99749","type":"change","z":"fb88cea7421b6512","name":"occupancy","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.occupancy","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":1820,"wires":[["1a6ed8fe17ba8d64"]]},{"id":"1a6ed8fe17ba8d64","type":"switch","z":"fb88cea7421b6512","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"true","vt":"str"},{"t":"eq","v":"false","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":630,"y":1820,"wires":[["606fbab317657e8f"],["dd886caee32ab68b"]]},{"id":"dd886caee32ab68b","type":"debug","z":"fb88cea7421b6512","name":"debug 10","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":840,"y":1840,"wires":[]},{"id":"711011c119463c3b","type":"mqtt-broker","name":"MQTT Broker","broker":"192.168.1.106","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]

You need to add a change node and then your switch needs to look for true or false

image

You need to edit your switch node for Boolean true / false rather than the string "true"

image

Thx to @smcgann99 and @ScheepersJohan

I got it to work.

Here are the solution, I use.

[{"id":"73f8f43c36f461d3","type":"mqtt in","z":"fb88cea7421b6512","name":"Bevægelsessensor Badeværelse","topic":"zigbee2mqtt/Bevægelsessensor Badeværelse/#","qos":"2","datatype":"auto-detect","broker":"711011c119463c3b","nl":false,"rap":true,"rh":0,"inputs":0,"x":170,"y":1940,"wires":[["f2013d666b0a18d2"]]},{"id":"f2013d666b0a18d2","type":"change","z":"fb88cea7421b6512","name":"occupancy","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.occupancy","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":1940,"wires":[["3d0918d628d76992"]]},{"id":"3d0918d628d76992","type":"switch","z":"fb88cea7421b6512","name":"","property":"payload","propertyType":"msg","rules":[{"t":"false"},{"t":"true"}],"checkall":"true","repair":false,"outputs":2,"x":650,"y":1940,"wires":[["85f542b4dcbaee10"],["57a5b288c83bfcbf"]]},{"id":"85f542b4dcbaee10","type":"debug","z":"fb88cea7421b6512","name":"false","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":790,"y":1920,"wires":[]},{"id":"57a5b288c83bfcbf","type":"debug","z":"fb88cea7421b6512","name":"true","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":790,"y":1960,"wires":[]},{"id":"711011c119463c3b","type":"mqtt-broker","name":"MQTT Broker","broker":"192.168.1.106","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]

I set the occupancy time under zigbee2mqtt -->

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.