@sdetweil Yeah you’re right, that one might be more difficult. But I do have MMM-ModuleToggleButton working with pinctrl. Here’s the updated node_helper.js file just in case anyone’s interested.
node_helper.js
const NodeHelper = require('node_helper'); // eslint-disable-line import/no-extraneous-dependencies //const Gpio = require('onoff').Gpio; const { exec } = require("child_process"); module.exports = NodeHelper.create({ start() { this.started = false; }, socketNotificationReceived(notification, payload) { if (notification === 'TOGGLE_BUTTON_CONFIG' && !this.started) { const self = this; this.config = payload; //const button = new Gpio(this.config.buttonGpioPin, 'in', 'both', { persistentWatch: true, debounceTimeout: this.config.debounceTimeoutInMilliseconds }); //button.watch((err, state) => { // if (state === 1) { // self.sendSocketNotification(self.config.notificationName, true); // } //}); //this.started = true; // Set up GPIO as input using pinctrl command const pin = this.config.buttonGpioPin; const debounceTimeout = this.config.debounceTimeoutInMilliseconds; const notificationName = this.config.notificationName; let lastState = null; // Function to read the pin state using pinctrl const checkPinState = () => { exec(`pinctrl get ${pin}`, (err, stdout, stderr) => { if (err) { console.error(`Error reading GPIO state: ${err.message}`); return; } // Parse the pin state from stdout const state = stdout.includes("hi") ? 1 : 0; // Handle state change with debounce if (state !== lastState && state === 1) { this.sendSocketNotification(notificationName, true); } // Update last state lastState = state; }); }; // Set up an interval to check the pin state with debounce setInterval(checkPinState, debounceTimeout || 100); // Defaults to 100ms if debounce is not defined } } });