Requesting value from Domoticz



  • I understand Domoticz doesn't yet support MySensors smart sleep mode.
    As a workaround MySensors node could periodically request certain value from Domoticz.
    I cannot find any docs on how to define dummy device or user value in Domoticz those value could be retrieved by MySensor v.2 node.
    My setup: GW and Domoticz run on the same RPi. Node runs on a battery-powered Arduino.
    I understood node will use
    void request(uint8_t childSensorId, uint8_t variableType, uint8_t destination);
    where destination=0 (to address GW),
    but what should be used for childSensorId?
    Where in Domoticz I can see proper values for childSensorId?

    Could someone guide me through?

    Thanks a lot!



  • I would also like some clarification on this as it would help as you say with the fact that Domoticz does not support Smartsleep Yet.



  • @benya If I understand you right, you are looking to find the child IDs of a sensor node.

    Click on Setup > Hardware. Under Hardware find your MySensors Gateway and click the [Setup] button. From there, find the node that you want the child IDs from and click on it. Below the Nodes list you will see the list of Children with child IDs.

    Hope that helps.



  • Thanks.
    What if need to get value from dummy sensor controlled by Domoticz (not by another MySensors node)?
    Where is corresponding childSensorId?
    My RPi runs both MySensors gateway and Domoticz.



  • @benya said:

    Thanks.
    What if need to get value from dummy sensor controlled by Domoticz (not by another MySensors node)?
    Where is corresponding childSensorId?
    My RPi runs both MySensors gateway and Domoticz.

    Are you trying to get the value on, or send the value to one of your MySensors nodes?



  • The goal is to pass value to the sensor that could be sleeping. Domoticz doesn't support MySensors smart sleep mode and polling current value is only option now.



  • @benya I think I understand what you need. I have not worked with smart sleep, but I have passed dummy sensor information to a MySensors node. The key is to have the dummy sensor, and a corresponding MySensors child for the node. If you look at this post, I hve a response where you will see how I do this with my thermostat node to pass the thermostat mode from a dummy selector to my thermostat bridge node.



  • You are pushing value from controller to the node.
    But if node is sleeping, new value won't reach node.
    To get new value node has to request it from controller after waking up from sleep.



  • You can use that though to set the value that the node can grab. Are you wondering how to grab the value?



  • @dbemowsk said:

    You can use that though to set the value that the node can grab. Are you wondering how to grab the value?

    I am trying to figure what values to pass to
    void request(uint8_t childSensorId, uint8_t variableType, uint8_t destination);
    Where are the corresponding values show up in Domoticz UI?



  • I pull the thermostat mode from my thermostat bridge node like this:

        request( CHILD_ID_MODE, V_TEXT );
    

    I have never used the destination attribute, so I can't speak to it's use, but using the childSensorId and variableType works for me. You still need to use the technique I described to set the MySensors child node from the dummy sensor though.



  • Hi @dbemowsk,
    I'm trying to figure out the message format in the receive() function. Could you show an example of your receive() function ? I couldn't find the received message format.
    Thank's



  • You are going to use 2 things. message.type and message.data. The message.type in my scenario is V_TEXT, and message.data is the payload, which in my case is O, H, C or A, but can be whatever you pass from Domoticz. The code in your receive function would look something like this:

    if (message.type == V_TEXT) {
      Serial.println("Received data" + String(message.data));
      //Here you would do something with message.data
    }
    

    If you have more than one child sensor sending V_TEXT data, you would then use an if statement or a switch/case to check message.sensor for the child ID of the sensor and process each as above.

    if (message.type == V_TEXT) {
      if (message.sensor == 1) {
        Serial.println("Received data from child 1" + String(message.data));
        //Here you would do something with message.data for the first child
      } else if (message.sensor == 2) {
        Serial.println("Received data from child 2" + String(message.data));
        //Here you would do something with message.data for the second child
      }
    }
    

    Let us know if you have trouble.



  • That is perfect thanks a lot.



  • @dbemowsk

    At the moment I'm trying to send a text value from Domoticz with MySensors Gateway to one of my nodes.

    I need to implement the "request" function in this node. So here's my question: what value did you assign to "CHILD_ID_MODE". I presume that's the ID of the dummy selector described in another topic on this forum? How did you obtain this value? Is it available somewhere in Domoticz UI?

    Now I request a text value, but all I get is a blank message, cause I don't know what I should insert as "uint8_t childSensorId".


  • Mod

    The child ID is something you define when you present the sensors of the node



  • @gohan Yes, I understand, but when I create a dummy text sensor I can't define its child ID. Can I find it somewhere?


  • Mod

    You have to create a sensor in the sensor node sketch, assign a child ID to it and present it like the others sensors during setup, then it should show on the controller. I can't be more specific because I haven't worked on text sensors yet



  • @gohan Dummy sensors are created in Domoticz, they don't use the MySensors library, so one doesn't upload any sketches to Arduino 🙂

    What I want to achieve specifically is to send outside temperature received from WeatherUnderground to one of my MySensors nodes.


  • Mod

    I know, but if you don't create a sensor able to receive the value, you can't send anything to it through the mysensors network



  • @gohan hey, now I get it!

    got it working the way I wanted, thank you so much 😄


  • Mod

    Just for my curiosity, why are you using the temperature from weather underground? Is it just displayed on a screen?



  • @gohan I'm doing a project for my master's thesis.

    There's a mathematical thermal model of a building running on MySensors node. I wanted to supply it with an information about actual outside temperature to have accurate results.


  • Mod

    A real mysensors project would require an external node with temperature and humidity sensor 😁



  • @gohan This model is just a small part of my project. But I get your concept.

    There's already a DHT11 node running inside my house, measuring quantities that you've mentioned.



  • @tomek_olo
    Sorry what is the way for send from domoticz child -node to other node through lua script for example Tanks



  • @mar.conte I don't understand your question. Can you clarify, please?



  • @tomek_olo
    Sorry what is the way for send from domoticz child -node to other node through lua script for example Tanks



  • @mar.conte

    OK, I'll try to describe everything I've done to get it working:

    1. I'm presenting MySensors node to Domoticz as S_INFO: "present(CHILD_ID, S_INFO);"
    2. Next step is to add this node in your Domoticz. It should be visible at first in "Devices" as a "Text" device. After you add it it will be present in the "Utility" tab.
    3. Now you have to edit a text value of this device in Domoticz. (I think that's what interests you but in reverse) I'm using a "Device" script that updates this text value with outside temperature every time the weather is updated:

    commandArray = {}
    local tempOut = devicechanged["Outside_Temperature"]
    local tempOutIdx = 25

    if ( devicechanged["Outside"]) then
    commandArray['UpdateDevice'] = otherdevices_idx['TextNode']..'|1|'..tempOut
    end

    1. Now when I want to download this new value to my node I use "request( CHILD_ID, V_TEXT );" and inside "receive()" function:

    if (message.type == V_TEXT) {
    if (message.sensor == CHILD_ID) {
    outTemp = message.getFloat();
    }
    }

    That's all, it's complicated. If you have any questions feel free to ask. I'll do my best to help.


  • Mod

    If the temperature sensor is also running on a mysensors node, you can send the value from the node to the one with lcd screen directly without using the controller.



  • For send message to child node wich isnt present in device list? In other words i have a node wich is in device list and the child 's node called S_custom with id 200 .... the node id is 101...



  • Hi,
    I've been trying to modify the sketch of Solar Powered Plant moisture sensor so that I can remotely control the sleep time from Domoticz.. But so far I failed.. ;-(
    Sorry for the long post below, but I try to provide all details, as I don't understand what I did wrong..

    I tried to understand several contributions including the ones above from dbemowsk (thank you also for your chat messages!) and tomek_olo, as well as the Water Pulse meter sensor , but I still don't succeed having the sensor receiving data from Domoticz.

    Here's what I tried to do.
    In Sensor, I reused the code from solar powered moisture sensor from other post (and that code is working on another sensor) then I modified it to:

    • present an additional child to Domoticz (CHILD_ID_SLEEP 2 with S_INFO) in setup
    • send a value (here 11) of V_VAR1 in setup as per the advise from dbemowsk so that domotic recognize that data field
    • then in Loop(), I have (apart the code for moisture sensor) a loop for requesting V_VAR1 (copied that from the water pulse meter sensor code)
    • outside Loop() (at bottom of script), I created the receive(const MyMessage &message) procedure (in code below, I tried to print to serial several debugging messages...)

    Here's below the whole code:

    #include <SPI.h>
    #define MY_RADIO_NRF24
    #define MY_DEBUG
    #include <MySensors.h>
    
    #define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
    #define N_ELEMENTS(array) (sizeof(array)/sizeof((array)[0]))
    
    #define CHILD_ID_MOISTURE 0
    #define CHILD_ID_BATTERY 1
    #define CHILD_ID_SLEEP_S 2
    // #define SLEEP_TIME_S 100 // Sleep time between reads (in seconds)
    #define THRESHOLD 1.1 // Only make a new reading with reverse polarity if the change is larger than 10%.
    #define STABILIZATION_TIME 1000 // Let the sensor stabilize before reading default BOD settings.
    const int SENSOR_ANALOG_PINS[] = {A4, A5}; // Sensor is connected to these two pins. Avoid A3 if using ATSHA204. A6 and A7 cannot be used because they don't have pullups.
    
    // MySensor gw;
    MyMessage msg(CHILD_ID_MOISTURE, V_HUM);
    MyMessage voltage_msg(CHILD_ID_BATTERY, V_VOLTAGE);
    MyMessage sleep_msg(CHILD_ID_SLEEP_S, V_VAR1);
    unsigned long SLEEP_TIME_S = 10;
    unsigned long SLEEP_TIME = 10000;
    long oldvoltage = 0;
    byte direction = 0;
    int oldMoistureLevel = -1;
    float batteryPcnt;
    float batteryVolt;
    int LED = 5;
    bool pcReceived = false;
    
    void setup()
    {
      pinMode(LED, OUTPUT);
      digitalWrite(LED, HIGH);
      delay(200);
      digitalWrite(LED, LOW);
      delay(200);
      digitalWrite(LED, HIGH);
      delay(200);
      digitalWrite(LED, LOW);
      SLEEP_TIME=SLEEP_TIME_S*1000;
    
    
    sendSketchInfo("Plant moisture solar proto", "1.0");
    // request(CHILD_ID_SLEEP_S, V_VAR1);
    present(CHILD_ID_MOISTURE, S_HUM);
      delay(250);
    present(CHILD_ID_BATTERY, S_MULTIMETER);
      for (int i = 0; i < N_ELEMENTS(SENSOR_ANALOG_PINS); i++) {
        pinMode(SENSOR_ANALOG_PINS[i], OUTPUT);
        digitalWrite(SENSOR_ANALOG_PINS[i], LOW);
      }
    present(CHILD_ID_SLEEP_S, S_INFO);
    send(sleep_msg.set(11));
    }
    
    void loop()
    {
      pcReceived = false;
      int moistureLevel = readMoisture();
    
      // Send rolling average of 2 samples to get rid of the "ripple" produced by different resistance in the internal pull-up resistors
      // See http://forum.mysensors.org/topic/2147/office-plant-monitoring/55 for more information
      if (oldMoistureLevel == -1) { // First reading, save current value as old
        oldMoistureLevel = moistureLevel;
      }
      if (moistureLevel > (oldMoistureLevel * THRESHOLD) || moistureLevel < (oldMoistureLevel / THRESHOLD)) {
        // The change was large, so it was probably not caused by the difference in internal pull-ups.
        // Measure again, this time with reversed polarity.
        moistureLevel = readMoisture();
      }
    send(msg.set((moistureLevel + oldMoistureLevel) / 2.0 / 10.23, 1));
      oldMoistureLevel = moistureLevel;
      
      int sensorValue = analogRead(A0);
      Serial.println(sensorValue);
      float voltage=sensorValue*(3.3/1023);
      Serial.println(voltage);
      batteryPcnt = (sensorValue - 248) * 0.72;
      batteryVolt = voltage;
    sendBatteryLevel(batteryPcnt);
      resend((voltage_msg.set(batteryVolt, 3)), 10);
    
    if (!pcReceived) {
          //Last sleept time not yet received from controller, request it again
          request(CHILD_ID_SLEEP_S, V_VAR1);
          Serial.print("Requested time sleep from gw VAR1");
          return;
        }
    
    
      digitalWrite(LED, HIGH);
      delay(200);
      digitalWrite(LED, LOW);
    SLEEP_TIME=SLEEP_TIME_S*1000;  
    sleep(SLEEP_TIME);
    }
    
    void resend(MyMessage &msg, int repeats)
    {
      int repeat = 1;
      int repeatdelay = 0;
      boolean sendOK = false;
    
      while ((sendOK == false) and (repeat < repeats)) {
        if (send(msg)) {
          sendOK = true;
        } else {
          sendOK = false;
          Serial.print("Error ");
          Serial.println(repeat);
          repeatdelay += 500;
        } repeat++; delay(repeatdelay);
      }
    }
    
    
    int readMoisture() {
      pinMode(SENSOR_ANALOG_PINS[direction], INPUT_PULLUP); // Power on the sensor
      analogRead(SENSOR_ANALOG_PINS[direction]);// Read once to let the ADC capacitor start charging
      sleep(STABILIZATION_TIME);
      int moistureLevel = (1023 - analogRead(SENSOR_ANALOG_PINS[direction]));
    
      // Turn off the sensor to conserve battery and minimize corrosion
      pinMode(SENSOR_ANALOG_PINS[direction], OUTPUT);
      digitalWrite(SENSOR_ANALOG_PINS[direction], LOW);
    
      direction = (direction + 1) % 2; // Make direction alternate between 0 and 1 to reverse polarity which reduces corrosion
      return moistureLevel;
    }
    
    void receive(const MyMessage &message)
    {
      if (message.type==V_TEXT) {
        // unsigned long infosleep=message.getULong();
        String infosleepstr=message.getString();
        unsigned long infosleep=infosleepstr.toInt();
        Serial.print("Received time sleep as string from gw:");
        Serial.println(infosleepstr);
        Serial.print("fin de msg");
        SLEEP_TIME_S = infosleep;
        pcReceived = true;
      }
      if (message.type==V_VAR1) {
        unsigned long infosleep=message.getULong();
        //unsigned long infosleep=message.getString();
        
        Serial.print("Received time sleep as VAR1 ULOng from gw:");
        Serial.println(infosleep);
        Serial.print("fin de msg");
        SLEEP_TIME_S = infosleep;
        pcReceived = true;
      }  
    }
    

    In Domoticz, in hardware I can see this:
    0_1509627328360_hardware view.png
    The sensor is the "proto" one (ID 1) where I can see the various children (Humidity=0 is normal as I did not attach the soil sensor and voltage is weird as it's not connected either).
    In devices view, I have:
    0_1509627449535_devices view.png
    where I can see the text sensor of S_INFO which is set to "5" thanks to a user variable (see LUA script below).
    0_1509628921576_button view.png
    I created a user variable "SondeSleep" with a LUA script (type "variables") to update the text sensor whenever the suer variable changes:

    commandArray = {}
    if ( uservariablechanged['SondeSleep']) then
    print ("nouvelle valeur Level1 de SondeSleep:" .. uservariables['SondeSleep']);
    ttidx=otherdevices_idx['SondeSolProto_Text_Sensor'];
    commandArray['UpdateDevice']=ttidx..'|1|' .. uservariables['SondeSleep'] 
    end
    return commandArray 
    

    This script seems working since it replicates properly the vriable value to the text_sensor. I'm just confused by the command

    commandArray['UpdateDevice']=ttidx..'|1|' .. uservariables['SondeSleep']
    

    where I couldn't understand the meaning of the value between the || (here |1|).

    The Domoticz website refers to LUA and JSON page, but I coudn't find the explanation. In 1 script of this post, I saw a 0, in another a 1.. I tried with both and also wit 2 (just in case it refers to Child ID ..) but no better result.
    Could someone clarifies the meaning ?

    When I run the sensor, I can only see (in serial monitor) the message "Requested time sleep from gw VAR1" from the "request" loop. and in Domoticz log, I can see that the sensor updates the humidity and voltage values, but that's all.

    I'm also surprised I do'nt see any value in S_INFO child, but maybe it's normal.
    I had tried to use V_TEXT instead of V_VAR1 everhwhere, but same result. There's definitely something I misunderstood somewehere.

    Anyone could help me ?
    ricorico94


  • Mod

    Have you tried with a variable that is Integer instead of text or other? I am just guessing, as I haven't tried what you are doing yet.



  • well, one of my issues is that I don't understand how the V_VAR1 is managed by Domoticz. The website states that V_VARx exist for any kind of sensor, but in such case I don't understand how to define its value in Domoticz as V_VAR1 appears nowhere. So I used an integer user variable, then transtype to text and in my receive(à procedure, I was trying to transtype again to integer (or unsigned long)..
    It's also why I had tried to replace all my V_VAR1 by V_TEXT, to be more homogenous.



  • @ricorico94 If you are asking about V_VarX, I won't be much help. Back when I used Domoticz, V_VarX was not supported yet. I would be curious to see what the answer is though.



  • HI again,
    I noticed that I never see any "read" line in the serial monitor (except at the very beginning when I restart the sensor". Is it normal ?
    Here are snapshots of a couple messages (among the thousands appearing on Serial monitor)
    Seen right after restart of sensor:

    0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1
    4 TSM:INIT
    4 TSF:WUR:MS=0
    12 TSM:INIT:TSP OK
    14 TSF:SID:OK,ID=1
    16 TSM:FPAR
    51 TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    585 TSF:MSG:READ,0-0-1,s=255,c=3,t=8,pt=1,l=1,sg=0:0
    591 TSF:MSG:FPAR OK,ID=0,D=1
    2060 TSM:FPAR:OK
    2060 TSM:ID
    2062 TSM:ID:OK
    2064 TSM:UPL
    2068 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
    2074 TSF:MSG:READ,0-0-1,s=255,c=3,t=25,pt=1,l=1,sg=0:1
    2080 TSF:MSG:PONG RECV,HP=1
    2084 TSM:UPL:OK
    2086 TSM:READY:ID=1,PAR=0,DIS=1
    2091 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
    2099 TSF:MSG:READ,0-0-1,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
    2107 TSF:MSG:SEND,1-1-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.1.1
    2121 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
    2570 TSF:MSG:READ,0-0-1,s=255,c=3,t=6,pt=0,l=1,sg=0:M
    2576 MCO:REG:REQ
    2580 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
    2588 TSF:MSG:READ,0-0-1,s=255,c=3,t=27,pt=1,l=1,sg=0:1
    2594 MCO:PIM:NODE REG=1
    2596 MCO:BGN:STP
    3201 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=11,pt=0,l=25,sg=0,ft=0,st=OK:Plant moisture solar prot
    3213 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0
    3223 TSF:MSG:SEND,1-1-0-0,s=0,c=0,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    3481 TSF:MSG:SEND,1-1-0-0,s=1,c=0,t=30,pt=0,l=0,sg=0,ft=0,st=OK:
    3491 TSF:MSG:SEND,1-1-0-0,s=2,c=0,t=36,pt=0,l=0,sg=0,ft=0,st=OK:
    3502 TSF:MSG:SEND,1-1-0-0,s=2,c=1,t=24,pt=2,l=2,sg=0,ft=0,st=OK:11
    3508 MCO:BGN:INIT OK,TSP=1
    3512 MCO:SLP:MS=1000,SMS=0,I1=255,M1=255,I2=255,M2=255
    3518 MCO:SLP:TPD
    3520 MCO:SLP:WUP=-1
    3524 TSF:MSG:SEND,1-1-0-0,s=0,c=1,t=1,pt=7,l=5,sg=0,ft=0,st=OK:0.0
    242
    0.78
    3534 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=0,pt=1,l=1,sg=0,ft=0,st=OK:252
    3545 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=38,pt=7,l=5,sg=0,ft=0,st=OK:0.781
    3555 TSF:MSG:SEND,1-1-0-0,s=2,c=2,t=24,pt=0,l=0,sg=0,ft=0,st=OK:
    Requested time sleep from gw VAR13565 TSF:MSG:SEND,1-1-0-0,s=2,c=2,t=47,pt=0,l=0,sg=0,ft=0,st=OK:
    Requested time sleep from gw TEXT3573 MCO:SLP:MS=1000,SMS=0,I1=255,M1=255,I2=255,M2=255
    

    and then messages which keeps repeating (no read message):

    10414 TSF:MSG:SEND,1-1-0-0,s=2,c=2,t=24,pt=0,l=0,sg=0,ft=0,st=OK:
    Requested time sleep from gw VAR110424 TSF:MSG:SEND,1-1-0-0,s=2,c=2,t=47,pt=0,l=0,sg=0,ft=0,st=OK:
    Requested time sleep from gw TEXT10432 MCO:SLP:MS=1000,SMS=0,I1=255,M1=255,I2=255,M2=255
    10438 MCO:SLP:TPD
    10440 MCO:SLP:WUP=-1
    10448 TSF:MSG:SEND,1-1-0-0,s=0,c=1,t=1,pt=7,l=5,sg=0,ft=0,st=OK:0.0
    189
    0.61
    10461 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=0,pt=1,l=1,sg=0,ft=0,st=OK:214
    10471 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=38,pt=7,l=5,sg=0,ft=0,st=OK:0.610
    10479 TSF:MSG:SEND,1-1-0-0,s=2,c=2,t=24,pt=0,l=0,sg=0,ft=0,st=OK:
    Requested time sleep from gw VAR110489 TSF:MSG:SEND,1-1-0-0,s=2,c=2,t=47,pt=0,l=0,sg=0,ft=0,st=OK:
    Requested time sleep from gw TEXT10498 MCO:SLP:MS=1000,SMS=0,I1=255,M1=255,I2=255,M2=255
    

    Any idea of what might happen ? (or not happen..)
    NB: in snapshots above, I'm requesting both V_VAR1 and V_TEXT vaues with these commands looping:

    if (!pcReceived) {
          //Last sleept time not yet received from controller, request it again
          request(CHILD_ID_SLEEP_S, V_VAR1);
          Serial.print("Requested time sleep from gw VAR1");
          request(CHILD_ID_SLEEP_S, V_TEXT);
          Serial.print("Requested time sleep from gw TEXT");
          return;
        }```
    
    ricorico94

  • Mod

    @Yveaux maybe you could give some hints?



  • Hi,
    I finally got it working ! Thanks to 3 changes.. Two which I understand why, the other, well, not really..
    Here's what I did or let's say, my findings..(well, I did much more than that, multiplying tests during several hours..😓 ).

    1. I had thought that since S_INFO was displayed in Domoticz, everything was OK in domoticz. Actually not, and on top of presenting this Child, it seems you need to send whatever value to Domoticz as V_TEXT to initiate that variable. I had read some allusions to that fact (in message from dbemowsk for example) without understanding that it had to be done not for the S_INFO but also for each variable (V_TEXT , V_VAR1,.. any to be used). In sketch I showed I was sending that command for V_VAR1, but when I was trying similar skecth for V_TEXT , I was still ending only to V_VAR1. Once I tried to send the message to V_TEXT, I could see a value V_TEXT appearing in Domoticz under the S_Info line.
    2. As per my previous post, I was not seeing any READ statement in serial monitor after the initial setup phase. Here, I tried to add a "wait" command after the request, instead of looping immediately as per the sketch of Pulse Water sensor. So my loop is now:
    if (!pcReceived) {
          request(CHILD_ID_SLEEP_S, V_TEXT);
          Serial.print("Requested time sleep from gw TEXT");
          wait(5000,2,V_TEXT); // wait for 5s or until a message of type V_TEXT is received
    }
    

    and now, I can see READ messages and also receive and handle them !
    I don't know why I must add this wait statement whereas the Pulse Water Meter sketch can work without it. Maybe linked to hardware used (I did not try to upload that sketch to my sensor to see if it would work). I also removed the "return" command which was present in Pulse Water sketch and which was preventing the rest of the loop() to be executed.

    1. Instead of trying to use V_VAR1 as per the Water Pulse Meter sketch, I use V_TEXT everywhere. In fact, I found a unique, old (in 2015) and very short comment on a forum (I can't remember if it's here on another one.. I searched so many times..) that V_VARx can not be setup or read by Domoticz and they can only be modified by a sensor and read by that sensor or another sensor to store information on the controller side. So, indeed, that works for the pulse water meter, but not for my need since I need interactions with the controller.

    So now it works. Learning curve was painful, but I think I understand the mechanism.

    If one of the admins of Mysensor reads my post, I could suggest the following:

    • in the Controller webpage, instead of stating Y* and "* limited functionality" for V_VAR1..5 variables, you could add a different comment Y*** "can be used for storing values on controller side, but can not be modified/read by Domoticz once it has been initialized with "send" command" and for V_TEXT : Y* "**** only variable which can be used for exchanging data between Domoticz and sensors in both ways and need an initial initialisation by sensor node by send command"
    • in Pulse Water Meter sketch, since it is often referred to as an example, you could add a few comments on why it is using V_VAR1 and not V_TEXT and why V_VAR1 can not be used for exchanging info with Domoticz controller. Also, I would add a comment in the !pcreceived loop proposing to add a "wait" command in case it does not work that way.

    If you plan to write a tutorial on this topic, I can propose my help.

    Thanks a lot to the persons who tried to help me.

    br,
    ricorico94


  • Plugin Developer

    For anyone finding this: in the end I changed the V_TEXT value in a MySensors node in Domoticz by creating a Blockly that calls an API URL that updates the text value.

    192.168.1.30:8080/json.htm?type=command&param=udevice&idx=18&nvalue=0&svalue=awesomeness

    Replace the IP address, idx value with the node ID number in domoticz, and 'awesomeness' with your values.

    // UPDATE: The Aurora theme now makes this even easier. Just clock on the value in the Domoticz interface, and change it.

    So: utility page -> click on the text value -> change it -> click outside of the text to save the change.


Log in to reply
 

Suggested Topics

  • 5
  • 1
  • 2
  • 3
  • 5
  • 4

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts