Motion Node not correctly recognized

Subforum for the 'MySensors' project.
http://www.mysensors.org/
Post Reply
coolnicklas
Posts: 2
Joined: Tuesday 20 June 2017 13:32
Target OS: -
Domoticz version:
Contact:

Motion Node not correctly recognized

Post by coolnicklas » Tuesday 20 June 2017 13:46

Hi,

I'm using MySensors with the ESP8266 Wifi gateway. I have added a Temp/Hum node which shows up nicely in Domoticz but my motion sensor is identified as a "Lightning 2" Type sensor with subtype "AC".

My intention is to add one or several relay switch nodes which shall be switched on/off when motion is detected.

Since the motion sensor node is not identified correctly, I can't create an "if -do" Control event. Any suggestions how to move forward?
Thanks
Nicklas

User avatar
emme
Posts: 644
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Motion Node not correctly recognized

Post by emme » Tuesday 20 June 2017 15:26

can you post the node code?
That's one small step for a programmer, one giant leap for me!
- - - - -
Raspberry Pi3 + AeonStick G5 + RFXCOMM433 + iRTrans Server + NodeJS
There's no stress in the mess!!

coolnicklas
Posts: 2
Joined: Tuesday 20 June 2017 13:32
Target OS: -
Domoticz version:
Contact:

Re: Motion Node not correctly recognized

Post by coolnicklas » Tuesday 20 June 2017 17:33

Pretty much straight out of the box from the MySensor example

Code: Select all

/**
// Enable debug prints
// #define MY_DEBUG

// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69

#include <MySensors.h>

unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
#define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
#define CHILD_ID 1   // Id of the sensor child

// Initialize motion message
MyMessage msg(CHILD_ID, V_TRIPPED);

void setup()
{
    Serial.println("setting up");
    pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
}

void presentation()
{
    Serial.println("presentation");
    // Send the sketch version information to the gateway and Controller
    sendSketchInfo("Motion Sensor", "1.0");

    // Register all sensors to gw (they will be created as child devices)
    present(CHILD_ID, S_MOTION);
}

void loop()
{
    // Read digital motion value
    bool tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH;

    Serial.println(tripped);
    send(msg.set(tripped?"1":"0"));  // Send tripped value to gw

    // Sleep until interrupt comes in on motion sensor. Send update every two minute.
    sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);
}

User avatar
emme
Posts: 644
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Motion Node not correctly recognized

Post by emme » Tuesday 20 June 2017 17:43

Motion in mysensor library is handled as v_tripped (On/Off) and V_ARMED (quite useless in this scenario)
yes... it is handled as an ON/OFF switch but you have to ensure if the sensor works as low=1=On and high=0=Off...
if so you will have the switch OFF in motion and ON when not in motion....

to change this you can easly change the line
send(msg.set(tripped?"1":"0"));
to
send(msg.set(tripped?"0":"1"));

another issue is the SLEEP_TIME setted to 2mins... so the device does not send any status after 2 mons from the last sent
maybe set it from 120000 to 5000 (5 secs)
ciao
M
That's one small step for a programmer, one giant leap for me!
- - - - -
Raspberry Pi3 + AeonStick G5 + RFXCOMM433 + iRTrans Server + NodeJS
There's no stress in the mess!!

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest