[SOLVED] V_DIMMER broken



  • Hi developers,
    V_DIMMER=V_PERCENTAGE is not working properly.

    You can try DimmableLight example and send several V_DIMMER messages (try for example send values 57 and 0 and see what is resulting state) to see the problem.

    After little research, I found that since commit b0ef810 (one commit before v. 1.5.2)
    the was removed a chunk of code in MySensor.cpp around line 588

    // Add string termination, good if we later would want to print it.
    	msg.data[mGetLength(msg)] = '\0'; 
    

    When I put this piece of code back, V_DIMMER is working again.
    Sincerely
    Hynek Baran


  • Admin

    What version/type of gateway and how does the log look like?

    (does it work again when you add the code in node or gateway?)



  • Yes, it works correctly when the above code is put back in the (node's) MySensor.cpp.

    My gateway's version is 1.5. I may try to upgrade, but not right now (in a few days).

    I will post a log but later (within a few hours), if you will be still interested.

    Do I understand well that you have not any troubles with DimmableLight example in version 1.5.3?


  • Admin

    Talked about the issue with @tekka and @Anticimex last night. There might be a problem for certain messages after the removal that must be resolved.



  • Hi developers.
    I did a little debugging job, as you will see, missing \0 terminator is causing troubles.

    So, I used slightly modified incomingMessage() DimmableLight example (little bit more logging is here):

    void incomingMessage(const MyMessage &message)
    {
      if (message.type == V_LIGHT) {
        Serial.print( "V_LIGHT command received. Value is " );
        Serial.println( message.data  );
        
        int lstate= atoi( message.data );
        Serial.print( "V_LIGHT new state: " );
        Serial.println( lstate );
        
        if ((lstate<0)||(lstate>1)) {
          Serial.println( "V_LIGHT data invalid (should be 0/1)" );
          return;
        }
        LastLightState=lstate;
        gw.saveState(EPROM_LIGHT_STATE, LastLightState);
        
        if ((LastLightState==LIGHT_ON)&&(LastDimValue==0)) {
           //In the case that the Light State = On, but the dimmer value is zero,
           //then something (probably the controller) did something wrong,
           //for the Dim value to 100%
          LastDimValue=100;
          gw.saveState(EPROM_DIMMER_LEVEL, LastDimValue);
        }
        
        //When receiving a V_LIGHT command we switch the light between OFF and the last received dimmer value
        //This means if you previously set the lights dimmer value to 50%, and turn the light ON
        //it will do so at 50%
      }
      else if (message.type == V_DIMMER) {
        Serial.print( "V_DIMMER command received. Value is " );
        Serial.println( message.data  );
        int dimvalue= atoi( message.data );
        Serial.print( "V_DIMMER new state: " );
        Serial.println( dimvalue );
        if ((dimvalue<0)||(dimvalue>100)) {
          Serial.println( "V_DIMMER data invalid (should be 0..100)" );
          return;
        }
        if (dimvalue==0) {
          LastLightState=LIGHT_OFF;
        }
        else {
          LastLightState=LIGHT_ON;
          LastDimValue=dimvalue;
          gw.saveState(EPROM_DIMMER_LEVEL, LastDimValue);
        }
      }
      else {
        Serial.println( "Invalid command received..." );  
        return;
      }
    

    I sent messages 34%, 100%, 49% and 0% to the node.
    The log is here:

    send: 31-31-0-0 s=255,c=3,t=15,pt=2,l=2,sg=0,st=ok:0
    send: 31-31-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,st=ok:1.5.3
    send: 31-31-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
    read: 0-0-31 s=255,c=3,t=6,pt=0,l=1,sg=0:M
    send: 31-31-0-0 s=255,c=3,t=15,pt=2,l=2,sg=0,st=ok:0
    send: 31-31-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,st=ok:1.5.3
    send: 31-31-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
    sensor started, id=31, parent=0, distance=1
    send: 31-31-0-0 s=255,c=3,t=11,pt=0,l=13,sg=0,st=ok:Dimable Light
    send: 31-31-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0
    send: 31-31-0-0 s=1,c=0,t=4,pt=0,l=0,sg=0,st=ok:
    Light state: OFF
    send: 31-31-0-0 s=1,c=1,t=3,pt=2,l=2,sg=0,st=ok:0
    Node ready to receive messages...
    read: 0-0-31 s=1,c=1,t=3,pt=0,l=2,sg=0:34
    V_DIMMER command received. Value is 340able Light
    V_DIMMER new state: 340
    V_DIMMER data invalid (should be 0..100)
    read: 0-0-31 s=1,c=1,t=3,pt=0,l=3,sg=0:100
    V_DIMMER command received. Value is 100able Light
    V_DIMMER new state: 100
    Light state: ON, Level: 100
    send: 31-31-0-0 s=1,c=1,t=3,pt=2,l=2,sg=0,st=ok:100
    read: 0-0-31 s=1,c=1,t=3,pt=0,l=2,sg=0:49
    V_DIMMER command received. Value is 490able Light
    V_DIMMER new state: 490
    V_DIMMER data invalid (should be 0..100)
    read: 0-0-31 s=1,c=1,t=3,pt=0,l=1,sg=0:0
    V_DIMMER command received. Value is 090able Light
    V_DIMMER new state: 90
    Light state: ON, Level: 90
    send: 31-31-0-0 s=1,c=1,t=3,pt=2,l=2,sg=0,st=ok:90
    

    Look for "V_DIMMER command received. Value is ..." lines. Makes a sense?

    I am not ready to update my 1.5 gateway now, sorry. If this is a problem, I can do it in a few weeks.
    HB



  • I have the same problem with v_dimmer value.

    Any solution?


  • Admin

    @per-ohman

    Download 1.5.4



  • Thanks for help. I installed 1.5.4 and reprogrammed the MQQTgateway and Dimmablelight and now its working perfect.


Log in to reply
 

Suggested Topics

  • 33
  • 5
  • 8
  • 11
  • 2
  • 6

25
Online

11.2k
Users

11.1k
Topics

112.5k
Posts