sinricpro / esp8266-esp32-sdk

Library for https://sinric.pro - simple way to connect your device to Alexa, Google Home, SmartThings and cloud
https://sinric.pro
227 stars 121 forks source link

device turns off for on and on for off what changes should i make in the onPowerstate #372

Closed Vedant573 closed 3 months ago

Vedant573 commented 3 months ago

bool onPowerState(String deviceId, bool &state) { Serial.printf("%s: %s\r\n", deviceId.c_str(), state ? "off" : "on"); int relayPIN = devices[deviceId].relayPIN; // get the relay pin for corresponding device digitalWrite(relayPIN, !state); // set the new relay state return true; }

what should i change in above code?

sivar2311 commented 3 months ago

Remove the "!" from "!state" :

digitalWrite(relayPIN, state);

Vedant573 commented 3 months ago

Thank you so much its working now!!