Request data from Domoticz



  • Hello!!
    I would like to make some small displays to put in the house where you can see the status of some lights and temperatures.
    So it was my intention to retrieve this info from Domoticz from time to time. If I understand correctly I should use the "request" command only that I have no idea where to start ....
    Has anyone already done something like this and wants to share their experience and / or a piece of code already done ??


  • Plugin Developer

    In theory the latest versions of Domoticz automatically send info fields to your node if their value changes.

    otherwise you can do a request. The code below is a quick copy-paste from an SMS doorlock I use, so don't copy paste it, but take the parts you need.

    
    #define ROTATING_PASSWORD1_ID 3                     // SMS Password can be set from controller.
    char rotatingPassword1[26] = "door1";               // Holds the password we get from the controller. Starts as the backup password: if no connection to the controller can be established, this will we the password.
    
    
    // IN YOUR PRESENT:
      present(ROTATING_PASSWORD1_ID, S_INFO); delay(RF_DELAY);
    
    
    // IN YOUR LOOP OR SETUP:
    
           request(ROTATING_PASSWORD1_ID, V_TEXT);           // periodically check if there is a new password set.
     
    
    
    // IN YOUR RECEIVE FUNCTION:
    
    void receive(const MyMessage &message)
    {
      if (message.type == V_TEXT) {
        if(message.sensor == ROTATING_PASSWORD1_ID){
          if( rotatingPassword1 != message.getString() && sizeof(message.getString()) > 2 ){
            strcpy(rotatingPassword1, message.getString());
            Serial.print(F("Rotating password 1 is now: ")); Serial.println(rotatingPassword1);
            send(charmsg.setSensor(DEVICE_STATUS_ID).set( F("received latest password 1")));
          }
        }
      }
    }
     
    
    


  • Are your lights and temp sensors MySensored or would you like to get status from some random Domoticz devices?



  • @pjr
    yes, I intend to receive data from devices that do not belong to that node, but to other nodes.
    So random devices of the network


  • Plugin Developer

    Then you'll have to fill that info field with the values from those sensors, using some automation in Domoticz.



  • do you mean that it is not possible to request those data from the node that will make the display ??


  • Plugin Developer

    No, you cannot request data from just any random device in your home. Just imagine how insecure that would be! And how complicated!

    The MySensors device has to create a field in Domoticz (using the present function). This can be a text field (as I explained above), but it can be any type you like.

    If the content of the info field then changes in Domoticz, its new value can be requested. In some cases the value will be automatically sent to the MySensors device (like info and thermostat).

    Finally, you will have to tell Domoticz to 'copy' the value you want into the field of your MySensors device.

    I hope this makes sense.


  • Plugin Developer

    For what you want, you could also just stick some old smartphones or tablets onto your wall, which have access to the Domoticz interface? If you create some special users for those devices you can curate which buttons and sensors each device can display.


  • Plugin Developer

    Another option: if you create a MySensors device with a little screen, and have that node also create some switches in Domoticz, then you can set those switches as 'slave devices' when you flip the master light switch. That way their value will also get updated. And then you can show that status on the screen of the MySensors device easily.



  • Hello
    So if I understand, a node from domoticz can only ask the status of a sensor connected already him, and not the status of other nodes of the network!
    So it is impossible for me to create nodes / displays to display the status of other sensors in the network.
    The only way is to use some old mobile phone as a display point



  • @sindrome73
    But Domoticz can write value from other nodes into V_TEXT field of your node, which can be requested then.
    Use LUA or DzVents script for this.
    alowhum pointed this way in several his posts to you.



  • @kimot I did not understand what you tell me, can you explain better or with some examples ??



  • @sindrome73

    Read post from gizmocuz commented on 10 May

    https://github.com/domoticz/domoticz/issues/2380

    There is a switch example, but domoticz can call events when temperature changes or periodically every minute etc.
    And then you can store new value onto V_TEXT, which can be requested from mysensor node or in newer versions of domoticz is automatically sended to your mysensor node and can be displayed on LCD.



  • @sindrome73 said in Request data from Domoticz:

    Hello
    So if I understand, a node from domoticz can only ask the status of a sensor connected already him, and not the status of other nodes of the network!
    So it is impossible for me to create nodes / displays to display the status of other sensors in the network.
    The only way is to use some old mobile phone as a display point

    You can directly request data from other node(nothing to do with domoticz).

    From documentation: https://www.mysensors.org/download/sensor_api_20#requesting-data

    Requests a variable value from gateway or some other sensor in the radio network.
    void request(uint8_t childSensorId, uint8_t variableType, uint8_t destination);
    childSensorId - The unique child id for the different sensors connected to this Arduino. 0-254.
    variableType - The variableType to fetch.
    destination - The nodeId of other node to request data from in radio network. Default is gateway.

    Other way is that you can present some text sensors in your "screen" node and update those from scripts at domoticz.



  • this is a good place to start and start to understand.
    I'm not a lot of diggers, however I start reading something, and in case I'll ask for help
    In a lot of thanks


Log in to reply
 

Suggested Topics

  • 90
  • 13
  • 4
  • 3
  • 3
  • 1

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts