Hi, i use home assistant on Pi3 6 months now and i am out of gpio pins. Is there a solution to get extra pins or put a 2nd Pi3 with HA but to be synchronized with my first one? Any ideas? Thanks
It is hard to give a suggestion without knowing what you are doing and what you are trying to accomplish.
I don’t even have a RaspberryPi and I use plenty of GPIO pins interfacing with other sensors/whatever, but they are all on a NodeMCU and talk to HA via MQTT.
As an alternative, I have a raspberry pi which doesn’t have home assistant running on it. To get HA to interact with it I run webiopi on the pi and call it from HA with the rest platform or curl commands which call the webio API.
For example:
switches:
relay_heating:
command_on: "/usr/bin/curl -X POST http://rpiipaddress:8000/GPIO/17/sequence/250,010"
command_off: "/usr/bin/curl -X POST http://rpiipaddress:8000/GPIO/17/sequence/250,010"
command_state: "/usr/bin/curl -X GET http://rpiipaddress:8000/GPIO/22/value"
value_template: '{{ value == "1" }}'
friendly_name: Heating Switch
This sends a 250ms pulse to toggle the heating on or off and mimics someone pressing the ‘advance’ button.
You can also run scripts, or macros (python). This one reads a DHT11 temperature sensor:
- platform: rest
resource: http://rpiipaddress:8000/macros/temperature
name: Hedgehog House Temperature
method: POST
value_template: '{{value_json.temperature}}'
unit_of_measurement: '°C'
The script on the pi it’s calling:
#!/usr/bin/env python
import webiopi
import Adafruit_DHT
import json
SENSOR = Adafruit_DHT.DHT11
PIN = 17
@webiopi.macro
def temperature():
humidity, temperature = Adafruit_DHT.read_retry(SENSOR, PIN)
if humidity is not None and temperature is not None:
return json.dumps({
"temperature": temperature,
"humidity": humidity
})
else:
return False