Global varies to count the number of times open/close the door

Global varies to count the number of times open/close the door.
How do in smartthings api, code,…?

Initialstate. Easiest.

Or the Google sheets solution.

Or try CoRE.

The only Global variable (well… scoped to the SmartApp Instance or Device Handler Instance) is the pre-defined map, state.* (also referenced by atomicState).

See the developer docs!

For Location scoped attributes, you can use Virtual Device instances and update them with sendEvent().

https://artik.cloud/ has ST integration and monitoring. If its a high traffic you may need to pay ($2 a month for every 10 seconds event).

Its free to try out. Just discovered it today and its easy to integrate through the Samsung SmartApp. Not sure if it will meet your needs.