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

      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 Offline
      martinhjelmareM Offline
      martinhjelmare
      Plugin Developer
      wrote on last edited by
      #55

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

      1 Reply Last reply
      0
      • MufasaM Offline
        MufasaM Offline
        Mufasa
        wrote on last edited by
        #56

        @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>
        
        martinhjelmareM 2 Replies Last reply
        0
        • MufasaM Mufasa

          @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>
          
          martinhjelmareM Offline
          martinhjelmareM Offline
          martinhjelmare
          Plugin Developer
          wrote on last edited by martinhjelmare
          #57

          @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);
          
          1 Reply Last reply
          1
          • MufasaM Mufasa

            @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>
            
            martinhjelmareM Offline
            martinhjelmareM Offline
            martinhjelmare
            Plugin Developer
            wrote on last edited by
            #58

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

            1 Reply Last reply
            1
            • MufasaM Offline
              MufasaM Offline
              Mufasa
              wrote on last edited by
              #59

              @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"));
                }
                
              }
              
              1 Reply Last reply
              0
              • MufasaM Offline
                MufasaM Offline
                Mufasa
                wrote on last edited by
                #60

                @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
                
                1 Reply Last reply
                0
                • MufasaM Offline
                  MufasaM Offline
                  Mufasa
                  wrote on last edited by Mufasa
                  #61

                  @martinhjelmare

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

                  martinhjelmareM 1 Reply Last reply
                  0
                  • MufasaM Mufasa

                    @martinhjelmare

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

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

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

                    1 Reply Last reply
                    0
                    • MufasaM Offline
                      MufasaM Offline
                      Mufasa
                      wrote on last edited by
                      #63

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

                      martinhjelmareM 1 Reply Last reply
                      0
                      • MufasaM Mufasa

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

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

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

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


                        23

                        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