@micho111 (Michal) posted a new topic, subject "Scheduling triger alerts for motion sensor". It read:

   Hello cayenne community,  
    I wanted to share idea. I have ESP8266(nodeMCU) connected to motion sensor and it works fine with cayenne. Problem is that i want make schedules so it start to be active only if i leave my home so in certain time in day.If i leave it active24/7 then it alert me every time im walking home whish is useless. I think its not possible with cayenne to schedule triger alerts.  
    BTW anyone have idea if its possible resolve in arduino code?  
    thanks!

@adam (Adam S) replied

    That's a pretty good idea. You can definitely do it in Arduino code but it would get a bit complicated. Ideally you would need a real time clock module, but syncing with an NTP server would be ok. In the main loop use code like if time of day is right then run the cayenne loop else do nothing.

To which @adrien.testas (Adrien Testas) replied

    Hello ! i find some solution !
    
    When i cabling motion sensor i put 5V on a relay, who is command by one GPIO. I make widget for turn on or off this GPIO, like this i can turn on or off when i want (:

So @shramik_salgaonkar (Shramik salgaonkar) replied

    @adrien.testas there is another way. add a button widget with virtual pin 2.  
    then read the status.  
    int x;  
    int y;  
    if (millis() - lastMillis1 > 10000)  
    {  
    lastMillis1 = millis();  
    Cayenne.virtualWrite(3, y, “digital_sensor”, “d”);  
    }  
    if (x == 1)  
    {  
    y = digitalRead(motionPin);  
    }  
    else  
    {  
    y = 0;  
    }  
    CAYENNE_IN(2)  
    {  
    int currentValue = getValue.asInt();  
    if (currentValue == 1)  
    {  
    x = 1;  
    }  
    else  
    {  
    x = 0;  
    }  
    }


{'source': 'discourse', 'url': 'https://community.mydevices.com/t/scheduling-triger-alerts-for-motion-sensor/2346', 'title': 'Scheduling triger alerts for motion sensor', 'views': 1678, 'has_accepted_answer': False, 'word_count': 248, 'like_count': 2, 'reply_count': 2, 'participant_count': 4, 'posts': 4, 'tags': '', 'author': '@micho111 (Michal)', 'participants': '@micho111 (Michal), @adam (Adam S), @adrien.testas (Adrien Testas), @shramik_salgaonkar (Shramik salgaonkar)', 'image_url': [None], 'created_at': '2017-02-23T04:04:28.471Z', 'last_posted_at': '2017-10-27T06:10:29.306Z'}