MySensors serial gateway, HA unable to connect /dev/ttyACM0 on HASSbian

Hello,

Starting with the I’m still quite a noob with all this.
However the situation is like this:

  • I have one Arduino Nano node with DHT22 sensor attached to it. It communicates with NFR24L01+. The code is more or less from MySensors library.

  • One Arduino Uno node with NFR24L01+ acting as serial Gateway. This gateway is connected to Pi3 running newest HASSbian by USB cable. It is shown as /dev/ttyACM0. Sketch is default MySensor serial gateway model.

[ 1369.040091] cdc_acm 1-1.5:1.0: ttyACM0: USB ACM device
[ 3835.067626] usb 1-1.5: USB disconnect, device number 6
[ 4001.212899] usb 1-1.4: new full-speed USB device number 7 using dwc_otg
[ 4001.327967] usb 1-1.4: New USB device found, idVendor=2341, idProduct=0043
[ 4001.327987] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=220
[ 4001.328001] usb 1-1.4: Manufacturer: Arduino (www.arduino.cc)
[ 4001.328013] usb 1-1.4: SerialNumber: 9543334393335160E171

  • My configuration.yaml is pretty simple. The default startup lines and then MySensors serial addittions on the bottom:
    mysensors:
    gateways:
    - device: ‘/dev/ttyACM0’
    persistence_file: ‘/home/homeassistant/mysensors1.json’
    baud_rate: 115200
    debug: true
    optimistic: false
    persistence: true
    retain: true
    version: 2.0

  • Startup goes ok, but gives errors of persistence_file even it should really be authorized by homeassistant as the file is in its home directory:
    16-10-31 11:27:31 WARNING (Thread-1) [mysensors.mysensors] File does not exist or is not readable: /home/homeassistant/mysensors1.json
    16-10-31 11:27:31 WARNING (Thread-1) [mysensors.mysensors] Trying backup file: /home/homeassistant/mysensors1.json.bak
    16-10-31 11:27:31 WARNING (Thread-1) [mysensors.mysensors] File does not exist or is not readable: /home/homeassistant/mysensors1.json.bak
    16-10-31 11:27:31 WARNING (Thread-1) [mysensors.mysensors] Failed to load sensors from file: /home/homeassistant/mysensors1.json

  • After this log messages are all green, and it continues with:
    16-10-31 11:29:30 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: old_state=<state sun.sun=above_horizon; next_setting=2016-10-31T14:26:13+00:00, azimuth=200.83, next_rising=2016-11-01T05:46:08+00:00, friendly_name=Sun, elevation=13.65 @ 2016-10-31T13:27:29.856190+02:00>, entity_id=sun.sun, new_state=<state sun.sun=above_horizon; next_setting=2016-10-31T14:26:13+00:00, azimuth=201.08, next_rising=2016-11-01T05:46:08+00:00, friendly_name=Sun, elevation=13.6 @ 2016-10-31T13:27:29.856190+02:00>>
    16-10-31 11:29:32 INFO (Thread-5) [mysensors.mysensors] Trying to connect to /dev/ttyACM0
    16-10-31 11:29:32 ERROR (Thread-5) [mysensors.mysensors] Unable to connect to /dev/ttyACM0
    16-10-31 11:29:42 INFO (Thread-5) [mysensors.mysensors] Trying to connect to /dev/ttyACM0
    16-10-31 11:29:42 ERROR (Thread-5) [mysensors.mysensors] Unable to connect to /dev/ttyACM0
    16-10-31 11:29:52 INFO (Thread-5) [mysensors.mysensors] Trying to connect to /dev/ttyACM0
    16-10-31 11:29:52 ERROR (Thread-5) [mysensors.mysensors] Unable to connect to /dev/ttyACM0
    16-10-31 11:30:02 INFO (Thread-5) [mysensors.mysensors] Trying to connect to /dev/ttyACM0
    16-10-31 11:30:02 ERROR (Thread-5) [mysensors.mysensors] Unable to connect to /dev/ttyACM0
    16-10-31 11:30:12 INFO (Thread-5) [mysensors.mysensors] Trying to connect to /dev/ttyACM0
    16-10-31 11:30:12 ERROR (Thread-5) [mysensors.mysensors] Unable to connect to /dev/ttyACM0
    16-10-31 11:30:22 INFO (Thread-5) [mysensors.mysensors] Trying to connect to /dev/ttyACM0
    16-10-31 11:30:22 ERROR (Thread-5) [mysensors.mysensors] Unable to connect to /dev/ttyACM0

First I thought that this is a permission problem and gave all+r to /dev/ttyACM0. When looking ttyACM0 with cat /dev/ttyACM0 it shows:
0;255;3;0;9;TSP:MSG:READ 255-255-255 3,t=3,pt=0,l=0,sg=0:
255;255;3;0;3;
55-0 s=255,c=3,t=3,pt=0,l=0,sg=0:
255;255;3;0;3;
0;255;3;0;9;TSP:MSG:READ 255-255-0 s=255,c=3,t=3,pt=0,l=0,sg=0:
255;255;3;0;3;
55-0 s=255,c=3,t=3,pt=0,l=0,sg=0:
255;255;3;0;3;
0;255;3;0;9;TSP:MSG:READ 255-255-0 s=255,c=3,t=3,pt=0,l=0,sg=0:
255;255;3;0;3;
0;255;3;0;9;Starting gateway (RNNGA-, 2.0.0)
0;255;3;0;9;TSM:INIT
0;255;3;0;9;TSM:RADIO:OK
0;255;3;0;9;TSM:GW MODE
0;255;3;0;9;TSM:READY
0;255;3;0;14;Gateway startup complete.
0;255;0;0;18;2.0.0
0;255;3;0;9;No registration required
0;255;3;0;9;Init complete, id=0, parent=0, distance=0, registration=1
0;255;3;0;9;TSP:MSG:READ 255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0:
0;255;3;0;9;TSP:MSG:BC
0;255;3;0;9;TSP:MSG:FPAR REQ (sender=255)
0;255;3;0;9;TSP:CHKUPL:OK
0;255;3;0;9;TSP:MSG:GWL OK
0;255;3;0;9;TSP:MSG:SEND 0-0-255-255 s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=bc:0
0;255;3;0;9;TSP:MSG:READ 255-255-0 s=255,c=3,t=3,pt=0,l=0,sg=0:
255;255;3;0;3;
0;255;3;0;9;TSP:MSG:READ 255-255-0 s=255,c=3,t=3,pt=0,l=0,sg=0:
255;255;3;0;3;

I’m really stuck with this now. Can someone help me with this? The HASSbian is the newest version as the MySensors v2.0 library.

I am also using PI3 with mysensors 2.0. At first I tried the port you mentioned above, It did not work. So I use the terminal command dmesg | grep tty, It tells me that the correct port is /dev/ttyUSB0. It started to work when I change the port.

Hello and thanks for the answer.
Problem is that there are no ttyUSB0. Dmesg | grep tty shows:

 [ 0.000000] Kernel command line: 8250.nr_uarts=0 dma.dmachans=0x7f35 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2709.boardrev=0xa22082 bcm2709.serial=0x851aad1a smsc95xx.macaddr=B8:27:EB:1A:AD:1A bcm2708_fb.fbswap=1 bcm2709.uart_clock=48000000 vc_mem.mem_base=0x3dc00000 vc_mem.mem_size=0x3f000000  dwc_otg.lpm_enable=0 console=ttyS0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
    [    0.001334] console [tty1] enabled
    [    1.883384] 3f201000.uart: ttyAMA0 at MMIO 0x3f201000 (irq = 87, base_baud = 0) is a PL011 rev2
    [    2.892178] systemd[1]: Starting system-getty.slice.
    [    2.895904] systemd[1]: Created slice system-getty.slice.
    [    3.723064] cdc_acm 1-1.4:1.0: ttyACM0: USB ACM device

Here are all ttys found in my Pi. ttyACM0 is created everytime when plugging Uno in but no ttyUSB00.

/dev/tty    /dev/tty19  /dev/tty3   /dev/tty40  /dev/tty51  /dev/tty62
/dev/tty0   /dev/tty2   /dev/tty30  /dev/tty41  /dev/tty52  /dev/tty63
/dev/tty1   /dev/tty20  /dev/tty31  /dev/tty42  /dev/tty53  /dev/tty7
/dev/tty10  /dev/tty21  /dev/tty32  /dev/tty43  /dev/tty54  /dev/tty8
/dev/tty11  /dev/tty22  /dev/tty33  /dev/tty44  /dev/tty55  /dev/tty9
/dev/tty12  /dev/tty23  /dev/tty34  /dev/tty45  /dev/tty56  /dev/ttyACM0
/dev/tty13  /dev/tty24  /dev/tty35  /dev/tty46  /dev/tty57  /dev/ttyAMA0
/dev/tty14  /dev/tty25  /dev/tty36  /dev/tty47  /dev/tty58  /dev/ttyprintk
/dev/tty15  /dev/tty26  /dev/tty37  /dev/tty48  /dev/tty59
/dev/tty16  /dev/tty27  /dev/tty38  /dev/tty49  /dev/tty6
/dev/tty17  /dev/tty28  /dev/tty39  /dev/tty5   /dev/tty60
/dev/tty18  /dev/tty29  /dev/tty4   /dev/tty50  /dev/tty61

Should Raspbian create dev/ttyUSB0 or is there something wrong with my Uno? It’s “original” keyestudio version and has been working with windows so far with no problem.

Yes, your case is ttyACM0. Sorry that I didn’t looked into your serial monitor you posted above. It seems that radio transmission is Ok. It reads values from the sensor. You need to change CHILD_ID of the sensor to other value, not 255 or 0.

I have been wondering why the child_id is always 255. Then I thought that the gateway somehow decides the ID regardless what i put in the nodes sketch. Here is the node sketch:

/**
 * 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 <[email protected]>
 * Copyright (C) 2013-2015 Sensnology AB
 *
 * 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
 * Version 1.1 - 2016-07-20: Converted to MySensors v2.0 and added various improvements - Torben Woltjen (mozzbozz)
 * 
 * DESCRIPTION
 * This sketch provides an example of how to implement a humidity/temperature
 * sensor using a DHT11/DHT-22.
 *  
 * 
 */

// Enable debug prints
#define MY_DEBUG

// Enable and select radio type attached 
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
//#define MY_RS485

#include <SPI.h>
#include <MySensors.h>  
#include <DHT.h>

// Set this to the pin you connected the DHT's data pin to
#define DHT_DATA_PIN 2

// Set this offset if the sensor has a permanent small offset to the real temperatures
#define SENSOR_TEMP_OFFSET 0

// Sleep time between sensor updates (in milliseconds)
// Must be >1000ms for DHT22 and >2000ms for DHT11
static const uint64_t UPDATE_INTERVAL = 10000;

// Force sending an update of the temperature after n sensor reads, so a controller showing the
// timestamp of the last update doesn't show something like 3 hours in the unlikely case, that
// the value didn't change since;
// i.e. the sensor would force sending an update every UPDATE_INTERVAL*FORCE_UPDATE_N_READS [ms]
static const uint8_t FORCE_UPDATE_N_READS = 10;

#define CHILD_ID_HUM 10
#define CHILD_ID_TEMP 11

float lastTemp;
float lastHum;
uint8_t nNoUpdatesTemp;
uint8_t nNoUpdatesHum;
bool metric = true;

MyMessage msgHum(CHILD_ID_HUM, V_HUM);
MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
DHT dht;


void presentation()  
{ 
  // Send the sketch version information to the gateway
  sendSketchInfo("TemperatureAndHumidity", "1.1");

  // Register all sensors to gw (they will be created as child devices)
  present(CHILD_ID_HUM, S_HUM);
  present(CHILD_ID_TEMP, S_TEMP);

  metric = getConfig().isMetric;
}


void setup()
{
  dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor
  if (UPDATE_INTERVAL <= dht.getMinimumSamplingPeriod()) {
    Serial.println("Warning: UPDATE_INTERVAL is smaller than supported by the sensor!");
  }
  // Sleep for the time of the minimum sampling period to give the sensor time to power up
  // (otherwise, timeout errors might occure for the first reading)
  sleep(dht.getMinimumSamplingPeriod());
}


void loop()      
{  
  // Force reading sensor, so it works also after sleep()
  dht.readSensor(true);

  // Get temperature from DHT library
  float temperature = dht.getTemperature();

  if (isnan(temperature)) {
    Serial.println("Failed reading temperature from DHT!");
  } else if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS) {
    // Only send temperature if it changed since the last measurement or if we didn't send an update for n times
    lastTemp = temperature;
    if (!metric) {
      temperature = dht.toFahrenheit(temperature);
    }
    // Reset no updates counter
    nNoUpdatesTemp = 0;
    temperature += SENSOR_TEMP_OFFSET;
    send(msgTemp.set(temperature, 1));

    #ifdef MY_DEBUG
    Serial.print("T: ");
    Serial.println(temperature);
    #endif
  } else {
    // Increase no update counter if the temperature stayed the same
    nNoUpdatesTemp++;
  }

  // Get humidity from DHT library
  float humidity = dht.getHumidity();
  if (isnan(humidity)) {
    Serial.println("Failed reading humidity from DHT");
  } else if (humidity != lastHum || nNoUpdatesHum == FORCE_UPDATE_N_READS) {
    // Only send humidity if it changed since the last measurement or if we didn't send an update for n times
    lastHum = humidity;
    // Reset no updates counter
    nNoUpdatesHum = 0;
    send(msgHum.set(humidity, 1));

    #ifdef MY_DEBUG
    Serial.print("H: ");
    Serial.println(humidity);
    #endif
  } else {
    // Increase no update counter if the humidity stayed the same
    nNoUpdatesHum++;
  }

  // Sleep for a while to save energy
  sleep(UPDATE_INTERVAL); 
}

And here is the Gateway sketch:

  /**
 * 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 <[email protected]>
 * Copyright (C) 2013-2015 Sensnology AB
 *
 * 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.
 *
 *******************************
 *
 * DESCRIPTION
 * The ArduinoGateway prints data received from sensors on the serial link. 
 * The gateway accepts input on seral which will be sent out on radio network.
 *
 * The GW code is designed for Arduino Nano 328p / 16MHz
 *
 * Wire connections (OPTIONAL):
 * - Inclusion button should be connected between digital pin 3 and GND  
 * - RX/TX/ERR leds need to be connected between +5V (anode) and digital pin 6/5/4 with resistor 270-330R in a series
 *
 * LEDs (OPTIONAL):
 * - To use the feature, uncomment MY_LEDS_BLINKING_FEATURE in MyConfig.h
 * - RX (green) - blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved
 * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
 * - ERR (red) - fast blink on error during transmission error or recieve crc error 
 * 
 */

// Enable debug prints to serial monitor
#define MY_DEBUG 


// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69

// Set LOW transmit power level as default, if you have an amplified NRF-module and
// power your radio separately with a good regulator you can turn up PA level. 
#define MY_RF24_PA_LEVEL RF24_PA_LOW

// Enable serial gateway
#define MY_GATEWAY_SERIAL

// Define a lower baud rate for Arduino's running on 8 MHz (Arduino Pro Mini 3.3V & SenseBender)
#if F_CPU == 8000000L
#define MY_BAUD_RATE 38400
#endif

// Flash leds on rx/tx/err
#define MY_LEDS_BLINKING_FEATURE
// Set blinking period
#define MY_DEFAULT_LED_BLINK_PERIOD 300

// Inverses the behavior of leds
//#define MY_WITH_LEDS_BLINKING_INVERSE

// Enable inclusion mode
#define MY_INCLUSION_MODE_FEATURE
// Enable Inclusion mode button on gateway
#define MY_INCLUSION_BUTTON_FEATURE

// Inverses behavior of inclusion button (if using external pullup)
//#define MY_INCLUSION_BUTTON_EXTERNAL_PULLUP

// Set inclusion mode duration (in seconds)
#define MY_INCLUSION_MODE_DURATION 60 
// Digital pin used for inclusion mode button
#define MY_INCLUSION_MODE_BUTTON_PIN  3 

// Uncomment to override default HW configurations
//#define MY_DEFAULT_ERR_LED_PIN 4  // Error led pin
//#define MY_DEFAULT_RX_LED_PIN  6  // Receive led pin
//#define MY_DEFAULT_TX_LED_PIN  5  // the PCB, on board LED

#include <SPI.h>
#include <MySensors.h>  

void setup() { 
  // Setup locally attached sensors
}

void presentation() {
 // Present locally attached sensors 
}

void loop() { 
  // Send locally attached sensor data here 
}

Hello Sushukka, I think If you put the line #define MY_NODE_ID 1 after the line #define MY_DEBUG of the sensor. It might help.

Hehe, thanks. That made the messages prettier. Sensor serial monitor shows now:

Starting sensor (RNNNA-, 2.0.0)
TSM:INIT
TSM:RADIO:OK
TSP:ASSIGNID:OK (ID=1)
TSM:FPAR
TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
TSM:FPAR
TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
TSM:FPAR
TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
TSM:FPAR
TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:

Hass startup is still problematic:

16-11-01 11:15:48 INFO (Thread-3) [mysensors.mysensors] Trying to connect to /dev/ttyACM0
16-11-01 11:15:48 INFO (MainThread) [homeassistant.core] Timer:starting
16-11-01 11:15:48 ERROR (Thread-3) [mysensors.mysensors] Unable to connect to /dev/ttyACM0
Exception in thread WSGI-server:
Traceback (most recent call last):
  File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.4/threading.py", line 868, in run
    self._target(*self._args, **self._kwargs)
  File "/home/homeassistant/.homeassistant/deps/cherrypy/wsgiserver/__init__.py", line 2008, in start
    raise socket.error(msg)
OSError: No socket could be created -- (('0.0.0.0', 8123): [Errno 98] Address already in use)

16-11-01 11:15:49 WARNING (Thread-2) [homeassistant.components.recorder] Ended unfinished session (id=22 from 2016-11-01 09:33:15.753878)
16-11-01 11:15:49 WARNING (Thread-2) [homeassistant.components.recorder] Found unfinished sessions
16-11-01 11:15:58 INFO (Thread-3) [mysensors.mysensors] Trying to connect to /dev/ttyACM0
16-11-01 11:15:58 ERROR (Thread-3) [mysensors.mysensors] Unable to connect to /dev/ttyACM0
16-11-01 11:16:08 INFO (Thread-3) [mysensors.mysensors] Trying to connect to /dev/ttyACM0
16-11-01 11:16:08 ERROR (Thread-3) [mysensors.mysensors] Unable to connect to /dev/ttyACM0

cat /dev/ttyACM0 shows now:

pi@raspberrypi:~ $  stty -F /dev/ttyACM0 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -     xten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts
pi@raspberrypi:~ $ cat /dev/ttyACM0
0;25sg=0:36.8
1;10;1;0;1;36.8
0;255;3;0;9;Starting gateway (RNNGA-, 2.0.0)
0;255;3;0;9;TSM:INIT
0;255;3;0;9;TSM:RADIO:OK
0;255;3;0;9;TSM:GW MODE
0;255;3;0;9;TSM:READY
0;255;3;0;14;Gateway startup complete.
0;255;0;0;18;2.0.0
0;255;3;0;9;No registration required
0;255;3;0;9;Init complete, id=0, parent=0, distance=0, registration=1
0;255;3;0;9;TSP:MSG:READ 1-1-0 s=10,c=1,t=1,pt=7,l=5,sg=0:36.9
1;10;1;0;1;36.9
0;255;3;0;9;TSP:MSG:READ 1-1-0 s=10,c=1,t=1,pt=7,l=5,sg=0:36.7
1;10;1;0;1;36.7
0;255;3;0;9;TSP:MSG:READ 1-1-0 s=10,c=1,t=1,pt=7,l=5,sg=0:36.8
1;10;1;0;1;36.8
0;255;3;0;9;TSP:SANCHK:OK
0;255;3;0;9;TSP:MSG:READ 1-1-0 s=10,c=1,t=1,pt=7,l=5,sg=0:36.7
1;10;1;0;1;36.7
0;255;3;0;9;TSP:MSG:READ 1-1-0 s=10,c=1,t=1,pt=7,l=5,sg=0:36.8
1;10;1;0;1;36.8
0;255;3;0;9;TSP:MSG:READ 1-1-0 s=10,c=1,t=1,pt=7,l=5,sg=0:36.7
1;10;1;0;1;36.7
0;255;3;0;9;TSP:SANCHK:OK
0;255;3;0;9;TSP:MSG:READ 1-1-0 s=11,c=1,t=0,pt=7,l=5,sg=0:23.0
1;11;1;0;0;23.0

It seems that the MySensors part is working fine, but somehow Homeassistant just cannot interpret/access the gateway serial feed… :frowning:

I haven’t tried DHT sensor yet, Actually you could look into .json file to see whether temperature value is shown in the file. Then you could look at the States page to see the name of the sensor. If it appears on the States page. You could display in the Front End.

Problem is that Hass cannot create the json file:

16-11-01 11:55:58 WARNING (Thread-1) [mysensors.mysensors] File does not exist or is not readable: /home/homeassistant/mysensors1.json
16-11-01 11:55:58 WARNING (Thread-1) [mysensors.mysensors] Trying backup file: /home/homeassistant/mysensors1.json.bak
16-11-01 11:55:58 WARNING (Thread-1) [mysensors.mysensors] File does not exist or is not readable: /home/homeassistant/mysensors1.json.bak
16-11-01 11:55:58 WARNING (Thread-1) [mysensors.mysensors] Failed to load sensors from file: /home/homeassistant/mysensors1.json

That is however Homeassistant userid’s home folder so it whould have permission to create that file.
In my HA web page there are nothing on states page, but only the weather forecast buttons.
On log page it says:

The following platforms contain invalid configuration: mysensors (please check your configuration)

Hello,
It seems that the problem was again Linux and permission related. I started HASS with root and it downloaded some additional packages and found my sensor. Now temperature/humidity is shown in the states pages nicely. After this I tried again running hass with homeassistant userid but faced the same problem: Unable to connect /dev/ttyACM0. Not sure should I just put chmod 777 on /dev/ttyACM0. It however vanishes after replugging the arduino so it wouldn’t be any permanent solution.

Re permissions on the serial port: you already found out that the HA user account needs access - here’s how that works for me on Ubuntu:

Check which group owns the mysensors tty device. In my case it’s group dialout:

crw-rw-rw-  1 root dialout 166,   0 Nov  2 07:27 ttyACM0

In /etc/group add your HA user to the group dialout:

dialout:x:20:hass

And another recommendation: as tty device names may change after reconnecting the serial gateway or after a restart, you may want to configure your system to use a persistent device name.

1 Like

I have the same problem with premissions in Windows 10.

[31m16-12-19 21:45:26 ERROR (Thread-13) [mysensors.mysensors] Permission denied when writing to C:\Users\Nightbodom\path\mysensors2.jsone[0m

Anyone know how to fix this?

is this really the valid path?

C:\Users\Nightbodom\path\mysensors2.json

i dont think path should be in that line. or do you have a dir named path?

1 Like

Thanks for help. I copy .homeassistrant to c: and change config to that location. Now hass can write sensor data in that file, but i still don’t see sensor (DHT11) on dashboard. I have to check sensor sketch…

btw. if i write hass --open-ui command-line get back: this file (hass.exe) don’t exist
but if i write py -m homeassistant --open-ui it works ok ?!?

i Always used py -m homeassistant --open-ui

i made a bat file from it and a link to that on my startmenu.

Hi
I have a problem. I have connected to my HA gateway mysensors create on Arduino Nano by USB.
In HA log i see this:

16-12-20 22:59:21 mysensors.mysensors: Bad file contents: /home/homeassistant/.homeassistant/mysensors1.json
16-12-20 22:59:21 mysensors.mysensors: Trying backup file: /home/homeassistant/.homeassistant/mysensors1.json.bak
16-12-20 22:59:21 mysensors.mysensors: File does not exist or is not readable: /home/homeassistant/.homeassistant/mysensors1.json.bak
16-12-20 22:59:21 mysensors.mysensors: Failed to load sensors from file: /home/homeassistant/.homeassistant/mysensors1.json

My config for mysensors look:
mysensors:
gateways:
- device: ‘/dev/ttyAMA0’
persistence_file: ‘/home/homeassistant/.homeassistant/mysensors1.json’
baud_rate: 115200

It is run on RPI3 with jessie Lite and All In One instalation HA.

Please help me please

Remove the JSON persistence file and restart home assistant. You will get a warning about the persistence file does not exist etc, when starting home assistant until a sensor is saved to the file. When the first sensor is saved, the file will be created at the path you specified in the config, as long as home assistant can write to that path.