request variable from gateway
-
@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.
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.
-
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.
@cimba007 AFAIK, earlier version of MySensors.org does not support any sensors. It was acting only as a gateway. never control any sensors.
requestfeature 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
requestfeature 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 as0, gateway believes it is for controller.In your case it happens as follows,
- You requested sensor
0ofV_ARMEDstatus and destination is0(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 meansnodeId=50requestedV_ARMEDdata ofSensorId 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).
- You requested sensor
-
Okay .. I tried the following:
void loop() { Serial.println("."); request(0,V_LIGHT_LEVEL,10); wait(50); sleep(5000); }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.
-
Okay .. I tried the following:
void loop() { Serial.println("."); request(0,V_LIGHT_LEVEL,10); wait(50); sleep(5000); }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

MySensor 2.0

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.
-
Okay .. I tried the following:
void loop() { Serial.println("."); request(0,V_LIGHT_LEVEL,10); wait(50); sleep(5000); }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

MySensor 2.0

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.
@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 nodeThink 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 payloadfor 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
-
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.
-
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.
@cimba007 said:
I thought saveState and loadState should be used to store this data on the node itself.
Yes,
saveStateandloadStateused to store data on local node itself (EEPROM). Do not get confusedrequestswithloadStateandsaveState. Both are completely different ;) -
@cimba007 said:
I thought saveState and loadState should be used to store this data on the node itself.
Yes,
saveStateandloadStateused to store data on local node itself (EEPROM). Do not get confusedrequestswithloadStateandsaveState. Both are completely different ;) -
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.
@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.,
-
@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
- Smart-sleep recently added, before when node wake-up get some date(adjust sleep duration) from controller with