Raspberry Pi gateway + hass.io + MQTT + MySensors
-
In this case I have question why? I Know that why not and because I can is good enough answer but...
You can have best from home assistant (install Hass os) and mysensors (make gateway on separate Arduino). And this way when you want to upgrade to something more than RPi you can do it with minimal damage ( I did it this way and it was quite nice upgrade). But this is only myn2 cents@michał-szura some may say that one integrated device is better than two. Also you can restart and debug mysensors gateway via ssh, try to achieve this with arduino. Anyway, even after you decide to move your controller installation to lets say dedicated server, NUC or VM you can still use your RPi as a network gateway without rebuilding anything.
@Sebex what exactly did you do? Did you use install script, or followed some guide on mentioned forum thread.
To see if supervisor is running executesudo systemctl status hassio-supervisor.service
Also you can usesudo docker pscommand to list running docker containers,sudo docker ps -awill show every container even if it is stopped. -
@michał-szura some may say that one integrated device is better than two. Also you can restart and debug mysensors gateway via ssh, try to achieve this with arduino. Anyway, even after you decide to move your controller installation to lets say dedicated server, NUC or VM you can still use your RPi as a network gateway without rebuilding anything.
@Sebex what exactly did you do? Did you use install script, or followed some guide on mentioned forum thread.
To see if supervisor is running executesudo systemctl status hassio-supervisor.service
Also you can usesudo docker pscommand to list running docker containers,sudo docker ps -awill show every container even if it is stopped.@monte said in Raspberry Pi gateway + hass.io + MQTT + MySensors:
@Sebex what exactly did you do? Did you use install script, or followed some guide on mentioned forum thread.
To see if supervisor is running executesudo systemctl status hassio-supervisor.service
Also you can usesudo docker pscommand to list running docker containers,sudo docker ps -awill show every container even if it is stopped.I followed your github link, and used the cmd below to instal hassio.
curl -sL https://raw.githubusercontent.com/home-assistant/hassio-installer/master/hassio_install.sh | bash -s -- -m MY_MACHINEWhen I run your suggested status cmd I indeed see that hassio is running:
Dec 29 23:18:24 banana hassio-supervisor[1046]: 19-12-29 22:18:24 INFO (MainThread) [__main__] Run Hass.io Dec 29 23:18:24 banana hassio-supervisor[1046]: 19-12-29 22:18:24 INFO (MainThread) [hassio.api] Start API on 172.30.32.2 Dec 29 23:18:24 banana hassio-supervisor[1046]: 19-12-29 22:18:24 INFO (MainThread) [hassio.addons] Phase 'initialize' start 0 add-ons Dec 29 23:18:24 banana hassio-supervisor[1046]: 19-12-29 22:18:24 INFO (MainThread) [hassio.addons] Phase 'system' start 0 add-ons Dec 29 23:18:24 banana hassio-supervisor[1046]: 19-12-29 22:18:24 INFO (MainThread) [hassio.addons] Phase 'services' start 0 add-ons Dec 29 23:18:24 banana hassio-supervisor[1046]: 19-12-29 22:18:24 INFO (SyncWorker_1) [hassio.docker.interface] Start homeassistant/raspberrypi3-64-homeassistant Dec 29 23:18:33 banana hassio-supervisor[1046]: 19-12-29 22:18:33 ERROR (MainThread) [hassio.homeassistant] Home Assistant has crashed! Dec 29 23:18:33 banana hassio-supervisor[1046]: 19-12-29 22:18:33 INFO (MainThread) [hassio.addons] Phase 'application' start 0 add-ons Dec 29 23:18:33 banana hassio-supervisor[1046]: 19-12-29 22:18:33 INFO (MainThread) [hassio.tasks] All core tasks are scheduled Dec 29 23:18:33 banana hassio-supervisor[1046]: 19-12-29 22:18:33 INFO (MainThread) [hassio.core] Hass.io is up and runningBut I tried accessing hassio multiple times via <raspberrypi local ipadres>:8123, which is unresponsive. Any suggestions? The Pi is connected via wifi, ip adres is not yet static but doubt that this is the cause.
-- update
Now that I am looking into it again after setting Pi's IP to static, the bottom 4th line shows an error. Home assistant has crashed. So something is going wrong...
-
@monte said in Raspberry Pi gateway + hass.io + MQTT + MySensors:
@Sebex what exactly did you do? Did you use install script, or followed some guide on mentioned forum thread.
To see if supervisor is running executesudo systemctl status hassio-supervisor.service
Also you can usesudo docker pscommand to list running docker containers,sudo docker ps -awill show every container even if it is stopped.I followed your github link, and used the cmd below to instal hassio.
curl -sL https://raw.githubusercontent.com/home-assistant/hassio-installer/master/hassio_install.sh | bash -s -- -m MY_MACHINEWhen I run your suggested status cmd I indeed see that hassio is running:
Dec 29 23:18:24 banana hassio-supervisor[1046]: 19-12-29 22:18:24 INFO (MainThread) [__main__] Run Hass.io Dec 29 23:18:24 banana hassio-supervisor[1046]: 19-12-29 22:18:24 INFO (MainThread) [hassio.api] Start API on 172.30.32.2 Dec 29 23:18:24 banana hassio-supervisor[1046]: 19-12-29 22:18:24 INFO (MainThread) [hassio.addons] Phase 'initialize' start 0 add-ons Dec 29 23:18:24 banana hassio-supervisor[1046]: 19-12-29 22:18:24 INFO (MainThread) [hassio.addons] Phase 'system' start 0 add-ons Dec 29 23:18:24 banana hassio-supervisor[1046]: 19-12-29 22:18:24 INFO (MainThread) [hassio.addons] Phase 'services' start 0 add-ons Dec 29 23:18:24 banana hassio-supervisor[1046]: 19-12-29 22:18:24 INFO (SyncWorker_1) [hassio.docker.interface] Start homeassistant/raspberrypi3-64-homeassistant Dec 29 23:18:33 banana hassio-supervisor[1046]: 19-12-29 22:18:33 ERROR (MainThread) [hassio.homeassistant] Home Assistant has crashed! Dec 29 23:18:33 banana hassio-supervisor[1046]: 19-12-29 22:18:33 INFO (MainThread) [hassio.addons] Phase 'application' start 0 add-ons Dec 29 23:18:33 banana hassio-supervisor[1046]: 19-12-29 22:18:33 INFO (MainThread) [hassio.tasks] All core tasks are scheduled Dec 29 23:18:33 banana hassio-supervisor[1046]: 19-12-29 22:18:33 INFO (MainThread) [hassio.core] Hass.io is up and runningBut I tried accessing hassio multiple times via <raspberrypi local ipadres>:8123, which is unresponsive. Any suggestions? The Pi is connected via wifi, ip adres is not yet static but doubt that this is the cause.
-- update
Now that I am looking into it again after setting Pi's IP to static, the bottom 4th line shows an error. Home assistant has crashed. So something is going wrong...
@sebex well, that indicates that homeassistant docker container has crashed for some reason. That's why you can not access it via web.
I assume you tried to restart RPi? No changes?
Trysudo docker start homeassistantandsudo docker ps -aafter this to see if it crashed or not.
It will print something like this:CONTAINER ID NAMES IMAGE COMMAND CREATED STATUS b8d101b1b04d addon_core_configurator homeassistant/amd64-addon-configurator:4.2 "/run.sh" 13 hours ago Up 13 hours ee63787039a5 hassio_dns homeassistant/amd64-hassio-dns:1 "coredns -conf /conf…" 14 hours ago Up 14 hours 18c68d86c0ae homeassistant homeassistant/qemux86-64-homeassistant:0.103.5 "/bin/entry.sh pytho…" 14 hours ago Up 14 hours 24f80b84279d hassio_supervisor homeassistant/amd64-hassio-supervisor "/bin/entry.sh pytho…" 14 hours ago Up 14 hoursStatus will show the status of the container. You can read the logs to see why it is crashing with command
sudo docker logs homeassistant.
Yesterday after I wrote a reply I tried that install script on my server and it just worked. I hope we will find problem with your setup :) -
@sebex well, that indicates that homeassistant docker container has crashed for some reason. That's why you can not access it via web.
I assume you tried to restart RPi? No changes?
Trysudo docker start homeassistantandsudo docker ps -aafter this to see if it crashed or not.
It will print something like this:CONTAINER ID NAMES IMAGE COMMAND CREATED STATUS b8d101b1b04d addon_core_configurator homeassistant/amd64-addon-configurator:4.2 "/run.sh" 13 hours ago Up 13 hours ee63787039a5 hassio_dns homeassistant/amd64-hassio-dns:1 "coredns -conf /conf…" 14 hours ago Up 14 hours 18c68d86c0ae homeassistant homeassistant/qemux86-64-homeassistant:0.103.5 "/bin/entry.sh pytho…" 14 hours ago Up 14 hours 24f80b84279d hassio_supervisor homeassistant/amd64-hassio-supervisor "/bin/entry.sh pytho…" 14 hours ago Up 14 hoursStatus will show the status of the container. You can read the logs to see why it is crashing with command
sudo docker logs homeassistant.
Yesterday after I wrote a reply I tried that install script on my server and it just worked. I hope we will find problem with your setup :)@monte yes tried rebooting it several times and also reinstalled but no changes so far, it still crashes.
I tried your commands, after
sudo docker start homeassistantit immediately crashes according to the logs below.CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 0b0ffff70832 homeassistant/armv7-hassio-dns:1 "coredns -conf /conf…" 5 minutes ago Up 5 minutes hassio_dns 3b83e6f9db07 homeassistant/raspberrypi3-64-homeassistant:0.103.5 "/bin/entry.sh pytho…" 2 hours ago Exited (1) 2 seconds ago homeassistant 9fd90364c61f homeassistant/armv7-hassio-supervisorsudo docker logs homeassistant [FATAL tini (6)] exec /bin/entry.sh failed: Exec format error [FATAL tini (6)] exec /bin/entry.sh failed: Exec format errorThanks for the help so far @monte hope we can fix it :D
-
@monte yes tried rebooting it several times and also reinstalled but no changes so far, it still crashes.
I tried your commands, after
sudo docker start homeassistantit immediately crashes according to the logs below.CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 0b0ffff70832 homeassistant/armv7-hassio-dns:1 "coredns -conf /conf…" 5 minutes ago Up 5 minutes hassio_dns 3b83e6f9db07 homeassistant/raspberrypi3-64-homeassistant:0.103.5 "/bin/entry.sh pytho…" 2 hours ago Exited (1) 2 seconds ago homeassistant 9fd90364c61f homeassistant/armv7-hassio-supervisorsudo docker logs homeassistant [FATAL tini (6)] exec /bin/entry.sh failed: Exec format error [FATAL tini (6)] exec /bin/entry.sh failed: Exec format errorThanks for the help so far @monte hope we can fix it :D
@sebex okay, that seems that for some reason script pulled out wrong HA container, I mean for wrong architecture. At least
[FATAL tini (6)] exec /bin/entry.sh failed: Exec format errorindicates that.
What is your RPi version?
You can try running the script without-m MY_MACHINEargument. It should autodetect the architecture and pull correct docker image.
What doesuname -mshow? -
@monte yea it made me wonder as well whether I should have selected the rpi 3 64bit version for docker image.
I have a Raspberry pi 3 b+ (so 64bit).
uname -mshows armv7l, when googling I got the answer that this can also be due to that Raspbian is running in 32 mode?I tried running the script without
-m MY_MACHINEreturns an error for setting the machine.root@banana:/home/pi# sudo curl -sL https://raw.githubusercontent.com/home-assistant/hassio-installer/master/hassio_install.sh | bash -s ModemManager.service enabled [Warning] ModemManager service is enabled. This might cause issue when using serial devices. [ERROR] Please set machine for armv7lI've just completely reflashed my Pi and used a different microsd card (couldn't format the original one anymore). Reinstalled raspbian, docker and hass.io. For the latter I selected raspberrpi3 (instead of rpi3-64). After accessing localip:8123 it seems that hass.io is accessible :D It's currently preparing so looking good!!
-
@monte yea it made me wonder as well whether I should have selected the rpi 3 64bit version for docker image.
I have a Raspberry pi 3 b+ (so 64bit).
uname -mshows armv7l, when googling I got the answer that this can also be due to that Raspbian is running in 32 mode?I tried running the script without
-m MY_MACHINEreturns an error for setting the machine.root@banana:/home/pi# sudo curl -sL https://raw.githubusercontent.com/home-assistant/hassio-installer/master/hassio_install.sh | bash -s ModemManager.service enabled [Warning] ModemManager service is enabled. This might cause issue when using serial devices. [ERROR] Please set machine for armv7lI've just completely reflashed my Pi and used a different microsd card (couldn't format the original one anymore). Reinstalled raspbian, docker and hass.io. For the latter I selected raspberrpi3 (instead of rpi3-64). After accessing localip:8123 it seems that hass.io is accessible :D It's currently preparing so looking good!!
-
@sebex you can chose either. I prefer ethernet, so you don't rely on another piece of software - MQTT broker, no additional setup is required.
Read this docs especially the "Presentation" paragraph. At first I had trouble registering my nodes in HA, because it require particular way of presentation. "Send at least one initial value per V_TYPE. In version 2.x of MySensors, this has to be done in the loop function." -
@sebex you can chose either. I prefer ethernet, so you don't rely on another piece of software - MQTT broker, no additional setup is required.
Read this docs especially the "Presentation" paragraph. At first I had trouble registering my nodes in HA, because it require particular way of presentation. "Send at least one initial value per V_TYPE. In version 2.x of MySensors, this has to be done in the loop function." -
@monte ok thanks, will take it into account.
Out of curiousity, since MQTT takes additional setup what''s the benefit of using MQTT? Do you know?@sebex I guess if you already have other mqtt services or devices in your system, or want to use a controller that is designed specifically around mqtt, nodered for example, or the one that doesn't have support for Mysensors specifically.
Also you could use Mysensors with remote mqtt server, your own, or third party. I tried this once, when I needed one sensor exposed to internet without dedicated server hardware at place, so I've built an esp8266 gateway with mqtt connected to free online mqtt broker. The nodered controller was also hosted on a free cloud :)
Not that it was particularly useful, or I would recommend it to someone, but it's a flexibility Mysensors has, and I guess it's the main reason so many people are using it for their projects. -
@monte ok it seems to work. Temp/humidity sensor is recognised by HA and data is getting through so looks good! Only connection isnt stable which is most likely due to that I still need to get capacitors for the NRF24L01+ on both ends, and need to solder the cables to the sensor. So still some tweaks to do but happy that it works, thanks for the support @monte :grinning:
Two general questions, any advice for which capacitor to select? Apart from 4.7 or 47uF, there's different types. Tanto, elco, bipolaire etc.
Furthermore I wondered why the 64bit hassio software didn't work on my Arduino, while it is a 64bit RPi 3+. Does Raspbian (or dockers?) as default run in 32? -
@monte ok it seems to work. Temp/humidity sensor is recognised by HA and data is getting through so looks good! Only connection isnt stable which is most likely due to that I still need to get capacitors for the NRF24L01+ on both ends, and need to solder the cables to the sensor. So still some tweaks to do but happy that it works, thanks for the support @monte :grinning:
Two general questions, any advice for which capacitor to select? Apart from 4.7 or 47uF, there's different types. Tanto, elco, bipolaire etc.
Furthermore I wondered why the 64bit hassio software didn't work on my Arduino, while it is a 64bit RPi 3+. Does Raspbian (or dockers?) as default run in 32?@sebex 4.7uF should be enough, I've never seen any problem with this value on my nodes. As for the type of the capacitor you probably will want to use ceramic or electrolytic (polarized) capacitor, but it doesn't do much difference for this application, if any. Those are just the most common types. Ceramic SMD capacitor of a size 0805 is the best choice IMO because it could be soldered directly to the VCC and GND pins on top of NRF24 module.
You can google about why raspbian is running like RPi is 32 bits, but as I understood it's better for downward compatibility and the fact that RPi3 won't get much boost (if any) from switching to 64 bit architecture. -
@sebex 4.7uF should be enough, I've never seen any problem with this value on my nodes. As for the type of the capacitor you probably will want to use ceramic or electrolytic (polarized) capacitor, but it doesn't do much difference for this application, if any. Those are just the most common types. Ceramic SMD capacitor of a size 0805 is the best choice IMO because it could be soldered directly to the VCC and GND pins on top of NRF24 module.
You can google about why raspbian is running like RPi is 32 bits, but as I understood it's better for downward compatibility and the fact that RPi3 won't get much boost (if any) from switching to 64 bit architecture. -
Ok so I am experiencing node loss. After a while my sensor node is not recognized anymore by the gateway/mothernode. It seems to be related to the persistence file that is not accessible although the user account should have the correct rights, not sure how to verify. See HA dev logs below.
Developer Tools Permission denied when writing to /config/home/pi/.homeassistant/mysensors.json 10:13 PM /usr/local/lib/python3.7/site-packages/mysensors/persistence.py (ERROR) - message first occurred at 10:06 PM and shows up 42 times Node 1 is unknown 10:11 PM __main__.py (WARNING) - message first occurred at 10:06 PM and shows up 116 times Failed to load sensors from file: home/pi/.homeassistant/mysensors.json 10:06 PM /usr/local/lib/python3.7/site-packages/mysensors/persistence.py (WARNING) File does not exist or is not readable: home/pi/.homeassistant/mysensors.json.bak 10:06 PM /usr/local/lib/python3.7/site-packages/mysensors/persistence.py (WARNING) Trying backup file: home/pi/.homeassistant/mysensors.json.bak 10:06 PM /usr/local/lib/python3.7/site-packages/mysensors/persistence.py (WARNING) File does not exist or is not readable: home/pi/.homeassistant/mysensors.json 10:06 PM /usr/local/lib/python3.7/site-packages/mysensors/persistence.py (WARNING)```# MySensors gateway mysensors: gateways: - device: '192.168.178.27' persistence_file: 'home/pi/.homeassistant/mysensors.json' tcp_port: 5003 persistence: true logger: default: info logs: homeassistant.components.mysensors: debug mysensors: debug@drock1985 saw your post in another thread related to this, do you have a suggestion?
-
Ok so I am experiencing node loss. After a while my sensor node is not recognized anymore by the gateway/mothernode. It seems to be related to the persistence file that is not accessible although the user account should have the correct rights, not sure how to verify. See HA dev logs below.
Developer Tools Permission denied when writing to /config/home/pi/.homeassistant/mysensors.json 10:13 PM /usr/local/lib/python3.7/site-packages/mysensors/persistence.py (ERROR) - message first occurred at 10:06 PM and shows up 42 times Node 1 is unknown 10:11 PM __main__.py (WARNING) - message first occurred at 10:06 PM and shows up 116 times Failed to load sensors from file: home/pi/.homeassistant/mysensors.json 10:06 PM /usr/local/lib/python3.7/site-packages/mysensors/persistence.py (WARNING) File does not exist or is not readable: home/pi/.homeassistant/mysensors.json.bak 10:06 PM /usr/local/lib/python3.7/site-packages/mysensors/persistence.py (WARNING) Trying backup file: home/pi/.homeassistant/mysensors.json.bak 10:06 PM /usr/local/lib/python3.7/site-packages/mysensors/persistence.py (WARNING) File does not exist or is not readable: home/pi/.homeassistant/mysensors.json 10:06 PM /usr/local/lib/python3.7/site-packages/mysensors/persistence.py (WARNING)```# MySensors gateway mysensors: gateways: - device: '192.168.178.27' persistence_file: 'home/pi/.homeassistant/mysensors.json' tcp_port: 5003 persistence: true logger: default: info logs: homeassistant.components.mysensors: debug mysensors: debug@drock1985 saw your post in another thread related to this, do you have a suggestion?
-
@Sebex you are using Hassio, so there is no /home/pi folder. Try
persistence_file: 'mysensors.json' -
@monte, I'm seeing that a HA update is available. Since I'm using HA via docker the following applies to update.
$ sudo docker pull homeassistant/home-assistant:latest
To be on the safe side I'd like to backup my HA and/or RPi first to prevent me from losing all my settings. In your experience what's the most convenient for doing this. I did make a clone from the sd card a few weeks ago but it's not the most labour efficient method, do you make regular backups? -
@monte, I'm seeing that a HA update is available. Since I'm using HA via docker the following applies to update.
$ sudo docker pull homeassistant/home-assistant:latest
To be on the safe side I'd like to backup my HA and/or RPi first to prevent me from losing all my settings. In your experience what's the most convenient for doing this. I did make a clone from the sd card a few weeks ago but it's not the most labour efficient method, do you make regular backups?@Sebex if you installed Hassio with provided script then you can find your Home Assistant config folder in
/usr/share/hassio. You can also change this path to your liking in/etc/hassio.jsonconfig file.
To backup all of your HA settings and setups you need to just copy this folder. That's why I like idea of using Docker. You can lose all your RPi setup, but if you fave backed up your config folder it only matter of half an hour to recover everything from scratch. -
@Sebex if you installed Hassio with provided script then you can find your Home Assistant config folder in
/usr/share/hassio. You can also change this path to your liking in/etc/hassio.jsonconfig file.
To backup all of your HA settings and setups you need to just copy this folder. That's why I like idea of using Docker. You can lose all your RPi setup, but if you fave backed up your config folder it only matter of half an hour to recover everything from scratch.@monte can you copy this over ssh? tried using scp -r, which seemed to work but can't find the downloaded files somehow.
And in regard of updating HA(within UI I see that and update is available). I can just stop the container and run a new updated version right, without it affecting config files?Furthermore I wondered about HA speed, if I want to look at the history of a sensors it takes quite a while to poll the data and create a graph. Is this subsequent to HA/rpi or can the performance be improved somehow?
-
@monte can you copy this over ssh? tried using scp -r, which seemed to work but can't find the downloaded files somehow.
And in regard of updating HA(within UI I see that and update is available). I can just stop the container and run a new updated version right, without it affecting config files?Furthermore I wondered about HA speed, if I want to look at the history of a sensors it takes quite a while to poll the data and create a graph. Is this subsequent to HA/rpi or can the performance be improved somehow?
@Sebex yes, you can copy config over ssh, like every other directory you have access to. It should be located from where you were running scp command. Do you use linux on your desktop/laptop?
You can also create samba share on your raspberry with location of your config folder, and then access it from any pc on the network, it makes easy to config your HA.Yes you can pull newer version of a container and all your config files should be in place.
Can't help you with UI speed, sorry. You can try to find anything on HA forum, maybe there is someone who made some performance tests.