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.
  • 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
        • D Offline
          D Offline
          drock1985
          wrote on last edited by
          #37

          I've been trying to get MQTT working using the Dev branch here (http://forum.mysensors.org/topic/2352/guide-setting-up-and-testing-mqtt-client-gateway/) and have my configuration.yaml file looking like this for my W5100MQTT broker:

          #MySensors MQTT Test
          mqtt 1:
            broker: 192.168.86.198
            port: 1883
          #  client_id: home-assistant-1
            keepalive: 60
          #  username: USERNAME
          #  password: PASSWORD
          
          

          The Serial output from Arduino shows that I connected successfully

          0;0;3;0;9;Starting gateway (RNNGA-, 1.6.0-beta)
          0;0;3;0;9;Radio init successful.
          IP: 192.168.86.112
          0;0;3;0;9;Attempting MQTT connection...
          0;0;3;0;9;MQTT connected
          0;0;3;0;9;Init complete, id=0, parent=0, distance=0
          

          But, Home-Assistant isn't registering the broker, and I have this error in the Dev section:

          15-12-15 15:32:17 homeassistant.components.mqtt: Missing required configuration items in mqtt: broker
          15-12-15 15:32:17 homeassistant.bootstrap: component mqtt failed to initialize
          

          Does anyone have any ideas? @humblehacker @martinhjelmare @hek ?

          My Projects
          2 Door Chime Sensor
          Washing Machine Monitor

          martinhjelmareM H 2 Replies Last reply
          0
          • hekH Offline
            hekH Offline
            hek
            Admin
            wrote on last edited by
            #38

            Sorry, havent tried HomeAssistant myself.

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

              Thanks @hek , had to ask :)

              Would it be possible to get a Home-Assistant dedicated sub-forum please?

              My Projects
              2 Door Chime Sensor
              Washing Machine Monitor

              1 Reply Last reply
              0
              • D drock1985

                I've been trying to get MQTT working using the Dev branch here (http://forum.mysensors.org/topic/2352/guide-setting-up-and-testing-mqtt-client-gateway/) and have my configuration.yaml file looking like this for my W5100MQTT broker:

                #MySensors MQTT Test
                mqtt 1:
                  broker: 192.168.86.198
                  port: 1883
                #  client_id: home-assistant-1
                  keepalive: 60
                #  username: USERNAME
                #  password: PASSWORD
                
                

                The Serial output from Arduino shows that I connected successfully

                0;0;3;0;9;Starting gateway (RNNGA-, 1.6.0-beta)
                0;0;3;0;9;Radio init successful.
                IP: 192.168.86.112
                0;0;3;0;9;Attempting MQTT connection...
                0;0;3;0;9;MQTT connected
                0;0;3;0;9;Init complete, id=0, parent=0, distance=0
                

                But, Home-Assistant isn't registering the broker, and I have this error in the Dev section:

                15-12-15 15:32:17 homeassistant.components.mqtt: Missing required configuration items in mqtt: broker
                15-12-15 15:32:17 homeassistant.bootstrap: component mqtt failed to initialize
                

                Does anyone have any ideas? @humblehacker @martinhjelmare @hek ?

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

                @drock1985

                What do you set MY_IP_GATEWAY_ADDRESS to on the arduino side?

                1 Reply Last reply
                0
                • hekH Offline
                  hekH Offline
                  hek
                  Admin
                  wrote on last edited by
                  #41

                  @drock1985 said:

                  Would it be possible to get a Home-Assistant dedicated sub-forum please?

                  You got it.
                  http://forum.mysensors.org/category/28/home-assistant

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

                    Thanks @hek very appreciated.

                    EDIT: Sort of ran into an issue with the Dev MQTTW5100Gateway sketch.... Thought the output I was getting above was good, but in reality the Arduino IDE wasn't giving an error. I decided to run the gateway in my RPI and view the data through SSH via screen. It initializes and shows the same data as the Arduino IDE, but then seconds later it dies and gives an error about screen terminating. Happens every time.

                    Going to try the ESP8266MQTTGateway: I'm got a hunch.

                    My Projects
                    2 Door Chime Sensor
                    Washing Machine Monitor

                    1 Reply Last reply
                    0
                    • D drock1985

                      I've been trying to get MQTT working using the Dev branch here (http://forum.mysensors.org/topic/2352/guide-setting-up-and-testing-mqtt-client-gateway/) and have my configuration.yaml file looking like this for my W5100MQTT broker:

                      #MySensors MQTT Test
                      mqtt 1:
                        broker: 192.168.86.198
                        port: 1883
                      #  client_id: home-assistant-1
                        keepalive: 60
                      #  username: USERNAME
                      #  password: PASSWORD
                      
                      

                      The Serial output from Arduino shows that I connected successfully

                      0;0;3;0;9;Starting gateway (RNNGA-, 1.6.0-beta)
                      0;0;3;0;9;Radio init successful.
                      IP: 192.168.86.112
                      0;0;3;0;9;Attempting MQTT connection...
                      0;0;3;0;9;MQTT connected
                      0;0;3;0;9;Init complete, id=0, parent=0, distance=0
                      

                      But, Home-Assistant isn't registering the broker, and I have this error in the Dev section:

                      15-12-15 15:32:17 homeassistant.components.mqtt: Missing required configuration items in mqtt: broker
                      15-12-15 15:32:17 homeassistant.bootstrap: component mqtt failed to initialize
                      

                      Does anyone have any ideas? @humblehacker @martinhjelmare @hek ?

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

                      @drock1985 said:

                      I've been trying to get MQTT working using the Dev branch here (http://forum.mysensors.org/topic/2352/guide-setting-up-and-testing-mqtt-client-gateway/) and have my configuration.yaml file looking like this for my W5100MQTT broker:

                      #MySensors MQTT Test
                      mqtt 1:
                        broker: 192.168.86.198
                        port: 1883
                      #  client_id: home-assistant-1
                        keepalive: 60
                      #  username: USERNAME
                      #  password: PASSWORD
                      
                      

                      Does anyone have any ideas? @humblehacker @martinhjelmare @hek ?

                      Does the IP address you defined in the config.yaml point to your Mosquitto Broker or the Arduino-Ethernet Shield? If it points to the Arduino afaik the point of the MQTTCLIENT Gateway is that it can be run as a client if you've already got a Mosquitto broker. Otherwise you would either need to remove mosquitto or forward it to a different port than the default 1883. If this was the case then HASS would be looking for a broker where none exists which is why it is missing configuration items...

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

                        For the time being, I'm thinking of taking a different approach with my toggle switch... I'm thinking of simply defining the button output as a binary sensor which can then toggle between two predefined scenes. At least in my case, input only needs to go in one direction so there's no need to receive any data from the controller....

                        martinhjelmareM 1 Reply Last reply
                        0
                        • H humblehacker

                          For the time being, I'm thinking of taking a different approach with my toggle switch... I'm thinking of simply defining the button output as a binary sensor which can then toggle between two predefined scenes. At least in my case, input only needs to go in one direction so there's no need to receive any data from the controller....

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

                          @humblehacker

                          FYI, my fifo_queue pull request has been merged with dev branch at pymysensors, so I'm hoping to be able to implement switch support for the mysensors component in homeassistant very soon.

                          H 1 Reply Last reply
                          0
                          • martinhjelmareM martinhjelmare

                            @humblehacker

                            FYI, my fifo_queue pull request has been merged with dev branch at pymysensors, so I'm hoping to be able to implement switch support for the mysensors component in homeassistant very soon.

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

                            @martinhjelmare said:

                            @humblehacker

                            FYI, my fifo_queue pull request has been merged with dev branch at pymysensors, so I'm hoping to be able to implement switch support for the mysensors component in homeassistant very soon.

                            Thats great news! That should be a huge help with my plans for building an RGB Lighting controller based on the rotary_led_dimmer sketch! If I can ever figure out how to implement a simple toggle switch first...

                            1 Reply Last reply
                            0
                            • H humblehacker

                              @drock1985 said:

                              I've been trying to get MQTT working using the Dev branch here (http://forum.mysensors.org/topic/2352/guide-setting-up-and-testing-mqtt-client-gateway/) and have my configuration.yaml file looking like this for my W5100MQTT broker:

                              #MySensors MQTT Test
                              mqtt 1:
                                broker: 192.168.86.198
                                port: 1883
                              #  client_id: home-assistant-1
                                keepalive: 60
                              #  username: USERNAME
                              #  password: PASSWORD
                              
                              

                              Does anyone have any ideas? @humblehacker @martinhjelmare @hek ?

                              Does the IP address you defined in the config.yaml point to your Mosquitto Broker or the Arduino-Ethernet Shield? If it points to the Arduino afaik the point of the MQTTCLIENT Gateway is that it can be run as a client if you've already got a Mosquitto broker. Otherwise you would either need to remove mosquitto or forward it to a different port than the default 1883. If this was the case then HASS would be looking for a broker where none exists which is why it is missing configuration items...

                              D Offline
                              D Offline
                              drock1985
                              wrote on last edited by
                              #47

                              @humblehacker said:

                              k

                              @humblehacker said:

                              @drock1985 said:

                              I've been trying to get MQTT working using the Dev branch here (http://forum.mysensors.org/topic/2352/guide-setting-up-and-testing-mqtt-client-gateway/) and have my configuration.yaml file looking like this for my W5100MQTT broker:

                              #MySensors MQTT Test
                              mqtt 1:
                                broker: 192.168.86.198
                                port: 1883
                              #  client_id: home-assistant-1
                                keepalive: 60
                              #  username: USERNAME
                              #  password: PASSWORD
                              
                              

                              Does anyone have any ideas? @humblehacker @martinhjelmare @hek ?

                              Does the IP address you defined in the config.yaml point to your Mosquitto Broker or the Arduino-Ethernet Shield? If it points to the Arduino afaik the point of the MQTTCLIENT Gateway is that it can be run as a client if you've already got a Mosquitto broker. Otherwise you would either need to remove mosquitto or forward it to a different port than the default 1883. If this was the case then HASS would be looking for a broker where none exists which is why it is missing configuration items...

                              @humblehacker

                              The configuration.yaml file I have pointed back to the local IP address, since Mosquitto and Home-Assistant are running on the same Pi.

                              So, you are saying that it should really be pointed back to the MQTT Gateway then? Still confusing to me.

                              My Projects
                              2 Door Chime Sensor
                              Washing Machine Monitor

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

                                Never mind then... As long as your using Mosquitto as your broker and the MQTT CLIENT Gateway (from the development branch) rather than the default MQTT Gateway sketch from- http://www.mysensors.org/build/mqtt_gateway then none of my earlier comments should apply... Basically I was saying that the default MYSensors MQTT Gateway is set up to function as a broker and would therefore conflict with any Mosquitto server running on the same port. The MQTT CLIENT Gateway (emphasis on CLIENT) from the development branch isnt set up as a broker so it shouldnt conflict with a Mosquitto installation.

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

                                  It's still important to be wary about which ip address you assign where, so I think it was a good point.

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

                                    Well, I have Mosquitto and the Dev ClientMQTTESP gateway working, and is communicating fine. Now just trying to figure out the proper entry to add an item as.

                                    My Projects
                                    2 Door Chime Sensor
                                    Washing Machine Monitor

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

                                      Ok, just got it all setup and working great now. Time to see how relays will work......

                                      My Projects
                                      2 Door Chime Sensor
                                      Washing Machine Monitor

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

                                        Hey @martinhjelmare , I see HA was updated today; did your commits get added?

                                        My Projects
                                        2 Door Chime Sensor
                                        Washing Machine Monitor

                                        martinhjelmareM 1 Reply Last reply
                                        0
                                        • D drock1985

                                          Hey @martinhjelmare , I see HA was updated today; did your commits get added?

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

                                          @drock1985

                                          Hi!

                                          No, I've submitted a pull request, but I need to fix some things, and maybe change some of it. But hopefully it wont take too long.

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


                                          22

                                          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