First off, I am quite new to this HomeAssistant thing. I’ve always just made my own solutions but I decided to give HA a shot since it already has a nice front-end and it can run on the RPi.
On the MySensors webpage, it shows the possibility of connecting an NRF024 to the RPi to act as a gateway. Now how would I add this to HA? I know I can edit configuration.yaml to add the mysensors section and define the gateway, although the gateway is wired to SPI, not UART or USB or over MQTT. How would I define that device path and baud rate?
Would it just be /dev/spidev0.0 and then no baud rate defined?
Yes, the radio is connected directly to the RPi GPIO header using the SPI0 connections.
I assume this program is written by me, otherwise who would know how often we need to check the nodes. My question is where does HA fit in with that? I figure that I list my sensors, that I want the gateway to check, in the configuration.yaml file and then HA will execute those reads?
I think this is my main area of confusion here since MySensors to seem to be a standalone thing and the HA is this massive complex shell meant to integrate with lots of things. I’m just not sure where to put the hooks in between them and what hooks are already there.
No, you get the program via clone, build, run etc, if you follow the instruction in the link above.
Updates are pushed to the gateway by the nodes, so no polling is necessary. You don’t need to list your nodes, that’s taken care of by the mysensors integration in home assistant. You just need to specify what gateway you are using and how home assistant should connect to it, and some other optional configuration options. See:
What you do need to do is write the sketches for the nodes. But there are ready examples for the simple cases over at mysensors.org, so you can get a long way with very little coding experience. Although I suggest you first try the example sketches that I’ve made available for each mysensors platform in home assistant. There are some steps required to properly present a node/sensor to the mysensors integration in home assistant that is not always done in the general examples over at mysensors.org.
I’m not sure what you mean here (sorry). If you mean what platforms are available for a component, eg if mysensors has a light platform or not, those are seen in the right bar, under “Related components” in desktop mode in homeassistant.io, when you browse a component page.
Some flow like this, but way more accurate. I made this in like two minutes.
I saw that it wasn’t supported in the documentation but it did have functionality in MyTopologyRFM69.cpp and was already set in the configure program. I hadn’t found that pull request though, good find! I guess I’ll be diggin through that tonight.
I wouldn’t mind making documentation like that at all! I do need to understand HA much more though, haha. Right now I’m just trying to fully understand how I can take further action on any status updates HA receives instead of just monitoring all of the inputs.
I had some spare time tonight so I figured I’d dig into this a little further.
The RFM69 gateway was merged into the development branch of MySensors about a week ago. Just using straight MySensors API, one could now setup an RFM69 radio as the gateway attached to the RPi.GPIO. After chugging through Home Assistant code, it looks like HA will set up the gateway in the mysensors.py file of HA at about line 182:
After running through the “pymysensors” file that HA references, I found where it sets up the SerialGateway (it wasn’t hard, the file is named gateway_serial.py). This is we actually communicate with the later that does the real signaling on the serial interface. Unfortunately the python module used is the serial module which is for UART operations only.
If a user wants to directly attach a gateway to the RPi GPIO header through the SPI connections, rather than the UART connect to a microcontroller loaded with Arduino, I think we’ll need some new functionality that enables directly attached SPI radios.
I wouldn’t be against writing this myself, but it’d be incredibly tailored to the Raspberry Pi
Didn’t we already talk about this above? It’s not the gateway that is attached to GPIOs, it’s the radio. There’s no need to change home assistant or pymysensors to do so. You will run a program on the RPi that will emulate a serial port or create an tcp socket server, or run a mqtt client. It’s through these three options home assistant will interface with mysensors.
We discussed attaching the radio to the GPIO. I must be misunderstanding what a gateway is then.
Isn’t the radio the gateway? As in, the gateway could be an Arduino connected, by UART, to a radio or it could be just be the radio connected by SPI with no Arduino involved. If that is true, then we only have functionality to do the UART signaling and not the SPI signaling.
Trying to emulate these services wouldn’t be the most straightforward option. Supplying a SPI driver for HA would be very beneficial for its growth and futureproof.
Okay so I totally didn’t know that when the documentation said a serial port, it meant I could use a tty device for IPC.
So if there are any other firmware engineers reading this, these serial ports aren’t necessarily UARTs.