Multiple gateways with HASS?



  • I have a situation where I have a home and an outbuilding that I would like to monitor and automate with MySensors and HASS. I've seen it written that the MySensors component of HASS supports multiple gateways. I have HaSSbian on Raspberry Pi running in the home, and I have lan access to the outbuilding. It's possible I could use repeater nodes to cover the entire area, but I would also like to explore the possibility of having an ethernet gateway in the out building and a serial gateway in the home. Both gateways would use the nRF24L01+ radio.

    1. Is this configuration possible?
    2. Could I use the same frequency on both gateways?
    3. How would the node address for the gateways need to be configured?

    Thanks,
    Horst


  • Plugin Developer

    Hi!

    1. Yes.
    2. No, each gateway needs its own radio channel.
    3. Node ids between gateways may overlap but I suggest keeping the sketch names for each node unique. That way you will have an easier time identifying the nodes in home assistant.

    The entity_id of each sensor in home assistant will be built like this: sketchname + node id + child id.
    If there's an id conflict when an entity is created, an index will be added to the entity_id. You can avoid this by keeping sketch names unique. Then you don't need to worry about node and child ids, and can assign node ids automatically and child ids sequentially for each node.



  • Thanks for the great explanation. I'll have the chance to see how it works next week. I'll report back how it comes together.



  • I have a partial success. It was very easy to add the serial gateway and configure it under HA. I can now monitor both buildings with MySensors. They have different frequencies and don't interfere with each other.

    The one issue I still need to solve appears to be a Hasspian ( Raspian ) issue where the serial GW ( arduino nano based ) won't register properly as a usb device on reboot. I need to physically unplug and replug the arduino for it to show up and be usable. In searching around so far, I've found it may be related to the arduino showing as a usb 1.1 device. I've tried a few things, but need to study up and continue troubleshooting. It's likely not really relevant to this forum anyway.

    FWIW, I did try extending the one MySensor's tree using repeater mode in the nodes, but it proved to be unreliable, likely due to the distances and walls in the way.

    Thanks again for the help,
    Horst



  • I can happily report that the boot issue I had has been resolved. It turns out I have 2 nano based sensors to use that are basically the same hardware. However, one of the nano's uses the ch340 serial port and the other uses the ftdi. The ftdi one is the one I had loaded the gateway sketch on. I reloaded the gateway sketch on the ch340 based nano, and it was able to register correctly on the pi during boot.

    I found several references to grounding pin 26 ( test ) of the ftdi chip, but that wasn't an option since I didn't have any of the equipment here.
    https://www.raspberrypi.org/forums/viewtopic.php?f=91&t=59420

    I also found a good reference about creating a udev rule to generate an alias device name in case the usb number changes after a reboot. This may come in handy for some folks.... http://rolfblijleven.blogspot.nl/2015/02/howto-persistent-device-names-on.html

    Horst



  • Hi, This topic seems to be similar to what I need, so I will continue in this one.

    I got couple Mysensors NRF nodes and one esp gateway node working fine for some time in now in Openhab, but because I want to make problems for myself I decided to Mysensorize couple of my old nodes and and same time try Home Assistant as well.

    So got my first 2 nodes up and running relatively easy, but after I Mysensorizing the second one with esp problems starts.
    So the problem is that Both ESP nodes call them selfs as "node 0" and at first I got errors like

    2017-07-06 11:44:02 WARNING (Thread-23) [mysensors] child_id 1 already exists in children of node 0, cannot add child
    2017-07-06 11:44:02 WARNING (Thread-23) [mysensors] child_id 2 already exists in children of node 0, cannot add child
    2017-07-06 11:44:02 WARNING (Thread-23) [mysensors] child_id 3 already exists in children of node 0, cannot add child
    2017-07-06 11:44:02 WARNING (Thread-23) [mysensors] child_id 4 already exists in children of node 0, cannot add child
    

    So I taught, well, let's edit second nodes child IDs to start from 5, maybe it will then work out, but now I get error

    2017-07-06 11:44:02 WARNING (Thread-24) [mysensors] child_id 5 already exists in children of node 0, cannot add child
    2017-07-06 11:44:02 WARNING (Thread-24) [mysensors] child_id 6 already exists in children of node 0, cannot add child
    2017-07-06 11:44:02 WARNING (Thread-24) [mysensors] child_id 8 already exists in children of node 0, cannot add child
    2017-07-06 11:44:02 WARNING (Thread-24) [mysensors] child_id 7 already exists in children of node 0, cannot add child
    

    So what's the correct way to get multiple ESPgateway nodes to work with HA? All working fine with Openhab.

    Sorry, using ethernet gateway skeches.


  • Plugin Developer

    @archiijs

    Each gateway should have its own slot in the list of gateways in the mysensors section in the home assistant config. You also need to configure separate radio channels for each gateway if the gateway has a radio. Eg:

    mysensors:
      gateways:
        - device: '192.168.1.11'
          persistence_file: 'path/mysensors1.json'
          tcp_port: 5003
        - device: '192.168.1.12'
          persistence_file: 'path/mysensors2.json'
          tcp_port: 5003
      optimistic: false
      persistence: true
      retain: true
      version: 2.0
    

    Each network can only have one gateway, and the gateway will always have node id 0.



  • @martinhjelmare said in Multiple gateways with HASS?:

    Each gateway should have its own slot in the list of gateways in the mysensors section in the home assistant config. You also need to configure separate radio channels for each gateway if the gateway has a radio. Eg:

    Sorry, I should add my config from beginning.
    This is how it looks in configuration.yaml

    mysensors:
      gateways:
        - device: '192.168.1.50'
          persistence_file: '/root/.homeassistant/mysensors1.json'
          tcp_port: 5003
        - device: '192.168.1.52'
          persistence_file: '/root/.homeassistant/mysensors2.json'
          tcp_port: 5003
        - device: '192.168.1.53'
          persistence_file: '/root/.homeassistant/mysensors3.json'
          tcp_port: 5003
      optimistic: false
      persistence: true
      retain: true
      version: 2.0
    

    First node is my NRF gateway, secound is working ESP gateway node and third one is one with problems mentioned before.

    This it what HA is writing to mysensors3.json

    {"0": {"sketch_name": "Koridors", "type": 17, "sketch_version": "2.0", "sensor_id": 0, "protocol_version": "2.1.1", "_battery_level": 0, "children": {"8": {"description": "", "id": 8, "values": {"0": "19.9"}, "type": 7}, "5": {"description": "", "id": 5, "values": {}, "type": 3}, "6": {"description": "", "id": 6, "values": {}, "type": 3}, "7": {"description": "", "id": 7, "values": {"1": "45.3"}, "type": 6}}}}
    

    But I can not see anything from this sensor in "states" tab in HA
    I do not have any radios attached to secound and third node.
    Thanks for your time.


  • Plugin Developer

    @archiijs

    Looking at the JSON persistence file, child 5 and 6 have empty value objects, child 7 and 8 look good. You need to send at least one initial value per child to home assistant before the entity can be added.

    You should see entities for children 7and 8.



  • Sadly no entities from that node at all in HA states. Also, 5 and 6 were used so they should send their state, but I will check again when I got home.



  • Hi, well issue resolved and unsurprisingly it was me :D

    So the first I got home and took a look at logs again and saw that node two has rejected connection and indeed, it not responded from any UI and even from the light switch, restart fixed it, but now I wonder if it will happen again.

    After that, I used light switches on the third node manualy and they imidietly appeared in HA, but still nothing from DHT sensor. So I took a look at my code and found my error
    I got mixed some things around. I got code like this before

    #define CHILD_TEMP         2   // Id of sensor dht
    #define CHILD_HUM          3   // Id of sensor dht
    
    MyMessage msgHum(CHILD_TEMP, V_HUM);
    MyMessage msgTemp(CHILD_HUM, V_TEMP);
    
    

    So I fixed this like this

    #define CHILD_TEMP         2   // Id of sensor dht
    #define CHILD_HUM          3   // Id of sensor dht
    
    MyMessage msgHum(CHILD_HUM, V_HUM);
    MyMessage msgTemp(CHILD_TEMP, V_TEMP);
    

    After that, all started to work as expected. Thanks for your input.
    0_1499406896616_HA.png


Log in to reply
 

Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.