Push V_Text value update from Domoticz to MySensors node


  • Hardware Contributor

    Hi, I am currently working on a 433Mhz gateway. It is a mysensors node that has a 433Mhz sender and receiver. It presents two S_INFO/V_TEXT children: the sender and the receiver. The idea is that the receiver receives a message via 433Mhz and sends the code as text to the controller. The controller decides what to do and then sends back a text with the answer code to the node. The node than takes that code and sends it via 433Mhz.
    My problem at the moment is that no message seems to get send to the node when I update the text value in domoticz. Does anyone have an idea why? I saw other people sending messages from the controller to a node.

    Here is my code:

    
    // define radio stuff
    #define MY_RADIO_NRF24
    #define MY_BAUD_RATE 9600
    #define MY_DEBUG    // Enables debug messages in the serial log
    //#define MY_NODE_ID 13
    
    // add signing stuff
    //#define MY_SIGNING_SOFT // Enables software signing
    //#define MY_SIGNING_REQUEST_SIGNATURES // Always request signing from gateway
    //#define MY_SIGNING_SOFT_RANDOMSEED_PIN 7 // floating pin for randomness
    //#define MY_DEBUG_VERBOSE_SIGNING
    
    #include <EEPROM.h>
    #include <SPI.h>
    #include <MyConfig.h>
    #include <MySensors.h>
    #include <Vcc.h>
    #include <RCSwitch.h>
    
    const long RECEIVER_PIN = 0;
    const long SENDER_PIN = 7;
    const long DEBOUNCE = 500;
    const long CHILD_RECEIVER = 0;
    const long CHILD_SENDER = 1;
    
    
    RCSwitch wirelessSwitch = RCSwitch();
    
    
    void presentation()
    {
      sendSketchInfo("433 Wireless Gateway", "29062017");
    
      present(CHILD_RECEIVER, S_INFO); // able to receive text
      present(CHILD_SENDER, S_INFO); // able to send text
    }
    
    void setup() {
      wirelessSwitch.enableReceive(RECEIVER_PIN); // Receiver on interrupt 0 => that is pin #2
      wirelessSwitch.enableTransmit(SENDER_PIN);  // Sender on pin 7
      Serial.println("Started listening on pin 2 for incoming 433Mhz messages");
    }
    
    void loop() {
      if (wirelessSwitch.available()) {
      	// for testing
        //output(wirelessSwitch.getReceivedValue(), wirelessSwitch.getReceivedBitlength(), wirelessSwitch.getReceivedDelay(), wirelessSwitch.getReceivedRawdata(),wirelessSwitch.getReceivedProtocol());
    
        unsigned long received_val = wirelessSwitch.getReceivedValue();
    
        Serial.print("Received 433Mhz message: ");
        Serial.println(received_val);
    
        send(MyMessage(CHILD_RECEIVER, V_TEXT).set(received_val));
    
        // software debounce
        wait(DEBOUNCE);
        wirelessSwitch.resetAvailable();
      }
    }
    
    void receive(const MyMessage &message) {
      Serial.print("Sensor: "); Serial.print(message.sensor); Serial.print(", Message: "); Serial.println(message.getString()); 
      if (message.type == V_TEXT) { 
        if (message.sensor == CHILD_SENDER) {
          Serial.println("Sending message via 433Mhz");
          char * messageContent = strdup(message.getString());
          wirelessSwitch.send(messageContent);
        }
      }
    }
    

    On the domoticz side I have a piece of lua code (using dzVents) that just copies the receiver value to the sender

    return {
            active = true,
            on = {
                '433Receiver'
            },
            execute = function(domoticz, sensor)
    
                domoticz.log("Received from gateway " .. sensor.state)
                -- check sensor values 
                domoticz.devices['433Sender'].updateText(sensor.state)
            end
        }
    

    and its working in the domoticz ui... Is this a domoticz error or am I missing something in my code?


  • Hardware Contributor

    PS part of the problem might be that the value gets updated in the normal domoticz ui but in the hardware tab in the details of the gateway I still see no value at all for the sender child. Does anyone know if I am missing some code in my lua perhaps, or if this is a bug in domoticz or the mysensors integration?


  • Mod

    @LastSamurai I ran into the same issue lately. IIRR it is an issue with Domoticz: V_TEXT can only be sent by a node to Domoticz. Domoticz will not send an updated text back to a node...
    A very lame workaround could be to trigger Domoticz to send something to the node (e.g. V_STATUS) which triggers the node to request the latest V_TEXT from Domoticz 💩


  • Hardware Contributor

    Well thats bad 😞 Thanks for the help though! I hope domoticz adds this feature soon


  • Mod

    @LastSamurai well, you could always ask /discuss on the domoticz forum


  • Hardware Contributor

    I already have (in a github issue). Didn't get any answer yet. I am currently trying to simply use some other type of sensor (as I just need to send an integer) but none of them have really worked yet.


Log in to reply
 

Suggested Topics

  • 5
  • 1
  • 8
  • 1
  • 2
  • 4

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts