Home Assistant - How to recognize MySensors nodes


  • Plugin Developer

    @humblehacker

    Hi!

    There is general MQTT support in home-assistant, not specific to mysensors, but I have too little experience using the MQTT features in mysensors, to say if it will work or not. I guess it depends on how the mysensors protocol is translated by the MQTT gateway and posted to the broker. If you want to try it, I suggest using the dev branch of mysensors and following this guide:

    http://forum.mysensors.org/topic/2352/guide-setting-up-and-testing-mqtt-client-gateway

    Here is the home-assistant docs:
    https://home-assistant.io/components/mqtt/

    Looking at the topic structure and looking at the docs at home-assistant, I'm optimistic. Maybe I'll even try it myself.

    Here are some advice if you want to continue trying the serial gateway approach:
    Are you using the latest release of home-assistant (0.8)? That release supports debug level logging as default, which should make the debug mode of the mysensors component work. That was not the case before.

    First, make sure your gateway and test node is talking without the controller. Hook up serial monitors and check the output on both sides. I'd be happy to look at that if you want to post it here.

    Then, hook up your serial gateway to the home-assistant computer. Start home-assistant from the command line: (hass). Check the log output. Post it here if you want.

    Then, powercycle your node. Make sure you have the serial monitor up on the node, or just reconnect it, and the node should reset. Look at the serial output on the node side, and check the log from hass, if there is anything. Post it here if you want. You can't have the serial monitor on the gateway active when starting hass, as the serial connection is exclusive.

    Edit:
    Also post your home-assistant config if you want, which is a crucial piece of evidence.



  • Are you using the latest release of home-assistant (0.8)? That release supports debug level logging as default, which should make the debug mode of the mysensors component work. That was not the case before.

    Yes I can confirm I am running version 0.8 and having just reread your above post, I realized changing debug to info in mysensors.py only applies to >v0.8 so I had to change it back and reboot again. I"ve been using the terminal output from hass -ui as my main debugger and through this was able to confirm that the mysensors component is recognized. Also troubleshooting on the Home Assistant gitter page over the past few days and tried enabling and disabling persistence from the config.yaml.

    First, make sure your gateway and test node is talking without the controller. Hook up serial monitors and check the output on both sides. I'd be happy to look at that if you want to post it here.
    Then, hook up your serial gateway to the home-assistant computer. Start home-assistant from the command line: (hass). Check the log output. Post it here if you want.
    Then, powercycle your node. Make sure you have the serial monitor up on the node, or just reconnect it, and the node should reset. Look at the serial output on the node side, and check the log from hass, if there is anything. Post it here if you want. You can't have the serial monitor on the gateway active when starting hass, as the serial connection is exclusive.

    OK yes. This is the part I've really needed help with as I can't seem to find any documentation from the MySensors end about debugging via serial monitor. I tried opening a serial monitor as I normally would with the Arduino IDE and nothing happened but I dont know if the MySensors library uses a custom protocol or baud rate. Is there a tutorial or guide on the subject that you can point me to? I can connect an OLED and/or LCD screen directly too if that is possible.


  • Plugin Developer

    For debugging with serial monitor, just plug in both the gateway and the node to your computer, either through USB if your arduino supports that or through FTDI adapter. Then open two instances of the Arduino IDE and open one serial monitor per IDE. Make sure you set board and port correct first, in the two IDEs, one per arduino. Mysensors use baudrate 115200, so make sure that's selected in the serial monitors.

    For an explanation of the mysensors' serial api, see:
    http://www.mysensors.org/download/serial_api_15

    In the end of that page there are some examples of serial output.



  • Yes, it was just the baud rate that had me thrown off I guess, since the default is always 9600 on Arduino. Anyway, the serial gateway seems to be functioning as expected printing 0;0;3;0;9;gateway started, id=0, parent=0, distance=0 0;0;3;0;14;Gateway startup complete.

    However when I load up the motion sensor sketch and open the monitor, it still shows nothing. I then tried a couple different sensors incl. a PIR sensor with the distance example and another with the ds18b20 temp sensor with the same result. Finally I loaded up the MockMySensors sketch and again the serial monitor was blank.
    I then loaded up the default DigitalSerialRead sketch from the Arduino IDE and the serial output printed as expected. Then lastly, I even tested the PhysicalPixel sketch with the standard NRF24 library and it transmitted as expected! So the issue is definitely with the MySensors library. But then I still couldnt even get it to work using Codebender and that should be using a completely different library file. SO I'm all out of ideas... In any case, there still could be an issue on the Controller end, but I have no way of knowing until I can fix the sender function.


  • Plugin Developer

    Have you activated (uncommented) DEBUG in MyConfig.h?



  • As I keep my sketchbook synchronized through Github, I can confirm that debugging is enabled in my master here
    However, I will need to confirm that the local sketchbook on the laptop I was using yesterday is up to date with the remote master. I'm pretty sure I enabled debugging when I first installed it.

    EDIT- Isn't debugging enabled by default now?- https://github.com/mysensors/Arduino/blob/master/libraries/MySensors/MyConfig.h



  • Hi,

    I've been following this thread for a few days, as I am in the same situation and kielnino - I can see the MySensors component get loaded and then....silence....I know the MySensors GW and nodes are working from testing with serial monitors and another controller app (MySController).

    Will probably be spending some time tracing through the pymysensors code tonight to see what gives. I do have debug enabled on homeassistant, but still no joy.

    One thought - shouldn't MySensors on homeassistant be implemented as a platform (and not a sensor) much like MQTT.

    I have got readings to work through MQTT (in my case, patched a node-red flow together to read the serial line and publish to a local mosquitto), but this is like driving around the city to get to the store next door...

    Any further thoughts/hints as to where to start looking?

    Thanks!


  • Plugin Developer

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


  • Plugin Developer

    @acmbc68

    Hi!

    Regarding the current mysensors implementation in home assistant, it's a sensor platform. But it's not a separate component.

    I have added a mysensors component together with a switch platform, in my github fork of home assistant. I haven't made a pull request yet, cause I'm waiting to have my other pull request to pymysensors approved, where I implement support for setting child values from the controller, cause it's a dependency.

    https://github.com/MartinHjelmare/home-assistant/tree/mysensors-component-switch

    https://github.com/MartinHjelmare/pymysensors/tree/fifo_queue

    I'm not completely finished with the home assistant switch branch. I want to add support for multiple gateways as well, and I haven't had time to test my solution properly yet.

    I've added more debug logging in my fifo_queue branch of pymysensors, and made the serial connection more robust, by closing it when the thread quits. I've also downgraded the required pyserial version to 2.5, due to a bug in pyserial 2.6 - 3. This has been fixed in the master branch of pyserial, but no new release exists, I think.

    If you know how to change installed components in home assistant, you can give my branches a try. They should be working in their current state on github, but more testing is always good.

    When I first started testing connecting my node with the gateway and home assistant, I had problems in the beginning, When I set the node id to 1 and made sure at least one value was sent from the node, I got it working. It might have been a coincidence, that it started working then, cause I'm not sure that home assistant needs sequential entity ids, but when you're debugging it's good to narrow down possible variables/problems. You also have to make sure that the gateway receives all the presentation data, including sketch name, from the node. Otherwise the sensor won't show up in the GUI. That's currently how it's written in the code.

    Edit:
    One more thing. Even though debug level logging should be enabled by default in home assistant 0.8, you still have to enable the logger component in your config.
    https://home-assistant.io/components/logger/



  • 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.



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


  • Plugin Developer

    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'
    


  • @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.



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



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


  • Plugin Developer

    @humblehacker

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



  • success!.png
    😃
    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...


  • Plugin Developer



  • 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.


  • Plugin Developer

    @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'
    


  • 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!


  • Plugin Developer

    @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"));
    


  • 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 );
      }
    }
    

  • Plugin Developer

    @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.



  • @martinhjelmare

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


  • Plugin Developer

    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
    


  • @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...


  • Plugin Developer

    @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.



  • @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?



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


  • Admin

    Sorry, havent tried HomeAssistant myself.



  • Thanks @hek , had to ask 🙂

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


  • Plugin Developer

    @drock1985

    What do you set MY_IP_GATEWAY_ADDRESS to on the arduino side?


  • Admin

    @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



  • 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.



  • @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...



  • 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....


  • Plugin Developer

    @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.



  • @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...



  • @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.



  • 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.


  • Plugin Developer

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



  • 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.



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



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


  • Plugin Developer

    @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.



  • 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());
       } 
    }

  • Plugin Developer

    @Mufasa

    Hi!

    First of all my branch is still under development, and right now I think there is a bug, which could make it unable to install. I'll have more time to fix things next week.

    How does your home assistant config for mysensors look like?

    Have you looked at the logs of home assistant after start?



  • @martinhjelmare

    Hey Martin, this is my config for the mysensors component

    mysensors:
      gateways:
        port: '/dev/ttyUSB0'
        persistance_file: '/home/pi/.homeassistant/mysensors.json'
      debug: true
      persistance: true
      version: '1.5'
    
    sensor:
      platform: mysensors
    
    switch:
      platform: mysensors
    

    Here is the log after start

    (hass-test)pi@raspberrypi:~/.homeassistant $ hass
    Config directory: /home/pi/.homeassistant
    WARNING:homeassistant.bootstrap:Colorlog package not found, console coloring disabled
    INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: service=turn_off, domain=homea
    ssistant>
    INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: service=turn_on, domain=homeas
    sistant>
    INFO:homeassistant.bootstrap:Home Assistant core initialized
    INFO:homeassistant.loader:Loaded switch from homeassistant.components.switch
    INFO:homeassistant.loader:Loaded discovery from homeassistant.components.discovery
    INFO:homeassistant.loader:Loaded conversation from homeassistant.components.conversation
    INFO:homeassistant.loader:Loaded sensor from homeassistant.components.sensor
    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 logbook from homeassistant.components.logbook
    INFO:homeassistant.loader:Loaded sun from homeassistant.components.sun
    INFO:homeassistant.loader:Loaded mysensors from homeassistant.components.mysensors
    INFO:homeassistant.loader:Loaded frontend from homeassistant.components.frontend
    INFO:homeassistant.loader:Loaded api from homeassistant.components.api
    INFO:homeassistant.loader:Loaded updater from homeassistant.components.updater
    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=recorder>
    INFO:homeassistant.loader:Loaded switch.mysensors from homeassistant.components.switch.mysensors
    INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: service=turn_off, domain=switc
    h>
    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=discovery>
    /home/pi/.homeassistant/lib/fuzzywuzzy/fuzz.py:33: UserWarning: Using slow pure-python SequenceMa
    tcher. Install python-Levenshtein to remove this warning
      warnings.warn('Using slow pure-python SequenceMatcher. Install python-Levenshtein to remove thi
    s warning')
    INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: service=process, domain=conver
    sation>
    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=conversation>
    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=http>
    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=history>
    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=logbook>
    INFO:urllib3.connectionpool:Starting new HTTP connection (1): maps.googleapis.com
    INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: new_state=<state sun.sun=above_hori
    zon; friendly_name=Sun, next_rising=03:32:34 08-01-2016, next_setting=15:36:03 07-01-2016, elevat
    ion=47.84 @ 14:58:04 07-01-2016>, entity_id=sun.sun>
    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=sun>
    INFO:homeassistant.core:Bus:Handling <Event platform_discovered[L]: service=mysensors.sensors, di
    scovered=>
    INFO:homeassistant.core:Bus:Handling <Event platform_discovered[L]: service=mysensors.switches, d
    iscovered=>
    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=mysensors>
    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=api>
    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=frontend>
    INFO:urllib3.connectionpool:Starting new HTTPS connection (1): pypi.python.org
    INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: new_state=<state updater.updater=0.
    10.1; friendly_name=Update Available @ 14:58:06 07-01-2016>, entity_id=updater.updater>
    INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=updater>
    INFO:homeassistant.core:Starting Home Assistant (15 threads)
    INFO:homeassistant.core:Bus:Handling <Event homeassistant_start[L]>
    INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: service=stop, domain=homeassis
    tant>
    INFO:mysensors.mysensors:Trying to connect to /dev/ttyUSB0
    INFO:homeassistant.core:Timer:starting
    INFO:homeassistant.components.mysensors:update persistence: node 1
    INFO:homeassistant.components.http:Starting web interface at http://0.0.0.0:8123
    INFO:netdisco.service:Scanning
    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
    INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 1-1-0 s=255,c=0,t=18,pt=0,l=5,sg=0:1.5.1
    INFO:homeassistant.components.mysensors:update sensor_update: node 1
    INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 1-1-0 s=255,c=3,t=6,pt=1,l=1,sg=0:0
    INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:send: 0-0-1-1 s=255,c=3,t=6,pt=0,l=1,sg=0,st=ok:M
    INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 1-1-0 s=255,c=3,t=11,pt=0,l=5,sg=0:Relay
    INFO:homeassistant.components.mysensors:update sensor_update: node 1
    INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 1-1-0 s=255,c=3,t=12,pt=0,l=3,sg=0:1.0
    INFO:homeassistant.components.mysensors:update sensor_update: node 1
    INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 1-1-0 s=1,c=0,t=3,pt=0,l=0,sg=0:
    INFO:homeassistant.components.mysensors:update sensor_update: node 1
    INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 1-1-0 s=3,c=1,t=3,pt=0,l=1,sg=0:0
    INFO:homeassistant.components.mysensors:update sensor_update: node 1
    INFO:urllib3.connectionpool:Starting new HTTP connection (1): 192.168.1.1
    INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: new_state=<state sun.sun=above_hori
    zon; friendly_name=Sun, next_rising=03:32:34 08-01-2016, next_setting=15:36:03 07-01-2016, elevat
    ion=47.76 @ 14:58:04 07-01-2016>, old_state=<state sun.sun=above_horizon; friendly_name=Sun, next
    _rising=03:32:34 08-01-2016, next_setting=15:36:03 07-01-2016, elevation=47.84 @ 14:58:04 07-01-2
    016>, entity_id=sun.sun>
    

  • Plugin Developer

    @Mufasa

    The error is in your sketch. When you declare your message you should use child sensor id as first argument. Now you're using the pin number. So then you're sending the value from a child which hasn't been presented to home assistant.

    MyMessage msg(child-sensor-id, variable-type);
    

  • Plugin Developer

    @Mufasa

    Btw, you can remove sensor/switch platform mysensors in your config, if using the latest version of my branch.

    Everything else looks good in the config and the log, what I can tell.



  • @martinhjelmare

    OK I have tried this but I'm am still having no luck, thank you for the quick replies.

    void setup()  
    {   
      // Initialize library and add callback for incoming messages
      gw.begin(incomingMessage, 1, 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);
        
        MyMessage lightMsg(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"));
      }
      
    }
    


  • @martinhjelmare

    Here is the part of the log

    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
    INFO:urllib3.connectionpool:Starting new HTTP connection (1): 192.168.1.1
    INFO:urllib3.connectionpool:Starting new HTTPS connection (1): 192.168.1.29
    INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 1-1-0 s=255,c=0,t=18,pt=0,l=5,sg=0:1.5.1
    INFO:homeassistant.components.mysensors:update sensor_update: node 1
    INFO:homeassistant.components.mysensors:No sketch_name: node 1
    INFO:homeassistant.components.mysensors:No sketch_name: node 1
    INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 1-1-0 s=255,c=3,t=6,pt=1,l=1,sg=0:0
    INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:send: 0-0-1-1 s=255,c=3,t=6,pt=0,l=1,sg=0,st=ok:M
    INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 1-1-0 s=255,c=3,t=11,pt=0,l=5,sg=0:Relay
    INFO:homeassistant.components.mysensors:update sensor_update: node 1
    INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 1-1-0 s=255,c=3,t=12,pt=0,l=3,sg=0:1.0
    INFO:homeassistant.components.mysensors:update sensor_update: node 1
    INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 1-1-0 s=1,c=0,t=3,pt=0,l=0,sg=0:
    INFO:homeassistant.components.mysensors:update sensor_update: node 1
    INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 1-1-0 s=1,c=1,t=2,pt=0,l=1,sg=0:0
    INFO:homeassistant.components.mysensors:update sensor_update: node 1
    


  • @martinhjelmare

    Just ran it again and it seams to have worked, Thanks a lot for the help!!


  • Plugin Developer

    @Mufasa

    If you declare your variable lightMsg in the for loop, it will be overwritten if you have more than one relay. I think you can use an array the same length as number of relays and store the msg variable in the slots of the array. Then use the array where you need your msg variables.



  • @martinhjelmare

    Ok cool just sorted that out! Is there any way to change the names of the individual child sensors and the switch? For example to have a room name and the names of the lights in that room as each child.


  • Plugin Developer

    @Mufasa

    Yes, you can make custom names and groups of your devices.

    https://home-assistant.io/getting-started/devices/

    Also read the blog post on customizing icons from version 0.8.


Log in to reply
 

Suggested Topics

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts