The On/Off State Widget in the Dashboard behaves strange

I have added a simple On/Off State Widget in the Dashboard to control the relay on my Sonoff device.
If I try to set the Widget to On it immediately goes back to Off (and the relay also goes On to Off).

I get the same “on then immediately off” behaviour if I trigger a Web Request from IFTTT Maker channel to turn the relay On.

However if I control the relay through the API Explorer everything works as it should.

What am I doing wrong?

Hi! How the resource is defined the sketch? Will check that in my own device meanwhile!

I think that you are defining the resource like the stock Arduino example, that is no well suited for dashboards. Will update the examples soon using the latest improvements as announced in Arduino Client Libraries 2.1.0

Try defining your relay something like that: (D1 is my digital pin)

thing["relay"] << digitalPin(D1);

This will define an input resource, for controlling a digital pin. But it will also allow reading the pin state for dashboards. This way, if IFTTT calls your relay, and you are connected to the dashboard, you should see how the IFTTT updates the relay state to on or off.


Thanks, that solved my issue.

I replaced the original resource definition

thing["relay"] << [](pson& in){ digitalWrite(RELAY, in ? HIGH : LOW);};

with your proposal

thing["relay"] << digitalPin(RELAY);

Now the Dashboard control and IFTTT recipe works like a charm :slightly_smiling:

Glad to hear you get it working!! :slight_smile:

Are you developing some interesting project? What is triggering the IFTTT to turn on/off your relay? Just curious :sunglasses:

Current project will turn on the front porch light when i’m nearing my home.
I use the Android Location channel to trigger IFTTT events and a hacked Sonoff device for the light control.

But I’m really just playing around with the possibilities at the moment. :sunglasses:


Great! It sounds interesting, or cool at least! :slight_smile:

Hi, my project is with raspberry Pi 3 B+ and a relay. I got the same problem in Dashboard that the Widget goes back to Off at once when I turn it to On however the Device API works really perfect. Can anybody help me about it.
My main.cpp:

#include "thinger/thinger.h"
#include <wiringPi.h>

#define USER_ID             "myuserid"
#define DEVICE_ID           "RPI001"
#define DEVICE_CREDENTIAL   "rpi001-led"

#define LED_PIN 0 //GPIO17

int main(void)
    thinger_device thing(USER_ID, DEVICE_ID, DEVICE_CREDENTIAL);


        pinMode(LED_PIN, OUTPUT);

    thing["light"] << [](pson & in){
                digitalWrite(LED_PIN, in ? HIGH:LOW);
                        digitalWrite(LED_PIN, LOW);
                        digitalWrite(LED_PIN, HIGH);

    return 0;

I replaced relay with servo, but i’ve problem. Anyone help me with please…?