gw.request() and domoticz - problem with get V_DISTANCE



  • Hey !
    I have a problem with receiving from the controller Domoticz (V2.3799) the V_DISTANCE by gw.request()
    MySensors is 1.5 - Latest Release.

    I wrote a short test program that shows a problem.

    #include <SPI.h>
    #include <MySensor.h>  
    
    #define CHILD_ID 1                              // Id of the sensor child
    MySensor gw;
    MyMessage msg(CHILD_ID, V_DISTANCE);
    MyMessage msg2(CHILD_ID, V_VAR1);
    unsigned long SEND_FREQUENCY = 3000;  // 1 sekunda = 1000;
    
    void setup()
    {
    	gw.begin(incomingMessage);
    	gw.sendSketchInfo("Test", "1.1");
    	gw.present(CHILD_ID, S_DISTANCE);
    }
    
    void loop()
    {
    	gw.process();
    	gw.request(CHILD_ID, V_DISTANCE, 0);
    	gw.request(CHILD_ID, V_VAR1, 0);
    		delay(2000);
    			gw.send(msg.set(0));
    		delay(2000);
    			gw.send(msg2.set(1));
    		delay(2000);
    	gw.sleep(SEND_FREQUENCY);
    }
    
    void incomingMessage(const MyMessage &message) {
    	if (message.type == V_VAR1) {
    		Serial.println("Received V_VAR1 from gw ");
    	}
    	if (message.type == V_DISTANCE) {
    	Serial.println("Received V_DISTANCE from gw ");
    	}
    	Serial.println("incomingMessage");
    }
    

    I do not know why I get message for V_VAR1 and didnt get for V_DISTANCE. ?
    And short LOG from my node here:

    Opening port
    Port open
    find parent
    send: 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,st=bc:
    read: 0-0-255 s=255,c=3,t=8,pt=1,l=1,sg=0:0
    parent=0, d=1
    req id
    send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,sg=0,st=ok:
    read: 0-0-255 s=255,c=3,t=4,pt=0,l=2,sg=0:20
    send: 20-20-0-0 s=255,c=0,t=17,pt=0,l=3,sg=0,st=fail:1.5
    send: 20-20-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
    read: 0-0-20 s=255,c=3,t=6,pt=0,l=1,sg=0:M
    id=20
    send: 20-20-0-0 s=255,c=0,t=17,pt=0,l=3,sg=0,st=ok:1.5
    send: 20-20-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
    read: 0-0-20 s=255,c=3,t=6,pt=0,l=1,sg=0:M
    sensor started, id=20, parent=0, distance=1
    send: 20-20-0-0 s=255,c=3,t=11,pt=0,l=4,sg=0,st=ok:Test
    send: 20-20-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.1
    send: 20-20-0-0 s=1,c=0,t=15,pt=0,l=0,sg=0,st=ok:
    send: 20-20-0-0 s=1,c=2,t=13,pt=0,l=0,sg=0,st=ok:
    send: 20-20-0-0 s=1,c=2,t=24,pt=0,l=0,sg=0,st=ok:
    send: 20-20-0-0 s=1,c=1,t=13,pt=2,l=2,sg=0,st=ok:0
    send: 20-20-0-0 s=1,c=1,t=24,pt=2,l=2,sg=0,st=ok:1
    read: 0-0-20 s=1,c=2,t=24,pt=0,l=0,sg=0:
    Received V_VAR1 from gw
    incomingMessage
    send: 20-20-0-0 s=1,c=2,t=13,pt=0,l=0,sg=0,st=ok:
    send: 20-20-0-0 s=1,c=2,t=24,pt=0,l=0,sg=0,st=ok:
    send: 20-20-0-0 s=1,c=1,t=13,pt=2,l=2,sg=0,st=ok:0
    send: 20-20-0-0 s=1,c=1,t=24,pt=2,l=2,sg=0,st=ok:1
    read: 0-0-20 s=1,c=2,t=24,pt=0,l=1,sg=0:1
    Received V_VAR1 from gw 
    incomingMessage
    send: 20-20-0-0 s=1,c=2,t=13,pt=0,l=0,sg=0,st=ok:
    send: 20-20-0-0 s=1,c=2,t=24,pt=0,l=0,sg=0,st=ok:
    send: 20-20-0-0 s=1,c=1,t=13,pt=2,l=2,sg=0,st=ok:0
    send: 20-20-0-0 s=1,c=1,t=24,pt=2,l=2,sg=0,st=ok:1
    
    Port closed
    

    I dont know why i get only message for V_VAR1 and I didnt get for V_DISTANCE. ?


  • Admin

    You're issuing a gw.sleep(). That shuts down the radio thus no incoming data.



  • Thx for quick answer Hek !.
    I comment this line

    	//gw.sleep(SEND_FREQUENCY);
    

    upload sketch by still no have log from "V_DISTANCE". Any other idea ?


  • Admin

    Use gw.wait(2000) instead of delay()



  • Hi !.
    Sure next sketch I will use. But the problem looks like it is elsewhere.
    I found that if i change in this sketch

    • S_DISTANCE -> S_LIGHT
    • V_DISTANCE -> V_LIGHT

    its works ! 😃 Maybe just this type (V_DISTANCE) is not supported in Domoticz and gw.request() (?)

    So now I will start a little more test. I'm going to check other types.



  • .. after some tests. If Im not wrong only few messages / variables - is support by gw.request() and domoticz.
    I used sketch belowe to tests, and i found only supports for:

    • S_LIGHT / V_LIGHT
    • S_DIMMER / V_DIMMER
    • S_BINARY / V_LIGHT
    • S_BINARY / V_STATUS

    My check list is in this sketch for tests in section comments

    #include <SPI.h>
    #include <MySensor.h>  
    #include <EEPROM.h>  
    
    /*  list of checked types /variables */
    
    /* supported by domoticz and gw.request -> type/variable:
    	S_LIGHT / V_LIGHT 
    	S_DIMMER / V_DIMMER 
    	S_BINARY / V_LIGHT
    	S_BINARY / V_STATUS
    */
    /* NOT supported by domoticz and gw.request -> type/variable:
    	S_DOOR / V_TRIPPED
    	S_MOTION / V_TRIPPED
    	S_DISTANCE / V_DISTANCE 
    	S_TEMP / V_TEMP 
    	S_BINARY / V_WATT
    	S_HUM / V_HUM
    	S_WIND / V_WIND
    	S_POWER / V_KWH
    */
    
    #define CHILD_ID 1                  // Id of the sensor child
    
    #define S_type   S_LIGHT      // here change type 
    #define V_type   V_LIGHT   		// here change variable 
    
    int clearEEPROM = 1;				// if required reset memory change for 1 
    
    MySensor gw;
    MyMessage msg(CHILD_ID, V_type);
    unsigned long SEND_FREQUENCY = 1000;  // 1 sec = 1000;
    
    void setup()
    {
    	if (clearEEPROM == 1) {
    		Serial.println("Reset EEPROM");
    		ClearEEPROM();
    		clearEEPROM = 0;
    	}
    
    	gw.begin(incomingMessage);
    	gw.sendSketchInfo("Test", "1.1");
    	gw.present(CHILD_ID, S_type);
    }
    
    void loop()
    {
    	gw.process();
    	gw.request(CHILD_ID, V_type, 0);
    	gw.wait(1000);
    	gw.send(msg.set(0));
    	gw.wait(1000);
    	gw.sleep(SEND_FREQUENCY);
    }
    
    void incomingMessage(const MyMessage &message) {
    	if (message.type == V_type) {
    		Serial.println("Received from gw ");
    	}
    	Serial.println("incomingMessage");
    }
    
    void ClearEEPROM()
    {
    	Serial.println("Clearing EEPROM");
    	for (int i = 0;i<512;i++) {
    		EEPROM.write(i, 0xff);
    	}
    	Serial.println("Cleared EEPROM");
    }
    
    

  • Hero Member

    @Eoreh you found out the hard way.. Domoticz only supports actuators with gw.request exception is V_TEXT (development) an the new CUSTOM type..


Log in to reply
 

Suggested Topics

16
Online

11.4k
Users

11.1k
Topics

112.7k
Posts