Cannot find simple open/close script

I am having troubel finding a simple way to do an open/closed loop script to make a magnetic door sensor ( alarm type ) that is NO to show up Closed then Show up open then the connection is broke ( door open ) so I can use that digital switch to make cayenne trigger other stuff when the door gets opened.

you can use this script to read the door sensor switch state and send it to cayenne Cayenne-MQTT-Arduino/GenericDigitalInput.ino at master · myDevicesIoT/Cayenne-MQTT-Arduino · GitHub

I have a raspberry pi, do you have the code for pi it just says arduino on there.

you can either use cayenne agent or use cayenne python library to send data to cayenne GitHub - myDevicesIoT/Cayenne-MQTT-Python: Python Library for Cayenne MQTT API and add Buttons and Switches - Physical Computing with Raspberry Pi to read button state.