Aircoookie/Espalexa

Simple problem

Closed this issue · 2 comments

Hi guys,

I have a problem... i just need to turn on/off my device, however i just know how to do it on FauxmoESP.

An example: I need to turn on/off a light, on the fauxmoESP i just define the relay/lamp pin and use the "state" function to turn on/off the relay/lamp by the digitalWrite function.

How can i do it on the espalexa code? Does the espalexa have a function to "check" the state?

Thanks in advance.

Hi!
Yes, just use an EspalexaDevice object like device3 in the EspalexaBasic example.
Then you can use device->getValue(). If the device is off, this will be 0, so you can just do bool isOn = device->getValue() :)

Oh god, thanks 👍