Room Occupancy Counter
A simple flow, designed for mobile phones, to count people in and out of a room. Our room had a one-way system, so we needed someone incrementing at the entrance and another person decrementing at the exit. This solution was perfect - very simple yet updating in real time.
Dependencies
- Dashboard
- MQTT (optional)
Settings
Modify the Gauge node settings for the maximum occupancy along with colour change knee points.
MQTT is not needed, but allows monitoring elsewhere if required.
Usage
Press the green buttons to increment the count (use the 1,2,3 or 4 to speed up entry), and the red buttons for decrementing.
Screenshot
[{"id":"49c962ed.f62aec","type":"ui_button","z":"6139c773.abcd48","name":"","group":"111fcd9b.8f4622","order":3,"width":"4","height":"2","passthru":true,"label":"+1","tooltip":"","color":"","bgcolor":"#008000","icon":"","payload":"1","payloadType":"num","topic":"","x":270,"y":200,"wires":[["ecd88a4.ba8c578"]]},{"id":"69a7bf35.3ee74","type":"ui_button","z":"6139c773.abcd48","name":"","group":"111fcd9b.8f4622","order":5,"width":"4","height":"2","passthru":true,"label":"+2","tooltip":"","color":"","bgcolor":"#008000","icon":"","payload":"2","payloadType":"num","topic":"","x":270,"y":240,"wires":[["ecd88a4.ba8c578"]]},{"id":"a0500217.145a3","type":"ui_button","z":"6139c773.abcd48","name":"","group":"111fcd9b.8f4622","order":7,"width":"4","height":"2","passthru":true,"label":"+3","tooltip":"","color":"","bgcolor":"#008000","icon":"","payload":"3","payloadType":"num","topic":"","x":270,"y":280,"wires":[["ecd88a4.ba8c578"]]},{"id":"539b2d28.3fd574","type":"ui_button","z":"6139c773.abcd48","name":"","group":"111fcd9b.8f4622","order":9,"width":"4","height":"2","passthru":true,"label":"+4","tooltip":"","color":"","bgcolor":"#008000","icon":"","payload":"4","payloadType":"num","topic":"","x":270,"y":320,"wires":[["ecd88a4.ba8c578"]]},{"id":"10bf6641.b30c4a","type":"ui_button","z":"6139c773.abcd48","name":"","group":"111fcd9b.8f4622","order":2,"width":"4","height":"2","passthru":true,"label":"-1","tooltip":"","color":"","bgcolor":"#800000","icon":"","payload":"-1","payloadType":"num","topic":"","x":270,"y":360,"wires":[["ecd88a4.ba8c578"]]},{"id":"370f07c1.4494d8","type":"mqtt out","z":"6139c773.abcd48","name":"","topic":"room-count","qos":"","retain":"true","broker":"400bd9c0.f199b8","x":790,"y":340,"wires":[]},{"id":"ecd88a4.ba8c578","type":"function","z":"6139c773.abcd48","name":"Adjust count, min 0","func":"var count=flow.get(\"room-count\");\ncount += msg.payload;\ncount = Math.max(count,0);\nflow.set(\"room-count\", count);\nmsg.payload=count;\nnode.status({fill:\"blue\",shape:\"dot\",text: msg.payload});\nreturn msg;","outputs":1,"noerr":0,"x":540,"y":340,"wires":[["370f07c1.4494d8","82bc9079.eedec"]]},{"id":"8d77ba89.757718","type":"inject","z":"6139c773.abcd48","name":"Power on reset","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":560,"y":220,"wires":[["764903b1.1d2b8c","370f07c1.4494d8","82bc9079.eedec"]]},{"id":"764903b1.1d2b8c","type":"function","z":"6139c773.abcd48","name":"Reset Variable","func":"flow.set(\"room-count\", msg.payload);\nnode.status({fill:\"blue\",shape:\"dot\",text: msg.payload});\nreturn msg;","outputs":1,"noerr":0,"x":800,"y":220,"wires":[[]]},{"id":"82bc9079.eedec","type":"ui_gauge","z":"6139c773.abcd48","name":"Occupancy","group":"111fcd9b.8f4622","order":1,"width":"8","height":"4","gtype":"gage","title":"","label":"people","format":"{{value}}","min":0,"max":"20","colors":["#00b500","#e6e600","#ca3838"],"seg1":"12","seg2":"18","x":790,"y":280,"wires":[]},{"id":"dd04de43.35fa2","type":"ui_button","z":"6139c773.abcd48","name":"","group":"111fcd9b.8f4622","order":4,"width":"4","height":"2","passthru":true,"label":"-2","tooltip":"","color":"","bgcolor":"#800000","icon":"","payload":"-2","payloadType":"num","topic":"","x":270,"y":400,"wires":[["ecd88a4.ba8c578"]]},{"id":"30b17709.281c48","type":"ui_button","z":"6139c773.abcd48","name":"","group":"111fcd9b.8f4622","order":6,"width":"4","height":"2","passthru":true,"label":"-3","tooltip":"","color":"","bgcolor":"#800000","icon":"","payload":"-3","payloadType":"num","topic":"","x":270,"y":440,"wires":[["ecd88a4.ba8c578"]]},{"id":"383f0cae.da0474","type":"ui_button","z":"6139c773.abcd48","name":"","group":"111fcd9b.8f4622","order":8,"width":"4","height":"2","passthru":true,"label":"-4","tooltip":"","color":"","bgcolor":"#800000","icon":"","payload":"-4","payloadType":"num","topic":"","x":270,"y":480,"wires":[["ecd88a4.ba8c578"]]},{"id":"111fcd9b.8f4622","type":"ui_group","z":"","name":"Room Count","tab":"21b9023d.80367e","order":1,"disp":false,"width":"8","collapse":false},{"id":"400bd9c0.f199b8","type":"mqtt-broker","z":"","broker":"172.16.106.1","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"10","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","willTopic":"","willQos":"0","willRetain":"false","willPayload":""},{"id":"21b9023d.80367e","type":"ui_tab","z":"","name":"Room Occupancy Counter","icon":"dashboard","disabled":false,"hidden":false}]