1-Wire home automation tutorial from linux.conf.au 2019, part 3

This is the third in a set of posts about the home automation tutorial from linux.conf.au 2019. You should probably read part 1 and part 2 before this post. In the end Alistair decided that my home automation shield was defective, which is the cause of the errors from the past post. So I am instead running with the prototype shield that he handed me when I started helping with the tutorial preparation. That shield has some other bugs (misalignments of holes mainly), but is functional apart from that. I have also decided that I'm not super excited by hassos, and just want to run the orangepi with the OWFS to MQTT gateway into my existing home assistant setup if possible, so I am going to focus on getting that bare component working for now. To that end, the gateway can be found at https://github.com/InfernoEmbedded/OWFS-MQTT-Bridge, and is a perl script named ha-daemon.pl. I needed to install some dependancies, which in my case were for armbian: $ apt-get install perl libanyevent-perl cpanminus libdist-zilla-perl libfile-slurp-perl libdatetime-format-strptime-perl $ dzil listdeps | cpanm --sudo Then I needed to write a configuration file and put it at ha.toml in the same directory as the daemon.…

Continue Reading1-Wire home automation tutorial from linux.conf.au 2019, part 3

1-Wire home automation tutorial from linux.conf.au 2019, part 2

For the actual on-the-day work, delegates were handed a link to these instructions in github. If you're playing along at home, you should probably read 1-Wire home automation tutorial from linux.conf.au 2019, part 1 before attempting the work described here. Its especially important that you know the IP address of your board for example. Relay tweaks The instructions are pretty self explanatory, although I did get confused about where to connect the relay as I couldn't find PC8 in my 40 pin header diagrams. That's because the shields for the tutorial have a separate header which is a bit more convenient: I was also a bit confused when the relay didn't work initially, but that turns out because I'd misunderstood the wiring. The relay needs to be powered from the 3.3v pin on the 40 pin header, as there is a PCB error which puts 5v on the pins labelled as 3.3v on the GPIO header. I ended up with jumper wires which looked like this: 1-Wire issues Following on the tutorial instructions worked well from then on until I tried to get 1-Wire setup. The owfs2mqtt bridge plugin was logging this: 2019-04-08 19:23:55.075: /opt/OWFS-MQTT-Bridge/lib/Daemon/OneWire.pm:148:Daemon::logError(): Connection to owserver failed: Can't connect…

Continue Reading1-Wire home automation tutorial from linux.conf.au 2019, part 2

1-Wire home automation tutorial from linux.conf.au 2019, part 1

I didn't get much of a chance to work through the home automation tutorial at linux.conf.au 2019 because I ended up helping others in the room get their Orange Pi is booting. Now that things have settled down after the conference, I've had a chance to actually do some of the tutorial myself. These are my notes so I can remember what I did later... Pre-tutorial setup You need to do the pre-tutorial setup first. I use Ubuntu, which means its important that I use 18.10 or greater so that st-link is packaged. Apart from that the instructions as written just worked. You also need to download the image for the SD card, which was provided on the day at the conference. The URL for that is from github. Download that image, decompress it, and then flash it to an SD card using something like Balena Etcher. The tutorial used 32gb SD cards, but the image will fit on something smaller than that. hassos also doesn't put anything on the Orange Pi HDMI port when it boots, so your machine is going to look like it didn't boot. That's expected. For the tutorial we provided a mapping from board number (mac…

Continue Reading1-Wire home automation tutorial from linux.conf.au 2019, part 1

Support for Raspberry Pi and Orange Pi GPIOs in Home Assistant

So, I've been off in the GPIO library salt mines for a while, but am now ready to circle back and document how to get GPIO inputs and outputs working in Home Assistant. This now works on both Raspberry Pi and OrangePi, assuming that my patch gets merged. First off, let's talk about GPIO outputs. This is something which has been working for a while on both platforms (a while being a week or so, assuming you've patched Home Assistant with my pull request, but you're all doing that right?). To configure an output in Home Assistant, you would add the following to configuration.yaml: rpi_gpio: board_family: orange_pi switch: - platform: rpi_gpio ports: PA7: LED Where board_family can be either "raspberry_pi" or "orange_pi". Note that for Raspberry Pis, the pin numbers are always numbers whereas for OrangePi we are using "SUNXI" numbering, which is of the form "PA7". The circuit for this LED is really simple: Now we have a switch we can control in Home Assistant: GPIO inputs are similar. The configuration looks like this: rpi_gpio: board_family: orange_pi binary_sensor: - platform: rpi_gpio invert_logic: true ports: PA7: PUSHYBUTTON With a circuit like this: invert_logic set to true is required because our…

Continue ReadingSupport for Raspberry Pi and Orange Pi GPIOs in Home Assistant

Updated examples for OrangePi GPIOs

As part of working through adding OrangePi support to Home Assistant, Alastair and I decided to change to a different GPIO library for OrangePi to avoid the requirement for Home Assistant to have access to /dev/mem. I just realised that I hadn't posted updated examples of how to do GPIO output with the new library. So here's a quick post about that. Assuming that we have an LED on GPIO PA7, which is pin 29, then the code to blink the LED would look like this with the new library: import OPi.GPIO as GPIO import time # Note that we use SUNXI mappings here because its way less confusing than # board mappsings. For example, these are all the same pin: # sunxi: PA7 (the label on the board) # board: 29 # gpio: 7 GPIO.setmode(GPIO.SUNXI) GPIO.setwarnings(False) GPIO.setup('PA7', GPIO.OUT) while True: GPIO.output('PA7', GPIO.HIGH) time.sleep(1) GPIO.output('PA7', GPIO.LOW) time.sleep(1) The most important thing there is the note about SUNXI pin mappings. I find the whole mapping scheme hugely confusing, unless you use SUNXI and then its all fine. So learn from my fail people! What about input? Well, that's not too bad either. Let's assume that you have a button in a…

Continue ReadingUpdated examples for OrangePi GPIOs

Pull Requests for the LCA2019 Home Automation tutorial

A quick list of things I did for the LCA2019 Home Automation tutorial. Of course Alistair did a lot more, but I still want to track these. Add OrangePi GPIO support to Home Assistant (declined) Document OrangePi GPIO support in Home Assistant (declined) Add OrangePi Prime GPIO pinouts to OPi.GPIO (merged, and released) Expose pullup resistor constants in OPi.PGIO (merged, and released) A simple burn in script for the workshop boards (merged) Automated generation of dhcpd.conf for the workshop network (merged) Clarifications for the workshop prerequisites (merged) Not all pins on Orange Pi support edge detection Clarify where the GPIO header is on the LCA2019 shield

Continue ReadingPull Requests for the LCA2019 Home Automation tutorial

Further adventures in Home Assistant OrangePi GPIO

Its funny how a single sentence can change your course. In the last post about this work, I said: We also need to run hass as root,  because OrangePi GPIO support requires access to /dev/mem for reasons I haven’t dug into just yet. That's turned out to be (reasonably) a pretty big sticking point upstream. Access to /dev/mem gives you a whole bunch of access to the machine that Home Assistant probably shouldn't have. Alastair went off spelunking because he's more patient than me and found yet another OrangePi GPIO library. I think we're up to three or four of these at the moment, but this is the first one we've found which supports the sysfs interface to GPIO pins. That's exciting because it removes our run-as-root requirement. Its unexciting in that the sysfs interface has been deprecated by the kernel, but will remain supported for a while. I think people would be within their rights to conclude that the state of GPIO libraries for OrangePi is a bit of a dumpster fire right now. Anyways, the point of this post is mostly to write down how to use the sysfs interface to GPIO pins so that I can remember it later,…

Continue ReadingFurther adventures in Home Assistant OrangePi GPIO

Adventures in Home Assistant Raspberry Pi GPIO

Alastair D'Silva is running what looks to be a very well prepared home automation tutorial at LCA2019 based on Home Assistant. I offered to have a hack on the support for GPIO pins on OrangePi boards in Home Assistant because it sounded interesting for a vacation week. The only catch being that I'd never done anything with GPIO pins at all on either Raspberry Pi or Orange Pi. The first step seemed to be to get GPIO working at all on a Raspberry Pi (which is currently supported out of the box with Home Assistant). This online tutorial has a simple example of a circuit and the associated python code to blink a LED on a Raspberry Pi, so off I went to build that circuit. The circuit has a LED with a 330 ohm pull up resistor on GPIO pin 18 on the board. The sample python code on the page above just blinks that LED, which I used to make sure that the circuit as working as intended. To configure the GPIO pin as a switch in Home Assistant, I added the following to configuration.yaml (noting that the empty rpi_gpio entry isn't strictly required, but will be later): rpi_gpio: switch: -…

Continue ReadingAdventures in Home Assistant Raspberry Pi GPIO

End of content

No more pages to load