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.
  • 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
                                        • MufasaM Offline
                                          MufasaM Offline
                                          Mufasa
                                          wrote on last edited by
                                          #54

                                          I have been trying to set up a switch in home assistant but I have had no luck in getting it to show up in the dashboard. I am using @martinhjelmare mysensors-component-switch branch of home assistant and the following sketch. Does anyone have any idea why this is happening? ```

                                          /**
                                           * 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 - Henrik Ekblad
                                           * 
                                           * DESCRIPTION
                                           * Example sketch showing how to control physical relays. 
                                           * This example will remember relay state after power failure.
                                           * http://www.mysensors.org/build/relay
                                           */ 
                                          
                                          #include <MySigningNone.h>
                                          #include <MyTransportNRF24.h>
                                          #include <MyTransportRFM69.h>
                                          #include <MyHwATMega328.h>
                                          #include <MySensor.h>
                                          #include <SPI.h>
                                          
                                          #define RELAY_1  3  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
                                          #define NUMBER_OF_RELAYS 1 // Total number of attached relays
                                          #define RELAY_ON 1  // GPIO value to write to turn on attached relay
                                          #define RELAY_OFF 0 // GPIO value to write to turn off attached relay
                                          
                                          // NRFRF24L01 radio driver (set low transmit power by default) 
                                          MyTransportNRF24 radio(RF24_CE_PIN, RF24_CS_PIN, RF24_PA_LEVEL_GW);  
                                          //MyTransportRFM69 radio;
                                          // Message signing driver (none default)
                                          //MySigningNone signer;
                                          // Select AtMega328 hardware profile
                                          MyHwATMega328 hw;
                                          // Construct MySensors library
                                          MySensor gw(radio, hw);
                                          MyMessage lightMsg(RELAY_1, S_LIGHT);
                                          
                                          void setup()  
                                          {   
                                            // Initialize library and add callback for incoming messages
                                            gw.begin(incomingMessage, AUTO, true);
                                            // Send the sketch version information to the gateway and Controller
                                            gw.sendSketchInfo("Relay", "1.0");
                                          
                                            // Fetch relay status
                                            for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
                                              // Register all sensors to gw (they will be created as child devices)
                                              gw.present(sensor, S_LIGHT);
                                              // Then set relay pins in output mode
                                              pinMode(pin, OUTPUT);   
                                              // Set relay to last known state (using eeprom storage) 
                                              digitalWrite(pin, gw.loadState(sensor)?RELAY_ON:RELAY_OFF);
                                            }
                                            gw.send(lightMsg.set("0"));
                                          }
                                          
                                          
                                          void loop() 
                                          {
                                            // Alway process incoming messages whenever possible
                                            gw.process();
                                          }
                                          
                                          void incomingMessage(const MyMessage &message) {
                                            // We only expect one type of message from controller. But we better check anyway.
                                            if (message.type==V_LIGHT) {
                                               // Change relay state
                                               digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
                                               // Store state in eeprom
                                               gw.saveState(message.sensor, message.getBool());
                                               // Write some debug info
                                               Serial.print("Incoming change for sensor:");
                                               Serial.print(message.sensor);
                                               Serial.print(", New status: ");
                                               Serial.println(message.getBool());
                                             } 
                                          }
                                          martinhjelmareM 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          21

                                          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