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. Controllers
  3. Home Assistant
  4. Home Assistant - How to recognize MySensors nodes

Home Assistant - How to recognize MySensors nodes

Scheduled Pinned Locked Moved Home Assistant
home assistant
64 Posts 7 Posters 46.1k 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.
  • A Offline
    A Offline
    acmbc68
    wrote on last edited by
    #17

    Thanks @martinhjelmare

    As per https://home-assistant.io/blog/posts/2/, all the components should be under the homeassistant install, so it shouldn't be a brain-wrecker to change those out.

    I'll start giving it a whirl tonight.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      acmbc68
      wrote on last edited by
      #18

      Ok.
      First of all - still no joy. Can't get any communications from MySensors to homeassistant.

      Trying to tackle this bottom up. Thought it might be an issue with PySerial, but that reads data OK from the serial port:

      import serial as serial
      print ("starting")
      ser = serial.Serial (
          port='COM4',
          baudrate=115200,
          parity=serial.PARITY_NONE,
          stopbits=serial.STOPBITS_ONE,
          bytesize=serial.EIGHTBITS
      )
      
      ser.flushInput()
      ser.flushOutput()
      
      print("connected to: " + ser.portstr)
      count=1
      
      while True:
              try:
                      data_raw = ser.readline()
                      print(data_raw)
              except serial.SerialException:
                      print ("SERIAL ERROR")
                      exit(1)
      

      This results in what is expected:

      starting
      connected to: COM4
      b'0;0;3;0;14;Gateway startup complete.\n'
      b'0;0;3;0;9;read: 1-1-0 s=2,c=1,t=23,pt=2,l=2:0\n'
      b'1;2;1;0;23;0\n'
      b'0;0;3;0;9;read: 1-1-0 s=1,c=1,t=0,pt=7,l=5:25.0\n'
      b'1;1;1;0;0;25.0\n'
      b'0;0;3;0;9;read: 1-1-0 s=0,c=1,t=1,pt=7,l=5:84.0\n'
      b'1;0;1;0;1;84.0\n'
      b'0;0;3;0;9;read: 1-1-0 s=3,c=1,t=16,pt=0,l=1:0\n'
      b'1;3;1;0;16;0\n'
      

      (this is a four sensor node - Temp, Humidity, light level and presence detection)

      I am trying to test the pymysensors (mysensors.mysensors) and I believe that is where the situation may originate.

      Basically, pymysensors just hangs there on calling gw.start() in the code below:

      
      import mysensors.mysensors as mysensors
      import logging
      
      def event(type, nid):
          print(type+" "+str(nid))
      
      gw = mysensors.SerialGateway('COM4', event)
      logging.warning("Created SerialGateway")
      print (gw)
      gw.start()
      

      Trying to wrangle through the pymysensors code...Could it be the windows threading implementation (gw.start()) causing some type of hung access to the serial port? Unfortunately, no messages (print or logging) that I put in the pymysensors actually get printed out (maybe due to being in a background thread?

      1 Reply Last reply
      0
      • martinhjelmareM Offline
        martinhjelmareM Offline
        martinhjelmare
        Plugin Developer
        wrote on last edited by
        #19

        For logging to work you have to set the level lower, and you should activate debug mode in pymysensors.

        import mysensors.mysensors as mysensors
        import logging
        
        logging.basicConfig(level=logging.DEBUG)
        
        def event(type, nid):
            print(type+" "+str(nid))
        
        gw = mysensors.SerialGateway('COM4', event)
        logging.warning("Created SerialGateway")
        print (gw)
        
        gw.debug = True
        
        gw.start()
        

        This is my console log when testing my fifo_queue branch.

        In [1]: %paste
        import mysensors.mysensors as mysensors
        import logging
        
        logging.basicConfig(level=logging.DEBUG)
        
        def event(type, nid):
            print(type+" "+str(nid))
        
        ## -- End pasted text --
        
        In [2]: gw = mysensors.SerialGateway('/dev/ttyUSB0', event)
        
        In [3]: gw.debug = True
        
        In [4]: gw.start()
        INFO:mysensors.mysensors:Trying to connect to /dev/ttyUSB0
        
        In [5]: INFO:mysensors.mysensors:/dev/ttyUSB0 is open...
        INFO:mysensors.mysensors:Connected to /dev/ttyUSB0
        INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:gateway started, id=0, parent=0, distance=0
        
        KeyboardInterrupt
        
        In [5]: gw.stop()
        INFO:mysensors.mysensors:Disconnecting from /dev/ttyUSB0
        INFO:mysensors.mysensors:Stopping thread
        

        Sometimes I get the following problem when I start the thread:

        WARNING:mysensors.mysensors:Error decoding message from gateway, probably received bad byte.
        

        A new gateway instance and restarting it always solves that. Sometimes messages seem to go out of sync, then it can be good to reconnect power to the gateway, also. But that has been very rare:

        Exception in thread Thread-1:
        Traceback (most recent call last):
          File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
            self.run()
          File "/home/martin/Dev/pymysensors/mysensors/mysensors.py", line 312, in run
            response = self.handle_queue()
          File "/home/martin/Dev/pymysensors/mysensors/mysensors.py", line 222, in handle_queue
            reply = func(*args, **kwargs)
          File "/home/martin/Dev/pymysensors/mysensors/mysensors.py", line 105, in logic
            msg = Message(data)
          File "/home/martin/Dev/pymysensors/mysensors/mysensors.py", line 397, in __init__
            self.decode(data)
          File "/home/martin/Dev/pymysensors/mysensors/mysensors.py", line 417, in decode
            self.sub_type) = [int(f) for f in data]
          File "/home/martin/Dev/pymysensors/mysensors/mysensors.py", line 417, in <listcomp>
            self.sub_type) = [int(f) for f in data]
        ValueError: invalid literal for int() with base 10: 'read: 1-1-0 s=1,c=1,t=0'
        
        1 Reply Last reply
        0
        • martinhjelmareM martinhjelmare

          @humblehacker

          Yes, it should be enabled by default, that's why I didn't mention it in my first advice. But it's good to double check anyway.

          Are you sure you have two different instances of the Arduino IDE running when you test? Only one serial monitor can be active at a time, per IDE. It's not enough to open a second sketch window. You have to start the IDE twice from the start menu, or however you start it. Also, check the ports. You should see different headings in the serial monitor window, specifying the port.

          What hardware are you using?

          H Offline
          H Offline
          humblehacker
          wrote on last edited by
          #20

          @martinhjelmare said:

          @humblehacker

          Yes, it should be enabled by default, that's why I didn't mention it in my first advice. But it's good to double check anyway.

          Are you sure you have two different instances of the Arduino IDE running when you test? Only one serial monitor can be active at a time, per IDE. It's not enough to open a second sketch window. You have to start the IDE twice from the start menu, or however you start it. Also, check the ports. You should see different headings in the serial monitor window, specifying the port.

          What hardware are you using?

          I had replied to this a couple days ago but it must not have posted so I apologize for the tardy response...
          I think I might've narrowed down to what my problem is but first I'll reply to your question. My first test used two different instances of the IDE running on two different systems.
          The gateway controller sketch was compiled on Windows 10 w/Arduino 1.6.6 and ran successfully on an Arduino UNO. The sensor/sender sketch was compiled on my Ubuntu MATE 15.10 laptop with Arduino 1.6.6 on an Arduino Leonardo.

          Interestingly, I just tried swapping out the hardware so the Uno connected to Linux and the Leo connected to Windows. Sure enough, the Uno works as expected running both the sensor and the gateway sketch on Linux and Windows while the Leo won't work with any MySensors sketch on either Linux or Windows... So the problem may be related to the serial port on the ATMega32u4. As I mentioned earlier, I was able to get the Leo to work with the standard RF24 library, so it must be something about the Mysensors library that doesn't get along with the ATMega32u4 processors...
          I'll try running my Arduino Nano now to see if it works with signals sent from my Uno.

          1 Reply Last reply
          0
          • H Offline
            H Offline
            humblehacker
            wrote on last edited by
            #21

            UPDATE:
            YES!!! The Uno connected to the motion sensor is transmitting data to my Arduino Nano gateway and I can finally see the data on the serial monitor! Now I just need to reconnect the gateway to Home Assistant to see what it picks up.
            Lesson learned as of the present is to only use ATMega328 processors like the Uno, Nano, Pro Mini etc... Most of my controllers at this point are based on the 32u4 so it would be good if we could figure out why the Leo boards don't work with MYS... Has anybody else experienced this problem?

            1 Reply Last reply
            0
            • H Offline
              H Offline
              humblehacker
              wrote on last edited by
              #22

              Sure enough-

              WARNING:mysensors.mysensors:Error decoding message from gateway, probably received bad byte.
              

              @martinhjelmare- How do I create a new gateway instance? Simply restart?

              martinhjelmareM 1 Reply Last reply
              0
              • H humblehacker

                Sure enough-

                WARNING:mysensors.mysensors:Error decoding message from gateway, probably received bad byte.
                

                @martinhjelmare- How do I create a new gateway instance? Simply restart?

                martinhjelmareM Offline
                martinhjelmareM Offline
                martinhjelmare
                Plugin Developer
                wrote on last edited by
                #23

                @humblehacker

                If using home assistant, it's enough to restart home assistant, to get a new gateway instance and reconnect.

                1 Reply Last reply
                0
                • H Offline
                  H Offline
                  humblehacker
                  wrote on last edited by
                  #24

                  success!.png
                  :smiley:
                  Other than the fact that my log seems to think its yesterday... I just need to find out why I can't use MySensors with Any ATMega32u4 devices... Attiny85/Trinket support would be nice too but I dont need to push my luck...

                  martinhjelmareM 1 Reply Last reply
                  0
                  • H humblehacker

                    success!.png
                    :smiley:
                    Other than the fact that my log seems to think its yesterday... I just need to find out why I can't use MySensors with Any ATMega32u4 devices... Attiny85/Trinket support would be nice too but I dont need to push my luck...

                    martinhjelmareM Offline
                    martinhjelmareM Offline
                    martinhjelmare
                    Plugin Developer
                    wrote on last edited by
                    #25

                    @humblehacker

                    :thumbsup:

                    1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      kielnino
                      wrote on last edited by
                      #26

                      I'm still stuck with the import of sensors to home-assitant. Can someone please post his configuration.yaml? I Wonder if I made a stupid configuration error there.
                      Do I need the "inclusion mode" of the Gateway or does home-assistant handle the detection of new sensors? In the serial monitor all the communication between the nodes and the Gateway is looking good, but in home-assistant they won't show up.

                      martinhjelmareM 1 Reply Last reply
                      0
                      • K kielnino

                        I'm still stuck with the import of sensors to home-assitant. Can someone please post his configuration.yaml? I Wonder if I made a stupid configuration error there.
                        Do I need the "inclusion mode" of the Gateway or does home-assistant handle the detection of new sensors? In the serial monitor all the communication between the nodes and the Gateway is looking good, but in home-assistant they won't show up.

                        martinhjelmareM Offline
                        martinhjelmareM Offline
                        martinhjelmare
                        Plugin Developer
                        wrote on last edited by
                        #27

                        @kielnino

                        Home assistant adds the new device after the sensor has presented itself to the gateway and sent at least one value. So proper presentation messages has to be sent by the node and received by the gateway. These include node id, sensor child id, sketch name and presentation "S_VALUE". Then one value should be sent using the correct "V_VALUE".

                        See the mysensor API documentation for the S_VALUES and V_VALUES.

                        See below for the sensors excerpt from my config. If you have multiple sensor platforms you need to increment the sensor name with a number: sensor, sensor 2, sensor 3, etc. All sensor platforms should be one continuing block in the config. Note that this is not my config for my github fork of home assistant. For that one, you need to add a separate domain in the config for mysensors.

                        ###########################################################
                        # SENSORS
                        ###########################################################
                        
                        # Mysensors
                        sensor:
                          platform: mysensors
                          port: "/dev/ttyUSB0"
                        #  debug:
                        
                        # forecast.io
                        sensor 2:
                          platform: forecast
                          api_key: ***censored***
                          monitored_conditions:
                            - summary
                            - precip_type
                            - precip_intensity
                            - temperature
                            - dew_point
                            - wind_speed
                            - wind_bearing
                            - cloud_cover
                            - humidity
                            - pressure
                            - visibility
                            - ozone
                        
                        # time_date
                        sensor 3:
                          platform: time_date
                          display_options:
                            - 'time'
                            - 'date'
                            - 'date_time'
                            - 'time_date'
                            - 'time_utc'
                            - 'beat'
                        
                        1 Reply Last reply
                        0
                        • D Offline
                          D Offline
                          drock1985
                          wrote on last edited by
                          #28

                          Hi @martinhjelmare

                          Just wanted to first say thank you for the port of MySensors to Home-Assistant. I'm currently in the process of switching from Domoticz to Home-Assistant, and have a quick question about getting my node recognized.

                          I have a Doorbell/Chome monitor, and it gets the ID from the gateway no problem. It shows up in HA after pressing the doorbell button (as a motion sensor, since that is the trigger) but I can't control the chime itself (aka, whether the bell rings if the door is pressed or not) which is set as a light switch.

                          I know from reading this thread that in order for a device to first appear in HA, it must send a command to the gateway. Is there any way for me through HA to force a command to the childid light switch, so that it will show up on its own?

                          Thanks!

                          My Projects
                          2 Door Chime Sensor
                          Washing Machine Monitor

                          martinhjelmareM 1 Reply Last reply
                          0
                          • D drock1985

                            Hi @martinhjelmare

                            Just wanted to first say thank you for the port of MySensors to Home-Assistant. I'm currently in the process of switching from Domoticz to Home-Assistant, and have a quick question about getting my node recognized.

                            I have a Doorbell/Chome monitor, and it gets the ID from the gateway no problem. It shows up in HA after pressing the doorbell button (as a motion sensor, since that is the trigger) but I can't control the chime itself (aka, whether the bell rings if the door is pressed or not) which is set as a light switch.

                            I know from reading this thread that in order for a device to first appear in HA, it must send a command to the gateway. Is there any way for me through HA to force a command to the childid light switch, so that it will show up on its own?

                            Thanks!

                            martinhjelmareM Offline
                            martinhjelmareM Offline
                            martinhjelmare
                            Plugin Developer
                            wrote on last edited by martinhjelmare
                            #29

                            @drock1985

                            Hi!

                            First I'd just want to make clear that I'm not the original author or maintainer of pymysensors, which is the mysensors API that home assistant uses. I have just made some pull requests to pymysensors and I'd like to improve the functionality, if possible.

                            To answer your question, mysensors switches are not yet supported in home assistant. That's what one of my pull requests want to solve, but it has yet to be merged. There is currently no way of forcing a node to resend it's presentation, if that info is lacking on the gateway side. This could be solved after version 1.6 of mysensors gets released but it will take more development, both on pymysensors and home assistant sides.

                            If you want to make sure that the doorbell shows up in the GUI, before the first press of the button, just send the sensor value to the gateway, in the end of the setup function in your node sketch.

                            For example, if you have defined a msgMotion for the doorbell:

                            gw.send(msgMotion.set("0"));
                            
                            1 Reply Last reply
                            0
                            • D Offline
                              D Offline
                              drock1985
                              wrote on last edited by
                              #30

                              Hi @martinhjelmare

                              I decided to try this on a simplier sketch that I have, but still no luck. I added this line gw.send(lightMsgW.set("1")); to the end of void setup(). The sensor shows up at the top of the States screen in HA, but doesn't let me actually control it, and it doesn't show up in Switches or Lights.

                              Here is the sketch that I am using.

                              /**
                               * The MySensors Arduino library handles the wireless radio link and protocol
                               * between your home built sensors/actuators and HA controller of choice.
                               * The sensors forms a self healing radio network with optional repeaters. Each
                               * repeater and gateway builds a routing tables in EEPROM which keeps track of the
                               * network topology allowing messages to be routed to nodes.
                               *
                               * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
                               * Copyright (C) 2013-2015 Sensnology AB
                               * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
                               *
                               * Documentation: http://www.mysensors.org
                               * Support Forum: http://forum.mysensors.org
                               *
                               * This program is free software; you can redistribute it and/or
                               * modify it under the terms of the GNU General Public License
                               * version 2 as published by the Free Software Foundation.
                               *
                               *******************************
                               *
                               * REVISION HISTORY
                               * Version 1.0 - 6-December-2015, Derrick Rockwell
                               *
                               * DESCRIPTION
                               *This sketch uses two 30 bulb, 3mm LED holiday light strings. These
                               *can usually be found in most dollar stores/hardware stores and are 
                               *battery powered. This sketch uses digital pins 3 and 4 to power two 
                               *a string of lights each. Ex, one can control white lights the other
                               *could control multi-colour lights. 
                               */
                              
                              #define SN "HolidayLEDDeskLights"
                              #define SV "1.0"
                              
                              #include <MySensor.h> 
                              #include <SPI.h>
                              
                              #define MLED_PIN 3      // Pin Multi-Coloured LED's will attached to
                              #define WLED_PIN 5      // Pin White-Coloured LED's will attached to
                              #define FADE_DELAY 10  // Delay in ms for each percentage fade up/down (10ms = 1s full-range dim)
                              #define CHILD_ID0 3
                              #define CHILD_ID1 5
                              
                              MySensor gw;
                              
                              static int currentLevelM = 0;  // Current dim level...
                              static int currentLevelW = 0;  // Current dim level...
                              
                              MyMessage dimmerMsgM(MLED_PIN, V_DIMMER);
                              MyMessage lightMsgM(MLED_PIN, V_LIGHT);
                              MyMessage dimmerMsgW(WLED_PIN, V_DIMMER);
                              MyMessage lightMsgW(WLED_PIN, V_LIGHT);
                              
                              /***
                               * Dimmable LED initialization method
                               */
                              void setup()  
                              { 
                                Serial.println( SN ); 
                                Serial.println( SV );
                                gw.begin( incomingMessage );
                                
                                // Register the LED Dimmable Light with the gateway
                                gw.present( MLED_PIN, S_DIMMER );
                                gw.present( WLED_PIN, S_DIMMER );
                                
                                gw.sendSketchInfo(SN, SV);
                                // Pull the gateway's current dim level - restore light level upon sendor node power-up
                                gw.request( MLED_PIN, V_DIMMER );
                                gw.request( WLED_PIN, V_DIMMER );
                                gw.send(lightMsgW.set("1"));
                              }
                              
                              /***
                               *  Dimmable LED main processing loop 
                               */
                              void loop() 
                              {
                                gw.process();
                              }
                              
                              //For Multi Coloured Lights
                              void incomingMessage(const MyMessage &message) {
                              if (message.type == V_LIGHT || message.type == V_DIMMER) {
                                    // if (message.sensor <= 2)
                                    {
                                        //0: All Dimmers
                                        //1: LED 1
                                        //2: LED 2
                                        //  Retrieve the power or dim level from the incoming request message
                                        int requestedLevel = atoi( message.data );
                                        
                                        // Adjust incoming level if this is a V_LIGHT variable update [0 == off, 1 == on]
                                        requestedLevel *= ( message.type == V_LIGHT ? 100 : 1 );
                                        
                                        if ((message.sensor == CHILD_ID0) || (message.sensor == 0)){
                                          fadeToLevel ( requestedLevel, MLED_PIN, &currentLevelM );
                                          // Inform the gateway of the current DimmableLED's SwitchPower1 and LoadLevelStatus value...
                                          gw.send(lightMsgM.set(requestedLevel > 0 ? 1 : 0));
                                          gw.send(dimmerMsgM.set(requestedLevel) );
                                        }
                                        if ((message.sensor == CHILD_ID1) || (message.sensor == 0)){
                                          fadeToLevel( requestedLevel, WLED_PIN, &currentLevelW );
                                          // Inform the gateway of the current DimmableLED's SwitchPower1 and LoadLevelStatus value...
                                          gw.send(lightMsgW.set(requestedLevel > 0 ? 1 : 0));
                                          gw.send(dimmerMsgW.set(requestedLevel) );
                                        }
                                      }
                              }
                              }
                              
                              /***
                               *  This method provides a graceful fade up/down effect
                               */
                               // For Multi Coloured Lights
                              void fadeToLevel( int toLevel, int pin, int *currentLevel ) {
                                int delta = ( toLevel - (*currentLevel) ) < 0 ? -1 : 1;
                                while ( (*currentLevel) != toLevel ) {
                                  (*currentLevel) += delta;
                                  analogWrite( pin, (int)((*currentLevel) / 100. * 255) );
                                  delay( FADE_DELAY );
                                }
                              }
                              

                              My Projects
                              2 Door Chime Sensor
                              Washing Machine Monitor

                              martinhjelmareM H 2 Replies Last reply
                              0
                              • D drock1985

                                Hi @martinhjelmare

                                I decided to try this on a simplier sketch that I have, but still no luck. I added this line gw.send(lightMsgW.set("1")); to the end of void setup(). The sensor shows up at the top of the States screen in HA, but doesn't let me actually control it, and it doesn't show up in Switches or Lights.

                                Here is the sketch that I am using.

                                /**
                                 * The MySensors Arduino library handles the wireless radio link and protocol
                                 * between your home built sensors/actuators and HA controller of choice.
                                 * The sensors forms a self healing radio network with optional repeaters. Each
                                 * repeater and gateway builds a routing tables in EEPROM which keeps track of the
                                 * network topology allowing messages to be routed to nodes.
                                 *
                                 * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
                                 * Copyright (C) 2013-2015 Sensnology AB
                                 * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
                                 *
                                 * Documentation: http://www.mysensors.org
                                 * Support Forum: http://forum.mysensors.org
                                 *
                                 * This program is free software; you can redistribute it and/or
                                 * modify it under the terms of the GNU General Public License
                                 * version 2 as published by the Free Software Foundation.
                                 *
                                 *******************************
                                 *
                                 * REVISION HISTORY
                                 * Version 1.0 - 6-December-2015, Derrick Rockwell
                                 *
                                 * DESCRIPTION
                                 *This sketch uses two 30 bulb, 3mm LED holiday light strings. These
                                 *can usually be found in most dollar stores/hardware stores and are 
                                 *battery powered. This sketch uses digital pins 3 and 4 to power two 
                                 *a string of lights each. Ex, one can control white lights the other
                                 *could control multi-colour lights. 
                                 */
                                
                                #define SN "HolidayLEDDeskLights"
                                #define SV "1.0"
                                
                                #include <MySensor.h> 
                                #include <SPI.h>
                                
                                #define MLED_PIN 3      // Pin Multi-Coloured LED's will attached to
                                #define WLED_PIN 5      // Pin White-Coloured LED's will attached to
                                #define FADE_DELAY 10  // Delay in ms for each percentage fade up/down (10ms = 1s full-range dim)
                                #define CHILD_ID0 3
                                #define CHILD_ID1 5
                                
                                MySensor gw;
                                
                                static int currentLevelM = 0;  // Current dim level...
                                static int currentLevelW = 0;  // Current dim level...
                                
                                MyMessage dimmerMsgM(MLED_PIN, V_DIMMER);
                                MyMessage lightMsgM(MLED_PIN, V_LIGHT);
                                MyMessage dimmerMsgW(WLED_PIN, V_DIMMER);
                                MyMessage lightMsgW(WLED_PIN, V_LIGHT);
                                
                                /***
                                 * Dimmable LED initialization method
                                 */
                                void setup()  
                                { 
                                  Serial.println( SN ); 
                                  Serial.println( SV );
                                  gw.begin( incomingMessage );
                                  
                                  // Register the LED Dimmable Light with the gateway
                                  gw.present( MLED_PIN, S_DIMMER );
                                  gw.present( WLED_PIN, S_DIMMER );
                                  
                                  gw.sendSketchInfo(SN, SV);
                                  // Pull the gateway's current dim level - restore light level upon sendor node power-up
                                  gw.request( MLED_PIN, V_DIMMER );
                                  gw.request( WLED_PIN, V_DIMMER );
                                  gw.send(lightMsgW.set("1"));
                                }
                                
                                /***
                                 *  Dimmable LED main processing loop 
                                 */
                                void loop() 
                                {
                                  gw.process();
                                }
                                
                                //For Multi Coloured Lights
                                void incomingMessage(const MyMessage &message) {
                                if (message.type == V_LIGHT || message.type == V_DIMMER) {
                                      // if (message.sensor <= 2)
                                      {
                                          //0: All Dimmers
                                          //1: LED 1
                                          //2: LED 2
                                          //  Retrieve the power or dim level from the incoming request message
                                          int requestedLevel = atoi( message.data );
                                          
                                          // Adjust incoming level if this is a V_LIGHT variable update [0 == off, 1 == on]
                                          requestedLevel *= ( message.type == V_LIGHT ? 100 : 1 );
                                          
                                          if ((message.sensor == CHILD_ID0) || (message.sensor == 0)){
                                            fadeToLevel ( requestedLevel, MLED_PIN, &currentLevelM );
                                            // Inform the gateway of the current DimmableLED's SwitchPower1 and LoadLevelStatus value...
                                            gw.send(lightMsgM.set(requestedLevel > 0 ? 1 : 0));
                                            gw.send(dimmerMsgM.set(requestedLevel) );
                                          }
                                          if ((message.sensor == CHILD_ID1) || (message.sensor == 0)){
                                            fadeToLevel( requestedLevel, WLED_PIN, &currentLevelW );
                                            // Inform the gateway of the current DimmableLED's SwitchPower1 and LoadLevelStatus value...
                                            gw.send(lightMsgW.set(requestedLevel > 0 ? 1 : 0));
                                            gw.send(dimmerMsgW.set(requestedLevel) );
                                          }
                                        }
                                }
                                }
                                
                                /***
                                 *  This method provides a graceful fade up/down effect
                                 */
                                 // For Multi Coloured Lights
                                void fadeToLevel( int toLevel, int pin, int *currentLevel ) {
                                  int delta = ( toLevel - (*currentLevel) ) < 0 ? -1 : 1;
                                  while ( (*currentLevel) != toLevel ) {
                                    (*currentLevel) += delta;
                                    analogWrite( pin, (int)((*currentLevel) / 100. * 255) );
                                    delay( FADE_DELAY );
                                  }
                                }
                                
                                martinhjelmareM Offline
                                martinhjelmareM Offline
                                martinhjelmare
                                Plugin Developer
                                wrote on last edited by
                                #31

                                @drock1985

                                As I wrote above, switches are not supported yet, in the default releases of home assistant. That support only exists in my personal branches at github.

                                1 Reply Last reply
                                0
                                • D Offline
                                  D Offline
                                  drock1985
                                  wrote on last edited by
                                  #32

                                  @martinhjelmare

                                  And how would I install your branch of home-assistant then so that I can use it?

                                  My Projects
                                  2 Door Chime Sensor
                                  Washing Machine Monitor

                                  1 Reply Last reply
                                  0
                                  • martinhjelmareM Offline
                                    martinhjelmareM Offline
                                    martinhjelmare
                                    Plugin Developer
                                    wrote on last edited by martinhjelmare
                                    #33

                                    You can test it by cloning my fork of home-assistant (https://github.com/MartinHjelmare/home-assistant), then checkout my branch "mysensors-component-switch". Then install it with pip. See my console log below. BIG DISCLAIMER: This is work in progress and under development. You are cloning my branch, which is based off the home assistant dev branch, which is not a stable release.

                                    martin@martin-htpc:~$ mkvirtualenv -p python3 testhomeass
                                    Running virtualenv with interpreter /usr/bin/python3
                                    Using base prefix '/usr'
                                    New python executable in testhomeass/bin/python3
                                    Also creating executable in testhomeass/bin/python
                                    Installing setuptools, pip, wheel...done.
                                    virtualenvwrapper.user_scripts creating /home/martin/.virtualenvs/testhomeass/bin/predeactivate
                                    virtualenvwrapper.user_scripts creating /home/martin/.virtualenvs/testhomeass/bin/postdeactivate
                                    virtualenvwrapper.user_scripts creating /home/martin/.virtualenvs/testhomeass/bin/preactivate
                                    virtualenvwrapper.user_scripts creating /home/martin/.virtualenvs/testhomeass/bin/postactivate
                                    virtualenvwrapper.user_scripts creating /home/martin/.virtualenvs/testhomeass/bin/get_env_details
                                    (testhomeass)martin@martin-htpc:~$ cd Dev/
                                    (testhomeass)martin@martin-htpc:~/Dev$ mkdir testhomeass
                                    (testhomeass)martin@martin-htpc:~/Dev$ cd testhomeass/
                                    (testhomeass)martin@martin-htpc:~/Dev/testhomeass$ git clone git@github.com:MartinHjelmare/home-assistant.git
                                    Klonar till "home-assistant"...
                                    remote: Counting objects: 28876, done.
                                    remote: Total 28876 (delta 0), reused 0 (delta 0), pack-reused 28876
                                    Tar emot objekt: 100% (28876/28876), 25.45 MiB | 1.59 MiB/s, done.
                                    Analyserar delta: 100% (19679/19679), done.
                                    Kontrollerar anslutning... klart.
                                    (testhomeass)martin@martin-htpc:~/Dev/testhomeass$ cd home-assistant/
                                    (testhomeass)martin@martin-htpc:~/Dev/testhomeass/home-assistant$ git status 
                                    På grenen dev
                                    Din gren är à jour med "origin/dev".
                                    
                                    inget att checka in, arbetskatalogen ren
                                    (testhomeass)martin@martin-htpc:~/Dev/testhomeass/home-assistant$ git checkout mysensors-component-switch
                                    Grenen mysensors-component-switch ställdes in att spåra fjärrgrenen mysensors-component-switch från origin.
                                    Växlade till en ny gren "mysensors-component-switch"
                                    (testhomeass)martin@martin-htpc:~/Dev/testhomeass/home-assistant$ pip install .
                                    Processing /home/martin/Dev/testhomeass/home-assistant
                                    Collecting requests<3,>=2 (from homeassistant==0.9.0.dev0)
                                      Using cached requests-2.8.1-py2.py3-none-any.whl
                                    Collecting pyyaml<4,>=3.11 (from homeassistant==0.9.0.dev0)
                                    Collecting pytz>=2015.4 (from homeassistant==0.9.0.dev0)
                                      Using cached pytz-2015.7-py2.py3-none-any.whl
                                    Requirement already satisfied (use --upgrade to upgrade): pip>=7.0.0 in /home/martin/.virtualenvs/testhomeass/lib/python3.4/site-packages (from homeassistant==0.9.0.dev0)
                                    Collecting vincenty==0.1.3 (from homeassistant==0.9.0.dev0)
                                    Building wheels for collected packages: homeassistant
                                      Running setup.py bdist_wheel for homeassistant
                                      Stored in directory: /home/martin/.cache/pip/wheels/0d/98/ff/ecb5c632258e50fbc91b535762865e4a132eb966f5c28f00d7
                                    Successfully built homeassistant
                                    Installing collected packages: requests, pyyaml, pytz, vincenty, homeassistant
                                    Successfully installed homeassistant-0.9.0.dev0 pytz-2015.7 pyyaml-3.11 requests-2.8.1 vincenty-0.1.3
                                    (testhomeass)martin@martin-htpc:~/Dev/testhomeass/home-assistant$ hass
                                    Config directory: /home/martin/.homeassistant
                                    WARNING:homeassistant.bootstrap:Colorlog package not found, console coloring disabled
                                    INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: service=turn_off, domain=homeassistant>
                                    INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: service=turn_on, domain=homeassistant>
                                    INFO:homeassistant.bootstrap:Home Assistant core initialized
                                    INFO:homeassistant.loader:Loaded introduction from homeassistant.components.introduction
                                    INFO:homeassistant.loader:Loaded history from homeassistant.components.history
                                    INFO:homeassistant.loader:Loaded recorder from homeassistant.components.recorder
                                    INFO:homeassistant.loader:Loaded http from homeassistant.components.http
                                    INFO:homeassistant.loader:Loaded notify from homeassistant.components.notify
                                    INFO:homeassistant.loader:Loaded logbook from homeassistant.components.logbook
                                    INFO:homeassistant.loader:Loaded sensor from homeassistant.components.sensor
                                    INFO:homeassistant.loader:Loaded mysensors from homeassistant.components.mysensors
                                    INFO:homeassistant.loader:Loaded switch from homeassistant.components.switch
                                    INFO:homeassistant.loader:Loaded frontend from homeassistant.components.frontend
                                    INFO:homeassistant.loader:Loaded api from homeassistant.components.api
                                    INFO:homeassistant.loader:Loaded logger from homeassistant.components.logger
                                    INFO:homeassistant.loader:Loaded conversation from homeassistant.components.conversation
                                    INFO:homeassistant.loader:Loaded automation from homeassistant.components.automation
                                    INFO:homeassistant.loader:Loaded group from homeassistant.components.group
                                    INFO:homeassistant.components.introduction:
                                    
                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                    
                                            Hello, and welcome to Home Assistant!
                                    
                                            We'll hope that we can make all your dreams come true.
                                    
                                            Here are some resources to get started:
                                    
                                             - Configuring Home Assistant:
                                               https://home-assistant.io/getting-started/configuration/
                                    
                                             - Available components:
                                               https://home-assistant.io/components/
                                    
                                             - Troubleshooting your configuration:
                                               https://home-assistant.io/getting-started/troubleshooting-configuration/
                                    
                                             - Getting help:
                                               https://home-assistant.io/help/
                                    
                                            This message is generated by the introduction component. You can
                                            disable it in configuration.yaml.
                                    
                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                        
                                    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=introduction>
                                    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=recorder>
                                    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=logger>
                                    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=http>
                                    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=history>
                                    INFO:homeassistant.loader:Loaded notify.telegram from homeassistant.components.notify.telegram
                                    INFO:homeassistant.util.package:Attempting install of python-telegram-bot==2.8.7
                                    INFO:homeassistant.components.notify.telegram:Telegram bot is '***censored***'.
                                    INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: service=telegram, domain=notify>
                                    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=notify>
                                    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=logbook>
                                    INFO:homeassistant.loader:Loaded sensor.mysensors from homeassistant.components.sensor.mysensors
                                    INFO:homeassistant.util.package:Attempting install of https://github.com/MartinHjelmare/pymysensors/archive/fifo_queue.zip#pymysensors==0.3
                                    INFO:mysensors.mysensors:Trying to connect to /dev/ttyUSB0
                                    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=mysensors>
                                    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=sensor>
                                    INFO:homeassistant.loader:Loaded switch.mysensors from homeassistant.components.switch.mysensors
                                    INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: service=turn_off, domain=switch>
                                    INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: service=turn_on, domain=switch>
                                    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=switch>
                                    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=api>
                                    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=frontend>
                                    INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: service=process, domain=conversation>
                                    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=conversation>
                                    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=group>
                                    INFO:homeassistant.loader:Loaded automation.state from homeassistant.components.automation.state
                                    INFO:homeassistant.components.automation:Initialized rule Rule 1 - Door bell pressed
                                    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=automation>
                                    INFO:homeassistant.core:Starting Home Assistant (16 threads)
                                    INFO:homeassistant.core:Bus:Handling <Event homeassistant_start[L]>
                                    INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: service=stop, domain=homeassistant>
                                    INFO:homeassistant.components.mysensors:update persistence: node 1
                                    INFO:homeassistant.core:Bus:Handling <Event MYSENSORS_NODE_UPDATE[L]: port=/dev/ttyUSB0, devices=, update_type=persistence, node_id=1>
                                    INFO:homeassistant.components.mysensors:update persistence: node 1
                                    INFO:homeassistant.components.mysensors:update persistence: node 1
                                    INFO:homeassistant.components.mysensors:adding new devices: [<Entity Sensebender Micro Bell 1.1: >, <Entity Sensebender Micro Bell 1.2: >, <Entity Sensebender Micro Bell 1.199: >]
                                    INFO:homeassistant.components.http:Starting web interface at http://0.0.0.0:8123
                                    INFO:homeassistant.core:Timer:starting
                                    INFO:homeassistant.core:Bus:Handling <Event MYSENSORS_NODE_UPDATE[L]: port=/dev/ttyUSB0, devices=1=1=0=<Entity Sensebender Micro Bell 1.1: >, 2=1=<Entity Sensebender Micro Bell 1.2: >, 3=, 199=38=<Entity Sensebender Micro Bell 1.199: >, update_type=persistence, node_id=1>
                                    INFO:homeassistant.components.mysensors:update persistence: node 1
                                    INFO:homeassistant.components.mysensors:update persistence: node 1
                                    INFO:homeassistant.components.mysensors:update persistence: node 1
                                    INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: entity_id=sensor.sensebender_micro_bell_11, new_state=<state sensor.sensebender_micro_bell_11=; battery_level=0, unit_of_measurement=°C, child_id=1, node_id=1, friendly_name=Sensebender Micro Bell 1.1 @ 01:26:30 13-12-2015>>
                                    INFO:homeassistant.components.sensor.mysensors:Sensebender Micro Bell 1.1: value_type 0, value = 21.0
                                    INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: entity_id=sensor.sensebender_micro_bell_12, new_state=<state sensor.sensebender_micro_bell_12=; battery_level=0, unit_of_measurement=%, child_id=2, node_id=1, friendly_name=Sensebender Micro Bell 1.2 @ 01:26:30 13-12-2015>>
                                    INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: entity_id=sensor.sensebender_micro_bell_11, old_state=<state sensor.sensebender_micro_bell_11=; battery_level=0, unit_of_measurement=°C, child_id=1, node_id=1, friendly_name=Sensebender Micro Bell 1.1 @ 01:26:30 13-12-2015>, new_state=<state sensor.sensebender_micro_bell_11=21.0; battery_level=100, unit_of_measurement=°C, child_id=1, node_id=1, friendly_name=Sensebender Micro Bell 1.1 @ 01:26:30 13-12-2015>>
                                    INFO:homeassistant.components.sensor.mysensors:Sensebender Micro Bell 1.2: value_type 1, value = 34
                                    INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: entity_id=sensor.sensebender_micro_bell_12, old_state=<state sensor.sensebender_micro_bell_12=; battery_level=0, unit_of_measurement=%, child_id=2, node_id=1, friendly_name=Sensebender Micro Bell 1.2 @ 01:26:30 13-12-2015>, new_state=<state sensor.sensebender_micro_bell_12=34; battery_level=100, unit_of_measurement=%, child_id=2, node_id=1, friendly_name=Sensebender Micro Bell 1.2 @ 01:26:30 13-12-2015>>
                                    INFO:homeassistant.components.sensor.mysensors:Sensebender Micro Bell 1.199: value_type 38, value = 3160
                                    INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: entity_id=sensor.sensebender_micro_bell_1199, new_state=<state sensor.sensebender_micro_bell_1199=; battery_level=0, unit_of_measurement=V, child_id=199, node_id=1, friendly_name=Sensebender Micro Bell 1.199 @ 01:26:30 13-12-2015>>
                                    INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: entity_id=sensor.sensebender_micro_bell_1199, old_state=<state sensor.sensebender_micro_bell_1199=; battery_level=0, unit_of_measurement=V, child_id=199, node_id=1, friendly_name=Sensebender Micro Bell 1.199 @ 01:26:30 13-12-2015>, new_state=<state sensor.sensebender_micro_bell_1199=3160; battery_level=100, unit_of_measurement=V, child_id=199, node_id=1, friendly_name=Sensebender Micro Bell 1.199 @ 01:26:30 13-12-2015>>
                                    INFO:mysensors.mysensors:/dev/ttyUSB0 is open...
                                    INFO:mysensors.mysensors:Connected to /dev/ttyUSB0
                                    WARNING:mysensors.mysensors:Error decoding message from gateway, probably received bad byte.
                                    ^CINFO:homeassistant.core:Stopping
                                    INFO:homeassistant.core:Bus:Handling <Event homeassistant_stop[L]>
                                    INFO:mysensors.mysensors:Disconnecting from /dev/ttyUSB0
                                    INFO:mysensors.mysensors:Stopping thread
                                    INFO:homeassistant.components.recorder:Closing database
                                    (testhomeass)martin@martin-htpc:~/Dev/testhomeass/home-assistant$ hass
                                    Config directory: /home/martin/.homeassistant
                                    WARNING:homeassistant.bootstrap:Colorlog package not found, console coloring disabled
                                    INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: domain=homeassistant, service=turn_off>
                                    INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: domain=homeassistant, service=turn_on>
                                    INFO:homeassistant.bootstrap:Home Assistant core initialized
                                    INFO:homeassistant.loader:Loaded history from homeassistant.components.history
                                    INFO:homeassistant.loader:Loaded recorder from homeassistant.components.recorder
                                    INFO:homeassistant.loader:Loaded http from homeassistant.components.http
                                    INFO:homeassistant.loader:Loaded mysensors from homeassistant.components.mysensors
                                    INFO:homeassistant.loader:Loaded conversation from homeassistant.components.conversation
                                    INFO:homeassistant.loader:Loaded frontend from homeassistant.components.frontend
                                    INFO:homeassistant.loader:Loaded api from homeassistant.components.api
                                    INFO:homeassistant.loader:Loaded notify from homeassistant.components.notify
                                    INFO:homeassistant.loader:Loaded introduction from homeassistant.components.introduction
                                    INFO:homeassistant.loader:Loaded logbook from homeassistant.components.logbook
                                    INFO:homeassistant.loader:Loaded switch from homeassistant.components.switch
                                    INFO:homeassistant.loader:Loaded sensor from homeassistant.components.sensor
                                    INFO:homeassistant.loader:Loaded logger from homeassistant.components.logger
                                    INFO:homeassistant.loader:Loaded automation from homeassistant.components.automation
                                    INFO:homeassistant.loader:Loaded group from homeassistant.components.group
                                    INFO:homeassistant.components.introduction:
                                    
                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                    
                                            Hello, and welcome to Home Assistant!
                                    
                                            We'll hope that we can make all your dreams come true.
                                    
                                            Here are some resources to get started:
                                    
                                             - Configuring Home Assistant:
                                               https://home-assistant.io/getting-started/configuration/
                                    
                                             - Available components:
                                               https://home-assistant.io/components/
                                    
                                             - Troubleshooting your configuration:
                                               https://home-assistant.io/getting-started/troubleshooting-configuration/
                                    
                                             - Getting help:
                                               https://home-assistant.io/help/
                                    
                                            This message is generated by the introduction component. You can
                                            disable it in configuration.yaml.
                                    
                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                        
                                    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=introduction>
                                    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=recorder>
                                    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=logger>
                                    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=http>
                                    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=history>
                                    INFO:mysensors.mysensors:Trying to connect to /dev/ttyUSB0
                                    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=mysensors>
                                    INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: domain=conversation, service=process>
                                    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=conversation>
                                    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=api>
                                    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=frontend>
                                    INFO:homeassistant.loader:Loaded notify.telegram from homeassistant.components.notify.telegram
                                    INFO:homeassistant.components.notify.telegram:Telegram bot is '***censored***'.
                                    INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: domain=notify, service=telegram>
                                    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=notify>
                                    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=logbook>
                                    INFO:homeassistant.loader:Loaded switch.mysensors from homeassistant.components.switch.mysensors
                                    INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: domain=switch, service=turn_off>
                                    INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: domain=switch, service=turn_on>
                                    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=switch>
                                    INFO:homeassistant.loader:Loaded sensor.mysensors from homeassistant.components.sensor.mysensors
                                    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=sensor>
                                    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=group>
                                    INFO:homeassistant.loader:Loaded automation.state from homeassistant.components.automation.state
                                    INFO:homeassistant.components.automation:Initialized rule Rule 1 - Door bell pressed
                                    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=automation>
                                    INFO:homeassistant.core:Starting Home Assistant (16 threads)
                                    INFO:homeassistant.core:Bus:Handling <Event homeassistant_start[L]>
                                    INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: domain=homeassistant, service=stop>
                                    INFO:homeassistant.components.mysensors:update persistence: node 1
                                    INFO:homeassistant.components.http:Starting web interface at http://0.0.0.0:8123
                                    INFO:homeassistant.core:Timer:starting
                                    INFO:homeassistant.core:Bus:Handling <Event MYSENSORS_NODE_UPDATE[L]: update_type=persistence, devices=, port=/dev/ttyUSB0, node_id=1>
                                    INFO:homeassistant.components.mysensors:update persistence: node 1
                                    INFO:homeassistant.components.mysensors:update persistence: node 1
                                    INFO:homeassistant.components.mysensors:update persistence: node 1
                                    INFO:homeassistant.components.mysensors:adding new devices: [<Entity Sensebender Micro Bell 1.1: >, <Entity Sensebender Micro Bell 1.2: >, <Entity Sensebender Micro Bell 1.199: >]
                                    INFO:homeassistant.core:Bus:Handling <Event MYSENSORS_NODE_UPDATE[L]: update_type=persistence, devices=1=1=0=<Entity Sensebender Micro Bell 1.1: >, 2=1=<Entity Sensebender Micro Bell 1.2: >, 3=, 199=38=<Entity Sensebender Micro Bell 1.199: >, port=/dev/ttyUSB0, node_id=1>
                                    INFO:homeassistant.components.mysensors:update persistence: node 1
                                    INFO:homeassistant.components.mysensors:update persistence: node 1
                                    INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: new_state=<state sensor.sensebender_micro_bell_11=; child_id=1, unit_of_measurement=°C, battery_level=0, friendly_name=Sensebender Micro Bell 1.1, node_id=1 @ 01:26:49 13-12-2015>, entity_id=sensor.sensebender_micro_bell_11>
                                    INFO:homeassistant.components.sensor.mysensors:Sensebender Micro Bell 1.1: value_type 0, value = 21.0
                                    INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: new_state=<state sensor.sensebender_micro_bell_12=; child_id=2, unit_of_measurement=%, battery_level=0, friendly_name=Sensebender Micro Bell 1.2, node_id=1 @ 01:26:49 13-12-2015>, entity_id=sensor.sensebender_micro_bell_12>
                                    INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: old_state=<state sensor.sensebender_micro_bell_11=; child_id=1, unit_of_measurement=°C, battery_level=0, friendly_name=Sensebender Micro Bell 1.1, node_id=1 @ 01:26:49 13-12-2015>, new_state=<state sensor.sensebender_micro_bell_11=21.0; child_id=1, unit_of_measurement=°C, battery_level=100, friendly_name=Sensebender Micro Bell 1.1, node_id=1 @ 01:26:49 13-12-2015>, entity_id=sensor.sensebender_micro_bell_11>
                                    INFO:homeassistant.components.sensor.mysensors:Sensebender Micro Bell 1.2: value_type 1, value = 34
                                    INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: old_state=<state sensor.sensebender_micro_bell_12=; child_id=2, unit_of_measurement=%, battery_level=0, friendly_name=Sensebender Micro Bell 1.2, node_id=1 @ 01:26:49 13-12-2015>, new_state=<state sensor.sensebender_micro_bell_12=34; child_id=2, unit_of_measurement=%, battery_level=100, friendly_name=Sensebender Micro Bell 1.2, node_id=1 @ 01:26:49 13-12-2015>, entity_id=sensor.sensebender_micro_bell_12>
                                    INFO:homeassistant.components.sensor.mysensors:Sensebender Micro Bell 1.199: value_type 38, value = 3160
                                    INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: new_state=<state sensor.sensebender_micro_bell_1199=3160; child_id=199, unit_of_measurement=V, battery_level=100, friendly_name=Sensebender Micro Bell 1.199, node_id=1 @ 01:26:49 13-12-2015>, entity_id=sensor.sensebender_micro_bell_1199>
                                    INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: old_state=<state sensor.sensebender_micro_bell_1199=3160; child_id=199, unit_of_measurement=V, battery_level=100, friendly_name=Sensebender Micro Bell 1.199, node_id=1 @ 01:26:49 13-12-2015>, new_state=<state sensor.sensebender_micro_bell_1199=; child_id=199, unit_of_measurement=V, battery_level=0, friendly_name=Sensebender Micro Bell 1.199, node_id=1 @ 01:26:49 13-12-2015>, entity_id=sensor.sensebender_micro_bell_1199>
                                    INFO:mysensors.mysensors:/dev/ttyUSB0 is open...
                                    INFO:mysensors.mysensors:Connected to /dev/ttyUSB0
                                    INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:gateway started, id=0, parent=0, distance=0
                                    

                                    You can see that I get a warning about bad byte, after first start. I solve this by restarting hass.

                                    Your home assistant config for mysensors should now be structured like this:

                                    mysensors:
                                      port:
                                        - '/dev/ttyUSB0'
                                      #  - '/dev/ttyACM0'
                                      debug: true
                                      persistence: true
                                      persistence_file:
                                        - '/home/martin/.homeassistant/mysensors.json'
                                      #  - '/home/martin/.homeassistant/mysensors2.json'
                                      version: '1.5'
                                    
                                    sensor:
                                      platform: mysensors
                                    
                                    switch:
                                      platform: mysensors
                                    
                                    1 Reply Last reply
                                    0
                                    • D drock1985

                                      Hi @martinhjelmare

                                      I decided to try this on a simplier sketch that I have, but still no luck. I added this line gw.send(lightMsgW.set("1")); to the end of void setup(). The sensor shows up at the top of the States screen in HA, but doesn't let me actually control it, and it doesn't show up in Switches or Lights.

                                      Here is the sketch that I am using.

                                      /**
                                       * The MySensors Arduino library handles the wireless radio link and protocol
                                       * between your home built sensors/actuators and HA controller of choice.
                                       * The sensors forms a self healing radio network with optional repeaters. Each
                                       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
                                       * network topology allowing messages to be routed to nodes.
                                       *
                                       * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
                                       * Copyright (C) 2013-2015 Sensnology AB
                                       * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
                                       *
                                       * Documentation: http://www.mysensors.org
                                       * Support Forum: http://forum.mysensors.org
                                       *
                                       * This program is free software; you can redistribute it and/or
                                       * modify it under the terms of the GNU General Public License
                                       * version 2 as published by the Free Software Foundation.
                                       *
                                       *******************************
                                       *
                                       * REVISION HISTORY
                                       * Version 1.0 - 6-December-2015, Derrick Rockwell
                                       *
                                       * DESCRIPTION
                                       *This sketch uses two 30 bulb, 3mm LED holiday light strings. These
                                       *can usually be found in most dollar stores/hardware stores and are 
                                       *battery powered. This sketch uses digital pins 3 and 4 to power two 
                                       *a string of lights each. Ex, one can control white lights the other
                                       *could control multi-colour lights. 
                                       */
                                      
                                      #define SN "HolidayLEDDeskLights"
                                      #define SV "1.0"
                                      
                                      #include <MySensor.h> 
                                      #include <SPI.h>
                                      
                                      #define MLED_PIN 3      // Pin Multi-Coloured LED's will attached to
                                      #define WLED_PIN 5      // Pin White-Coloured LED's will attached to
                                      #define FADE_DELAY 10  // Delay in ms for each percentage fade up/down (10ms = 1s full-range dim)
                                      #define CHILD_ID0 3
                                      #define CHILD_ID1 5
                                      
                                      MySensor gw;
                                      
                                      static int currentLevelM = 0;  // Current dim level...
                                      static int currentLevelW = 0;  // Current dim level...
                                      
                                      MyMessage dimmerMsgM(MLED_PIN, V_DIMMER);
                                      MyMessage lightMsgM(MLED_PIN, V_LIGHT);
                                      MyMessage dimmerMsgW(WLED_PIN, V_DIMMER);
                                      MyMessage lightMsgW(WLED_PIN, V_LIGHT);
                                      
                                      /***
                                       * Dimmable LED initialization method
                                       */
                                      void setup()  
                                      { 
                                        Serial.println( SN ); 
                                        Serial.println( SV );
                                        gw.begin( incomingMessage );
                                        
                                        // Register the LED Dimmable Light with the gateway
                                        gw.present( MLED_PIN, S_DIMMER );
                                        gw.present( WLED_PIN, S_DIMMER );
                                        
                                        gw.sendSketchInfo(SN, SV);
                                        // Pull the gateway's current dim level - restore light level upon sendor node power-up
                                        gw.request( MLED_PIN, V_DIMMER );
                                        gw.request( WLED_PIN, V_DIMMER );
                                        gw.send(lightMsgW.set("1"));
                                      }
                                      
                                      /***
                                       *  Dimmable LED main processing loop 
                                       */
                                      void loop() 
                                      {
                                        gw.process();
                                      }
                                      
                                      //For Multi Coloured Lights
                                      void incomingMessage(const MyMessage &message) {
                                      if (message.type == V_LIGHT || message.type == V_DIMMER) {
                                            // if (message.sensor <= 2)
                                            {
                                                //0: All Dimmers
                                                //1: LED 1
                                                //2: LED 2
                                                //  Retrieve the power or dim level from the incoming request message
                                                int requestedLevel = atoi( message.data );
                                                
                                                // Adjust incoming level if this is a V_LIGHT variable update [0 == off, 1 == on]
                                                requestedLevel *= ( message.type == V_LIGHT ? 100 : 1 );
                                                
                                                if ((message.sensor == CHILD_ID0) || (message.sensor == 0)){
                                                  fadeToLevel ( requestedLevel, MLED_PIN, &currentLevelM );
                                                  // Inform the gateway of the current DimmableLED's SwitchPower1 and LoadLevelStatus value...
                                                  gw.send(lightMsgM.set(requestedLevel > 0 ? 1 : 0));
                                                  gw.send(dimmerMsgM.set(requestedLevel) );
                                                }
                                                if ((message.sensor == CHILD_ID1) || (message.sensor == 0)){
                                                  fadeToLevel( requestedLevel, WLED_PIN, &currentLevelW );
                                                  // Inform the gateway of the current DimmableLED's SwitchPower1 and LoadLevelStatus value...
                                                  gw.send(lightMsgW.set(requestedLevel > 0 ? 1 : 0));
                                                  gw.send(dimmerMsgW.set(requestedLevel) );
                                                }
                                              }
                                      }
                                      }
                                      
                                      /***
                                       *  This method provides a graceful fade up/down effect
                                       */
                                       // For Multi Coloured Lights
                                      void fadeToLevel( int toLevel, int pin, int *currentLevel ) {
                                        int delta = ( toLevel - (*currentLevel) ) < 0 ? -1 : 1;
                                        while ( (*currentLevel) != toLevel ) {
                                          (*currentLevel) += delta;
                                          analogWrite( pin, (int)((*currentLevel) / 100. * 255) );
                                          delay( FADE_DELAY );
                                        }
                                      }
                                      
                                      H Offline
                                      H Offline
                                      humblehacker
                                      wrote on last edited by
                                      #34

                                      @drock1985
                                      It looks like we're trying to do similar things with HA and MYS... I've been working on a rotary encoder switch for colored lights (eg Limitlessled/HUE etc...) and had been trying to program it through MQTT. However, I just now noticed the LEDDIMMERwithROTARYENCODER sketch in the MySensors examples so I thought I might try using MYS instead of MQTT. Of course that leads right back to the lack of support for MYS Switches in HASS... Perhaps there's a solution for both of our problems if we use an MQTT Gateway instead? I've worked with MQTT and NodeRED before and it was pretty straight forward, but then again I've been having a much harder time understanding the way its implemented in HASS... So I might need to work with it some more before I can be of any help testing the MQTT MYS Gateway with HA...

                                      martinhjelmareM 1 Reply Last reply
                                      0
                                      • H humblehacker

                                        @drock1985
                                        It looks like we're trying to do similar things with HA and MYS... I've been working on a rotary encoder switch for colored lights (eg Limitlessled/HUE etc...) and had been trying to program it through MQTT. However, I just now noticed the LEDDIMMERwithROTARYENCODER sketch in the MySensors examples so I thought I might try using MYS instead of MQTT. Of course that leads right back to the lack of support for MYS Switches in HASS... Perhaps there's a solution for both of our problems if we use an MQTT Gateway instead? I've worked with MQTT and NodeRED before and it was pretty straight forward, but then again I've been having a much harder time understanding the way its implemented in HASS... So I might need to work with it some more before I can be of any help testing the MQTT MYS Gateway with HA...

                                        martinhjelmareM Offline
                                        martinhjelmareM Offline
                                        martinhjelmare
                                        Plugin Developer
                                        wrote on last edited by
                                        #35

                                        @humblehacker

                                        Hi!

                                        I also want to try the MQTT gateway together with HA. MQTT support is well supported in HA, and looking at the MQTT protocol in mysensors dev branch it looks promising. I have just got some ethernet modules and more nanos, so as soon as I find some time, I'll get started. We can post our progress somewhere here whoever gets it going first.

                                        1 Reply Last reply
                                        0
                                        • D Offline
                                          D Offline
                                          drock1985
                                          wrote on last edited by drock1985
                                          #36

                                          @humblehacker @martinhjelmare

                                          Sounds like an interesting idea to me. I have never used a MQTT gateway before, so i'm going in a little blind. I think I have the server so far (mosquitto) running on the same RPI as my HA install; so now looking into the next step.

                                          One thing though, would this replace my current serial gateway, or be an addition to it?

                                          My Projects
                                          2 Door Chime Sensor
                                          Washing Machine Monitor

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


                                          24

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.1k

                                          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