Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
ajlisyA

ajlisy

@ajlisy
About
Posts
2
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • request() not working with HomeAssistant
    ajlisyA ajlisy

    When I toggle the switch in HomeAssistant, I do get a V_STATUS update message in receive() and see it print through in the logs.

    So, the toggle itself causes a status message, but I cannot figure out a way to actually poll the status.

    Thanks!

    Home Assistant

  • request() not working with HomeAssistant
    ajlisyA ajlisy

    Hi everyone,

    I've been going crazy trying to figure this one out.

    I have a sketch hooked up to HomeAssistant. The basic sketch just toggles a switch back and forth. The actual sending of the updates works -- as the sketch toggles the switch, I see the switch moving back and forth in the HA UI.

    However, when I try to request the V_STATUS of the switch, I see the message going out through the gateway and onto the MQTT, but I never get anything back. receive() never gets called with a status message.

    I'm currently on the development version of MySensors, but I had the same issue on 2.0. I just switched to development an hour ago to see if that would solve the problem, but alas, it didn't.

    Any thoughts? Thanks in advance

    My Sketch

    // Enable debug prints to serial monitor
    #define MY_DEBUG 
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    
    #include <SPI.h>
    #include <MySensors.h>
    
    #define RELAY_PIN  3  // Arduino Digital I/O pin number for relay 
    #define CHILD_ID 2   // Id of the sensor child
    #define RELAY_ON 0
    #define RELAY_OFF 1
    
    bool state;
    
    MyMessage msg(CHILD_ID,V_STATUS);
    
    void setup()  
    {  
    
      // Make sure relays are off when starting up
      digitalWrite(RELAY_PIN, RELAY_OFF);
      // Then set relay pins in output mode
      pinMode(RELAY_PIN, OUTPUT);   
    }
    
    void presentation()  {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Relay & Button", "1.0");
    
      // Register all sensors to gw (they will be created as child devices)
      present(CHILD_ID, S_BINARY);
    
    
    }
    
    
    int flip = 0;
    void loop() 
    {
      send(msg.set(flip),false);
      flip=flip?0:1;
      wait(5000);
      request(CHILD_ID,V_STATUS);
      wait(2000,C_SET,V_STATUS);
      
    } 
    
    void receive(const MyMessage &message) {
      // We only expect one type of message from controller. But we better check anyway.
      Serial.println("Got a message");
      if (message.isAck()) {
         Serial.println("This is an ack from gateway");
      }
    
      if (message.type == V_STATUS) {
        Serial.println("Got V_STATUS back:");
        Serial.println(message.getBool());
         Serial.print("Incoming change for sensor:");
         Serial.print(message.sensor);
         
         // Change relay state
         state = message.getBool();
         digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF);
    
    
       } 
    }
    

    Gateway log:

    Nov  8 05:31:52 raspberrypi mysGateway: TSF:MSG:READ,1-1-0,s=2,c=2,t=2,pt=0,l=0,sg=0:
    Nov  8 05:31:52 raspberrypi mysGateway: Sending message on topic: mysensors-out/1/2/2/0/2
    Nov  8 05:31:54 raspberrypi mysGateway: TSF:MSG:READ,1-1-0,s=2,c=1,t=2,pt=2,l=2,sg=0:0
    Nov  8 05:31:54 raspberrypi mysGateway: Sending message on topic: mysensors-out/1/2/1/0/2
    Nov  8 05:31:59 raspberrypi mysGateway: TSF:MSG:READ,1-1-0,s=2,c=2,t=2,pt=0,l=0,sg=0:
    Nov  8 05:31:59 raspberrypi mysGateway: Sending message on topic: mysensors-out/1/2/2/0/2
    Nov  8 05:32:01 raspberrypi mysGateway: TSF:MSG:READ,1-1-0,s=2,c=1,t=2,pt=2,l=2,sg=0:1
    Nov  8 05:32:01 raspberrypi mysGateway: Sending message on topic: mysensors-out/1/2/1/0/2
    Nov  8 05:32:06 raspberrypi mysGateway: TSF:MSG:READ,1-1-0,s=2,c=2,t=2,pt=0,l=0,sg=0:
    Nov  8 05:32:06 raspberrypi mysGateway: Sending message on topic: mysensors-out/1/2/2/0/2
    Nov  8 05:32:08 raspberrypi mysGateway: TSF:MSG:READ,1-1-0,s=2,c=1,t=2,pt=2,l=2,sg=0:0
    Nov  8 05:32:08 raspberrypi mysGateway: Sending message on topic: mysensors-out/1/2/1/0/2
    Nov  8 05:32:13 raspberrypi mysGateway: TSF:MSG:READ,1-1-0,s=2,c=2,t=2,pt=0,l=0,sg=0:
    Nov  8 05:32:13 raspberrypi mysGateway: Sending message on topic: mysensors-out/1/2/2/0/2
    Nov  8 05:32:15 raspberrypi mysGateway: TSF:MSG:READ,1-1-0,s=2,c=1,t=2,pt=2,l=2,sg=0:1
    Nov  8 05:32:15 raspberrypi mysGateway: Sending message on topic: mysensors-out/1/2/1/0/2
    Nov  8 05:32:20 raspberrypi mysGateway: TSF:MSG:READ,1-1-0,s=2,c=2,t=2,pt=0,l=0,sg=0:
    Nov  8 05:32:20 raspberrypi mysGateway: Sending message on topic: mysensors-out/1/2/2/0/2
    Nov  8 05:32:22 raspberrypi mysGateway: TSF:MSG:READ,1-1-0,s=2,c=1,t=2,pt=2,l=2,sg=0:0
    Nov  8 05:32:22 raspberrypi mysGateway: Sending message on topic: mysensors-out/1/2/1/0/2
    

    mosquitto_sub:

    Client mosqsub/4008-raspberryp received PUBLISH (d0, q0, r0, m0, 'mysensors-in/1/2/1/0/2', ... (1 bytes))
    mysensors-in/1/2/1/0/2 1
    Client mosqsub/4008-raspberryp received PUBLISH (d0, q0, r0, m0, 'mysensors-out/1/2/1/0/2', ... (1 bytes))
    mysensors-out/1/2/1/0/2 0
    Client mosqsub/4008-raspberryp received PUBLISH (d0, q0, r0, m0, 'mysensors-out/1/2/2/0/2', ... (0 bytes))
    mysensors-out/1/2/2/0/2 (null)
    Client mosqsub/4008-raspberryp received PUBLISH (d0, q0, r0, m0, 'mysensors-in/1/2/1/0/2', ... (1 bytes))
    mysensors-in/1/2/1/0/2 0
    Client mosqsub/4008-raspberryp received PUBLISH (d0, q0, r0, m0, 'mysensors-out/1/2/1/0/2', ... (1 bytes))
    mysensors-out/1/2/1/0/2 1
    Client mosqsub/4008-raspberryp received PUBLISH (d0, q0, r0, m0, 'mysensors-out/1/2/2/0/2', ... (0 bytes))
    mysensors-out/1/2/2/0/2 (null)
    Client mosqsub/4008-raspberryp received PUBLISH (d0, q0, r0, m0, 'mysensors-in/1/2/1/0/2', ... (1 bytes))
    mysensors-in/1/2/1/0/2 1
    Client mosqsub/4008-raspberryp received PUBLISH (d0, q0, r0, m0, 'mysensors-out/1/2/1/0/2', ... (1 bytes))
    mysensors-out/1/2/1/0/2 0
    Client mosqsub/4008-raspberryp received PUBLISH (d0, q0, r0, m0, 'mysensors-out/1/2/2/0/2', ... (0 bytes))
    mysensors-out/1/2/2/0/2 (null)
    Client mosqsub/4008-raspberryp received PUBLISH (d0, q0, r0, m0, 'mysensors-in/1/2/1/0/2', ... (1 bytes))
    mysensors-in/1/2/1/0/2 0
    
    

    Serial output

    811358 TSF:MSG:SEND,1-1-0-0,s=2,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=OK:1
    816367 TSF:MSG:SEND,1-1-0-0,s=2,c=2,t=2,pt=0,l=0,sg=0,ft=0,st=OK:
    818379 TSF:MSG:SEND,1-1-0-0,s=2,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=OK:0
    823388 TSF:MSG:SEND,1-1-0-0,s=2,c=2,t=2,pt=0,l=0,sg=0,ft=0,st=OK:
    825397 TSF:MSG:SEND,1-1-0-0,s=2,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=OK:1
    830406 TSF:MSG:SEND,1-1-0-0,s=2,c=2,t=2,pt=0,l=0,sg=0,ft=0,st=OK:
    832415 TSF:MSG:SEND,1-1-0-0,s=2,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=OK:0
    837424 TSF:MSG:SEND,1-1-0-0,s=2,c=2,t=2,pt=0,l=0,sg=0,ft=0,st=OK:
    839433 TSF:MSG:SEND,1-1-0-0,s=2,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=OK:1
    844442 TSF:MSG:SEND,1-1-0-0,s=2,c=2,t=2,pt=0,l=0,sg=0,ft=0,st=OK:
    846451 TSF:MSG:SEND,1-1-0-0,s=2,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=OK:0
    851462 TSF:MSG:SEND,1-1-0-0,s=2,c=2,t=2,pt=0,l=0,sg=0,ft=0,st=OK:
    853471 TSF:MSG:SEND,1-1-0-0,s=2,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=OK:1
    858480 TSF:MSG:SEND,1-1-0-0,s=2,c=2,t=2,pt=0,l=0,sg=0,ft=0,st=OK:
    860496 TSF:MSG:SEND,1-1-0-0,s=2,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=OK:0
    865506 TSF:MSG:SEND,1-1-0-0,s=2,c=2,t=2,pt=0,l=0,sg=0,ft=0,st=OK:
    867515 TSF:MSG:SEND,1-1-0-0,s=2,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=OK:1
    872524 TSF:MSG:SEND,1-1-0-0,s=2,c=2,t=2,pt=0,l=0,sg=0,ft=0,st=OK:
    874533 TSF:MSG:SEND,1-1-0-0,s=2,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=OK:0
    879543 TSF:MSG:SEND,1-1-0-0,s=2,c=2,t=2,pt=0,l=0,sg=0,ft=0,st=OK:
    881552 TSF:MSG:SEND,1-1-0-0,s=2,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=OK:1
    886561 TSF:MSG:SEND,1-1-0-0,s=2,c=2,t=2,pt=0,l=0,sg=0,ft=0,st=OK:
    888570 TSF:MSG:SEND,1-1-0-0,s=2,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=OK:0
    893580 TSF:MSG:SEND,1-1-0-0,s=2,c=2,t=2,pt=0,l=0,sg=0,ft=0,st=OK:
    
    

    (Note that the logs above are not perfectly lined up -- I copied and pasted as they were rolling, so they may be a few lines offset)

    Home Assistant
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular