Sensor state



  • I'm building MySensors node connected to the relay.
    It's presented as BINARY sensor type.
    Mycontroller properly shows node with a child sensor.
    But nowhere in UI I'm able to change sensor state.
    A few questions:

    • Does node have to report current sensor state?
    • when node gets new state from controller, is it better to save state in EEPROM or
    • is it better to request new state from controller every time node boots?
    • I understood controller keeps sensor state in the database. Node has ability to report sensor state. Which value has higher priority - state in the database or recently reported value from sensor?

  • ADMIN

    @benya To change sensor(relay) state you have sensor/sensor variable entry on MyController server. We can add Sensor/Sensor variable in multiple ways.

    • Does node have to report current sensor state?

    Yes, By reporting sensor/sensor variable state from node, when node turns ON, entry created on MyController

    • when node gets new state from controller, is it better to save state in EEPROM or
    • is it better to request new state from controller every time node boots?

    It is about your convenience, you can either store state on Node's EEPROM, or you can request from MyController when you want.

    • I understood controller keeps sensor state in the database. Node has ability to report sensor state. Which value has higher priority - state in the database or recently reported value from sensor?

    MyController stores all the values on it is database. When node reports a state, it stores on database as recent value.



  • If node performs the following actions:

    • boot
    • request current value from controller
    • receive value and change relay state accordingly
    • report current value to the controller
    • smartSleep 1min

    Is it sufficient to change its state from controller?


  • ADMIN

    @benya Yes, it can perform.

    smartSleep 1min

    You have to enable Smart Sleep on node settings in MyController.



  • How does node request its own sensor's value from controller?
    Should it call request(uint8_t childSensorId, uint8_t variableType, uint8_t destination)?
    destination should be 0?
    What should be used for childSensorId?
    Is it the same ID used to present this sensor (e.g. childSensorId passed to present() function)?


  • ADMIN

    @benya

    How does node request its own sensor's value from controller?
    Should it call request(uint8_t childSensorId, uint8_t variableType, uint8_t destination)?

    Specifying destination id is not required, when request data from the controller or you can specify it as the gateway address.

    request(uint8_t childSensorId, uint8_t variableType);
    or
     request(const uint8_t childSensorId, const uint8_t variableType, 0);
    


  • What about appropriate value of childSensorId when sensor belongs to the same node that makes request?


  • ADMIN

    @benya

    What about appropriate value of childSensorId when sensor belongs to the same node that makes request?

    In a node, we have a different type of sensors.
    In a sensor, we have a different type of variables(SensorVariables).

    Here childId is sensorId and variableType defines which type of variable.

    Example: I have binary (S_BINARY) sensor with the id 21 and Status and Watts (V_STATUS and V_WATTS) variables. I want to know the current state of my Status variable on MyController. I have to call the following code from my Arduino/MySensors node.

    request(21, V_STATUS);
    

    I will receive the response on,

    void receive(const MyMessage &message){
      if (message.sensor == 21 && message.type == V_STATUS) {
        //Do some actions with, message.getBool();
      }
    }
    


  • If I have two nodes (#1 and #2) and each has sensor with ID '21' and each node calls request(21, V_STATUS), which sensor values they will get from controller?
    Node #1 will get his node_1/sensor_21 value and node #2 will get his node_2/sensor_21 value?


  • ADMIN

    @benya

    If I have two nodes (#1 and #2) and each has sensor with ID '21' and each node calls request(21, V_STATUS), which sensor values they will get from controller?
    Node #1 will get his node_1/sensor_21 value and node #2 will get his node_2/sensor_21 value?

    Yes, You can have any number of nodes with the same sensorId. When MyController receives a request from a node, it knows node Id too. node id will be added on behind the scene when you raise a request.


Log in to reply
 

7
Online

439
Users

231
Topics

1378
Posts

Looks like your connection to MYCONTROLLER.ORG was lost, please wait while we try to reconnect.