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
  1. Home
  2. Development
  3. request variable from gateway

request variable from gateway

Scheduled Pinned Locked Moved Development
13 Posts 3 Posters 7.5k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • TheoLT TheoL

    @cimba007 if understand your question correctly. Then your assumption is that the gateway responds to a request made by any node?

    If that is your question and if I understand MySensors correctly, then to answer is "Partly true". Because the gateway is just gateway and contains no logic. It delegates the request to the controller. In your case any MQTT client that happens to listen to request made by a node. That client should publish a response to that request to your MQTT gateway (which I believe is also an MQTT client).

    So if no one is responding to a node's request, a node will never receive the answers to it's requests.

    cimba007C Offline
    cimba007C Offline
    cimba007
    wrote on last edited by cimba007
    #4

    https://github.com/mycontroller-org/mycontroller/issues/264

    I think i narrowed down the issue .. the wrong value is returned from mycontroller.org upon receiving the request.

    Still the documentation on mysensor should clearly state who will respond the the request message .. the controller or the actual sensor.

    J 1 Reply Last reply
    0
    • cimba007C cimba007

      https://github.com/mycontroller-org/mycontroller/issues/264

      I think i narrowed down the issue .. the wrong value is returned from mycontroller.org upon receiving the request.

      Still the documentation on mysensor should clearly state who will respond the the request message .. the controller or the actual sensor.

      J Offline
      J Offline
      jkandasa
      Plugin Developer
      wrote on last edited by
      #5

      @cimba007 AFAIK, earlier version of MySensors.org does not support any sensors. It was acting only as a gateway. never control any sensors. request feature was designed that time. It was designed as, if some one request data from gateway(default), it will forward the request to controller. If do a request from other than gateway (other destination - like you have mentioned) it will be forwarded to that particular destination node(this operation happens without controller knowledge).

      But recently MySensors introduced sensors support on Gateway too. I hope this request feature not redesigned yet. I believe it is tough to change this logic. Because gateway's primary response is, if some one asked any request with the destination id as 0, gateway believes it is for controller.

      In your case it happens as follows,

      • You requested sensor 0 of V_ARMED status and destination is 0 (gateway id)
      • Gateway thinks this message for controller(as per current design) and sent to controller
      • controller reads this message as 50;0;2;0;15;(node-id;child-sensor-id;message-type;ack;sub-type;payload), which means nodeId=50 requested V_ARMED data of SensorId 0. It looks in db and nothing found. It creates entry for this node/sensor/variable and sends some default value(MyController designed like if it receives message from new device, create an entry for that).
      1 Reply Last reply
      0
      • cimba007C Offline
        cimba007C Offline
        cimba007
        wrote on last edited by
        #6

        Okay .. I tried the following:

        void loop()
        {
          Serial.println(".");
          request(0,V_LIGHT_LEVEL,10);
          wait(50);
          sleep(5000);
        }
        

        0_1472320551772_upload-8f40a3ca-539e-4f22-ad15-0e56f62feeae

        But I get no response as node 10 is 99% of the time in sleep mode.

        This creates a funny situation .. if a node wants to request the latest value of another node .. the other node has to process the request and responde accordingly. This will not working if the other node is sleeping.

        If the same nodes requests data from the gateway which is online .. the gateway does not process the message and querys the controller to supply the data .. which it does not have.

        Sofar that I understand the request feature it is utterly useless. Either all responses should come from the controller or all responses should come from the designated destination of the message. In the current design it is mixed and is working different for nodes and gateways as destination.

        1 Reply Last reply
        0
        • cimba007C Offline
          cimba007C Offline
          cimba007
          wrote on last edited by
          #7

          Okay .. I tried the following:

          void loop()
          {
            Serial.println(".");
            request(0,V_LIGHT_LEVEL,10);
            wait(50);
            sleep(5000);
          }
          

          0_1472320551772_upload-8f40a3ca-539e-4f22-ad15-0e56f62feeae

          But I get no response as node 10 is 99% of the time in sleep mode.

          This creates a funny situation .. if a node wants to request the latest value of another node .. the other node has to process the request and responde accordingly. This will not working if the other node is sleeping.

          If the same nodes requests data from the gateway which is online .. the gateway does not process the message and querys the controller to supply the data .. which it does not have.

          Sofar that I understand the request feature it is utterly useless. Either all responses should come from the controller or all responses should come from the designated destination of the message. In the current design it is mixed and is working different for nodes and gateways as destination.

          MySensor 1.5

          0_1472321377252_upload-750e6187-f0e0-4cba-857d-3b1601e664bc ![0_1472321069793_upload-385a2970-1384-4d2a-9076-4b7f9e32ca1a](Uploading 100%)

          MySensor 2.0

          0_1472321343368_upload-a2d76890-60bc-47b3-af53-e2b325f53961 ![0_1472321136082_upload-83419ed7-f4e0-4ba9-a064-be915feb3476](Uploading 100%)

          From this reading the controller should never respond to request messages, the destination node had to handle the responde itself. Correct me if I am wrong but this is how it is written in the mysensor documentation.

          J 1 Reply Last reply
          0
          • cimba007C cimba007

            Okay .. I tried the following:

            void loop()
            {
              Serial.println(".");
              request(0,V_LIGHT_LEVEL,10);
              wait(50);
              sleep(5000);
            }
            

            0_1472320551772_upload-8f40a3ca-539e-4f22-ad15-0e56f62feeae

            But I get no response as node 10 is 99% of the time in sleep mode.

            This creates a funny situation .. if a node wants to request the latest value of another node .. the other node has to process the request and responde accordingly. This will not working if the other node is sleeping.

            If the same nodes requests data from the gateway which is online .. the gateway does not process the message and querys the controller to supply the data .. which it does not have.

            Sofar that I understand the request feature it is utterly useless. Either all responses should come from the controller or all responses should come from the designated destination of the message. In the current design it is mixed and is working different for nodes and gateways as destination.

            MySensor 1.5

            0_1472321377252_upload-750e6187-f0e0-4cba-857d-3b1601e664bc ![0_1472321069793_upload-385a2970-1384-4d2a-9076-4b7f9e32ca1a](Uploading 100%)

            MySensor 2.0

            0_1472321343368_upload-a2d76890-60bc-47b3-af53-e2b325f53961 ![0_1472321136082_upload-83419ed7-f4e0-4ba9-a064-be915feb3476](Uploading 100%)

            From this reading the controller should never respond to request messages, the destination node had to handle the responde itself. Correct me if I am wrong but this is how it is written in the mysensor documentation.

            J Offline
            J Offline
            jkandasa
            Plugin Developer
            wrote on last edited by jkandasa
            #8

            @cimba007 said:

            From this reading the controller should never respond to request messages, the destination node had to handle the responde itself. Correct me if I am wrong but this is how it is written in the mysensor documentation.

            Controller receives request from gateway, So it is doing it's job.
            It is correct for other nodes not for gateway node

            Think other way, with the current design,

            • A node wants to get it is own state/configuration/etc from controller, it has to be sent to gateway(default). So gateway forwards to controller and controller responds back.
            • If we change this step gateway will respond. But if node wants to get it own configuration/state/etc., from gateway it never reach to controller. Gateway will deal with it's local sensor id.
            • As per current design you cannot request gateway's sensor data
            Workaround #1
            • You have to move your sensor from gateway node to non-gateway node. and use non-gateway node id as destination
            Workaround #2 (MyController.org specific)
            • Create new dummy sensor on a node from where you are requesting data
            • Add Forward payload for gateway-sensor data to node-dummy-sensor
            • do self request with dummy-sensor id
            • My controller reads dummy-sensor-data(gateway sensor data) and reports back to your node
            1 Reply Last reply
            0
            • cimba007C Offline
              cimba007C Offline
              cimba007
              wrote on last edited by
              #9

              Okay, thanks for this very good explanation.

              @HEK: Would it be possible to adjust the current documentation of mysensor 2.0 request feature to include jkandasa's explanation? If it confuses me I think it might confuse other people as well.

              Requesting its own configuration from the controller is a usecase I never thought about.

              I thought saveState and loadState should be used to store this data on the node itself.

              WORKAROUND #3 ;-)

              To mitigate the issue I think I will save the V_ARMED state on the nodes. In addition to that my nodes will query their own V_ARMED status from the controler. Even if the change of status from CONTROLLER->NODE was not received by the node the node will eventually update to the correct status.

              Still somehow sad that there is currently no way for a node to request data from other nodes if they are offline. This could be addressed by changing the request feature:

              @HEK: Do you think this is something other users might want as well? If so I would gladly open an issue as featurerequest on github.

              • Request data from controller
              • Request data from destination node

              This would make clear what the request function is for and what the expected result would be.

              J 1 Reply Last reply
              0
              • cimba007C cimba007

                Okay, thanks for this very good explanation.

                @HEK: Would it be possible to adjust the current documentation of mysensor 2.0 request feature to include jkandasa's explanation? If it confuses me I think it might confuse other people as well.

                Requesting its own configuration from the controller is a usecase I never thought about.

                I thought saveState and loadState should be used to store this data on the node itself.

                WORKAROUND #3 ;-)

                To mitigate the issue I think I will save the V_ARMED state on the nodes. In addition to that my nodes will query their own V_ARMED status from the controler. Even if the change of status from CONTROLLER->NODE was not received by the node the node will eventually update to the correct status.

                Still somehow sad that there is currently no way for a node to request data from other nodes if they are offline. This could be addressed by changing the request feature:

                @HEK: Do you think this is something other users might want as well? If so I would gladly open an issue as featurerequest on github.

                • Request data from controller
                • Request data from destination node

                This would make clear what the request function is for and what the expected result would be.

                J Offline
                J Offline
                jkandasa
                Plugin Developer
                wrote on last edited by jkandasa
                #10

                @cimba007 said:

                I thought saveState and loadState should be used to store this data on the node itself.

                Yes, saveState and loadState used to store data on local node itself (EEPROM). Do not get confused requests with loadState and saveState. Both are completely different ;)

                cimba007C 1 Reply Last reply
                0
                • J jkandasa

                  @cimba007 said:

                  I thought saveState and loadState should be used to store this data on the node itself.

                  Yes, saveState and loadState used to store data on local node itself (EEPROM). Do not get confused requests with loadState and saveState. Both are completely different ;)

                  cimba007C Offline
                  cimba007C Offline
                  cimba007
                  wrote on last edited by
                  #11

                  @jkandasa

                  I just never thought that requesting your own configuration from the controller would be needed, exactly as there is saveState and loadState so requesting from controller would be unnecessary.

                  J 1 Reply Last reply
                  0
                  • cimba007C cimba007

                    @jkandasa

                    I just never thought that requesting your own configuration from the controller would be needed, exactly as there is saveState and loadState so requesting from controller would be unnecessary.

                    J Offline
                    J Offline
                    jkandasa
                    Plugin Developer
                    wrote on last edited by
                    #12

                    @cimba007 said:

                    I just never thought that requesting your own configuration from the controller would be needed, exactly as there is saveState and loadState so requesting from controller would be unnecessary.

                    It is necessary in some cases,

                    • When you want to get offset/calibration values.
                    • Smart-sleep recently added, before when node wake-up get some date(adjust sleep duration) from controller with request
                    • etc.,
                    1 Reply Last reply
                    0
                    • cimba007C Offline
                      cimba007C Offline
                      cimba007
                      wrote on last edited by cimba007
                      #13

                      @jkandasa said:

                      It is necessary in some cases,

                      • Smart-sleep recently added, before when node wake-up get some date(adjust sleep duration) from controller with request

                      Yep .. but this would be even more useful if one node could query other nodes data and receive the resonse from the controller (if the other node is sleeping).

                      Again .. my proposal is to differentiate between:

                      • Request data from controller (for any other node, including gateway) ( = history query of most recent update the controller knows about)
                      • Request data from destination node ( = live query )

                      Edit: I just discovered resource groups on mycontroller .. think this will help out a lot with my planned workaround ;-)

                      Edit2: I could not help myself and request an improvement: https://github.com/mysensors/MySensors/issues/574

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      13

                      Online

                      11.7k

                      Users

                      11.2k

                      Topics

                      113.0k

                      Posts


                      Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                      • Login

                      • Don't have an account? Register

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