GPIO Configuration for Orange PI

Hello,
Another satisfied user of Home Assistant here.
:slight_smile:
I have just recently discovered it and am going nuts (in a happy, crazy way :slight_smile: ) using it and trying to integrate various components into my setup.
I have hit a snag with platform it is running on. I am using a orange pi zero for running the home assistant server on. it works fine and without any issues.
I want to use the GPIO for controlling several relays with the orange pi.
However there is not orangepi_gpio component in the repo to use.
I am almost certain that the stock raspberrypi_gpio will not work with it dues the differences in the underlying libraries for rpi and opi.

There exists a wiringpi library for the opi too. Is it as simple as creating a custom component for the pio and set it up in a similar way for the opi as it is done for the rpi?? I would love to work on making it happen and contributing to the project.

If a good samaritan can point me to articles / guides on how it is done for the rpi and creating custom components…
:slight_smile:
Thank you and have a nice day!!

It would require orangepi_PC_gpio_pyH3 and a new component including platforms.

Thank you!! Can you provide links to articles which will get me started on those issues. I will try and work and post it here. Might help someone else later. :slight_smile:

PS: That is what I am already using along with SSD1306 python package for driving a OLED display. I thought it would make my life easier if I could use the available GPIO to drive relays /SSR to control lights and power outlets. :slight_smile:

Hi!

I’m also starting a Home Assistant project with Orange Pi Lite. Please let me know when you have something ready so I can test on this platform.

Mikko

@Misna
Will do, I am still getting around to working with home-assistant.
I ll have to see if I can work on integrating the GPIO sections of orangepi into home assistant.

There is a LOT of documentation that is available, :slight_smile: going through it is taking sometime.

If you can control the GPIO from the command prompt on your orange pi using wiringpi / opi then its easy to integrate without a specialized component. Just run a command switch to run a python / php script that uses the wiringpi / opi library. I use a php file because I use it in a webpage

kitchenon.php

<?php //set pins mode to output system ( "gpio -g mode 16 out" ); system ( "gpio -g write 16 0" ); and then in HA I put switch: - platform: command_line switches: kitchen_light: command_on: 'curl -k "http://localhost/action/kitchenon.php"' command_off: 'curl -k "http://localhost/action/kitchenoff.php"' https://home-assistant.io/components/switch.command_line/

Thanks !!! :slight_smile: That was what I was looking for…
I ll push the additions to the repo over the weekend where others can try it out and customize it.

I too am running HA on an Orange Pi Zero. I have encountered many errors. What flavour of linux are you running?

Armbian jessie.

I was able to run the wiringOP and use the command_line_switches as suggested. I am just cleaning up the entire thing before I push it here.

What errors are you seeing??

Sorted most of the errors out by manually starting hass with sudo, I need to get the systemd script set up properly. I suspect I need to run hass --open-ui and also make it run with root privileges??

I am pretty much a linux noob.

Here is the main error I am seeing now.

17-03-15 07:36:23 ERROR (MainThread) [homeassistant.core] Timer got out of sync. Resetting
17-03-15 07:36:27 ERROR (MainThread) [homeassistant.core] Timer got out of sync. Resetting
17-03-15 07:36:47 ERROR (MainThread) [homeassistant.components.light] Error while setting up platform hue
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/helpers/entity_component.py", line 153, in _async_setup_platform
    entity_platform.schedule_add_entities, discovery_info
  File "/usr/lib/python3.5/asyncio/futures.py", line 361, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 296, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/components/light/hue.py", line 138, in setup_platform
    allow_in_emulated_hue, allow_hue_groups)
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/components/light/hue.py", line 149, in setup_bridge
    config_file_path=hass.config.path(filename))
  File "/root/.homeassistant/deps/phue.py", line 629, in __init__
    self.connect()
  File "/root/.homeassistant/deps/phue.py", line 753, in connect
    self.register_app()
  File "/root/.homeassistant/deps/phue.py", line 707, in register_app
    response = self.request('POST', '/api', data)
  File "/root/.homeassistant/deps/phue.py", line 666, in request
    return json.loads(str(result.read(), encoding='utf-8'))
  File "/usr/lib/python3.5/json/__init__.py", line 319, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.5/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.5/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
17-03-15 07:38:22 ERROR (MainThread) [homeassistant.core] Timer got out of sync. Resetting
17-03-15 09:09:26 WARNING (Thread-9) [netdisco.philips_hue_nupnp] Could not query server https://www.meethue.com/api/nupnp: HTTPSConnectionPool(host='www.meethue.com', port=443): Max retries exceeded with url: /api/nupnp (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0xb4930490>: Failed to establish a new connection: [Errno -2] Name or service not known',))

BTW -
Armbian
Ubuntu Linux 16.04.2
Linux 3.4.113-sun8i on armv7l
and latest build of Home Assistant.

I have HA Bridge also running on the Orange Pi
2 lights using wemo emulation and Alexa and a Yeeilight that I now have controlled by HA.

Trying to get the Yeelight to work with Alexa.

( we need a footer for our postings…)

Anyone here that knows how rpi-rf can be ported to the orange pi (zero)? Thise tiny things look nice for such projects.

1 Like