home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.16k stars 30.19k forks source link

MH-Z19, permission denied on ttyS0 #7513

Closed RonaldvE closed 7 years ago

RonaldvE commented 7 years ago

Make sure you are running the latest version of Home Assistant before reporting an issue.

You should only file an issue if you found a bug. Feature and enhancement requests should go in the Feature Requests section of our community forum:

Home Assistant release (hass --version): 0.44.1

Python release (python3 --version): 3.4.2

Component/platform: MH-Z19 Pi3 All-in-one installer

Description of problem: Cannot get the MH-Z19 CO2 sensor to work, HomeAssistant reports the following error: 2017-05-09 07:22:42 ERROR (Thread-10) [homeassistant.components.sensor.mhz19] Could not open serial connection to /dev/ttyS0 ([Errno 13] could not open port /dev/ttyS0: [Errno 13] Permission denied: '/dev/ttyS0')

Expected:

Problem-relevant configuration.yaml entries and steps to reproduce:

sensor 2:
  platform: mhz19
  serial_device: /dev/ttyS0
  name: MHZ19

Info taken from Pi: root@raspberrypi:/home/pi# ls -l /dev/ttyS0 crw--w---- 1 root tty 4, 64 May 8 20:15 /dev/ttyS0

logged in as Homeassistant: homeassistant@raspberrypi:/home/pi$ ls -l /dev/ttyS0 crw--w---- 1 root tty 4, 64 May 8 20:15 /dev/ttyS0

Traceback (if applicable):

Additional info: I have tried everything that I could think of with permissions and groups, but can't resolve this error.

JshWright commented 7 years ago

TTY devices are generally part of the dialout group. I would suggest adding the user running Home Assistant to that group: sudo usermod -G dialout -a <username>

This isn't a bug in Home Assistant (it is accurately reporting the fact that it lacks permissions to access that device). If you're in need of more help troubleshooting this, head over to the forums, or the Gitter chat, and I suspect someone can get your issue sorted out pretty quickly. https://home-assistant.io/help/