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. Bug Reports
  3. [SOLVED] V_DIMMER broken

[SOLVED] V_DIMMER broken

Scheduled Pinned Locked Moved Bug Reports
8 Posts 3 Posters 3.1k Views 4 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.
  • T Offline
    T Offline
    tlustoch
    wrote on last edited by Yveaux
    #1

    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

    1 Reply Last reply
    0
    • H Offline
      H Offline
      hek
      Admin
      wrote on last edited by hek
      #2

      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?)

      T 2 Replies Last reply
      0
      • H hek

        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?)

        T Offline
        T Offline
        tlustoch
        wrote on last edited by
        #3

        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?

        1 Reply Last reply
        0
        • H Offline
          H Offline
          hek
          Admin
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • H hek

            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?)

            T Offline
            T Offline
            tlustoch
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            • per.ohmanP Offline
              per.ohmanP Offline
              per.ohman
              wrote on last edited by
              #6

              I have the same problem with v_dimmer value.

              Any solution?

              1 Reply Last reply
              0
              • H Offline
                H Offline
                hek
                Admin
                wrote on last edited by
                #7

                @per-ohman

                Download 1.5.4

                1 Reply Last reply
                0
                • per.ohmanP Offline
                  per.ohmanP Offline
                  per.ohman
                  wrote on last edited by
                  #8

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

                  1 Reply Last reply
                  1

                  Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                  Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                  With your input, this post could be even better 💗

                  Register Login
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  18

                  Online

                  12.0k

                  Users

                  11.2k

                  Topics

                  113.4k

                  Posts


                  Copyright 2025 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