Master & Slave Problems

Hi, I’m having problems with running two instances of HA. I have loads of sensors, switches I want to control via GPIO and they are dotted through my house. Having two pi’s will suit my requirement for number of gpio pins and distance between them. Also one pi has a touch screen so it can be used to control the system in the kitchen. I apologise for the long post, but I wanted to be clear.

Master Raspberry Pi 2, Slave Raspberry Pi B+

What I do:
Master:
$ hass

Slave:
$ python .homeassistant/slave.py

What happens:
Master.IP:1705
All temperatures show up and Switches show up READ ONLY (state not switch)

Slave.IP:8123 
Empty HomeAssistant Page.  After a few min 1 of the temperatures show up but nothing else.

IF I DO THIS INSTEAD:
Master:
$ hass

Slave:
$ sudo python .homeassistant/slave.py (SUDO ADDED TO THIS LINE)

What happens: (SAME)
Master.IP:1705
All temperatures show up and Switches show up READ ONLY (state not switch)

Slave.IP:8123 
Empty HomeAssistant Page.  After a few min 1 of the temperatures show up but nothing else.

BUT IF I DO THIS:
Master:
$ hass

Slave:
$ python .homeassistant/slave.py (allow to load then Ctrl C)
Then without restarting hass
$ sudo python .homeassistant/slave.py (SUDO ADDED TO THIS LINE)

What happens:
Master.IP:1705 (SAME)
All temperatures show up and Switches show up READ ONLY (state not switch)

Slave.IP:8123  
WORKING HomeAssistant Page.  All of the temperatures show up and control over GPIO.

My slave.py
#! /usr/bin/env python

import homeassistant.remote as remote
import homeassistant.bootstrap as bootstrap
import homeassistant.config as config

Location of the Master API: host, password, port.

Password and port are optional.

remote_api = remote.API(“192.168.0.12”, “????”, 1705)

Initialize slave

hass = remote.HomeAssistant(remote_api)

myconfig = config.load_yaml_config_file("/home/pi/.homeassistant/configuration.yaml")

To add an interface to the slave on localhost:8123

bootstrap.setup_component(hass, ‘frontend’, myconfig)

To add my entities

bootstrap.setup_component(hass, ‘switch’, myconfig)
bootstrap.setup_component(hass, ‘sensor’, myconfig)

hass.start()
hass.block_till_stopped()

My slave configuration.yaml

------------------------------------ DS18b20 TEMPERATURE SENSORS

sensor 1:
platform: onewire
names:
28-00000617adbd: Living Room
28-04150115a1ff: Back
28-01156198ebff: Front

----------------------------------------------- RPi-GPIO SWITCH

switch:
platform: rpi_gpio
ports:
26: RED
25: GREEN
24: YELLOW
invert_logic: False

  1. How do I gain control over the slave gpios from the master IP
  2. How do I get all items to show up on the slave without running
    “$ python .homeassistant/slave.py” and then also “$ sudo python .homeassistant/slave.py”

thanks

Update:

I left both the slave and master running for about 30min. The remaining temperatures started showing on the slave.IP, the 2nd one after 10min and the final/3rd after 25min.

I then closed both and added an automation to the master configuation.yaml which turned on/off the Red LED depending on the temperature of Front sensor.

So then i ran Master $ hass and Slave $ python3 .homeassistant/slave.py

The same thing happened as before:
Master.IP:1705
All temperatures show up and Switches show up READ ONLY (state not switch)

    Slave.IP:8123 
    Empty HomeAssistant Page. After a few min 1 of the temperatures show up but nothing else.

But then when the automation trigger was met, the slave.IP:8123 shows the controllable Red LED switch (the other switches are not showing) and two of the temperature sensors show. The Master.IP still shows read only switches, but the automation’s on the master configuation.yaml does control the slave’s switches. The LED does come on and go off as per the automation.

But I still need to know

  1. How do I gain control over the slave gpios from the master IP
  2. How do I get all items to show up on the slave without running
    “$ python .homeassistant/slave.py” and then also “$ sudo python .homeassistant/slave.py” OR a automation trigger is met

Partially solved the issue,

When I started to mess about with two instances I #Blanked out all of the master configuration.yaml GPIO switches and sensors.

After starting, HA prompted an upgrade so I upgraded HA.

So my new installation of HA had never had RPI.GPIO installed.

I added a GPIO switch to the master configuration.yaml, then when i ran hass it installed RPi.GPIO==0.6.1.

Now controllable switches show up on the Master IP.

However the temp sensors and the GPIO switch connected to the slave are unstable on the slave.IP. The temps are not there when i start slave.py but sometimes 2 of them appear after a while. The switch for the Green LED connected to the Master appears on the slave IP but the switch for the Red LED (connected the the slave) does not, until I press it on the Master IP. At which point the remaining 3rd temperature appears too.

Master configuration.yaml (All other text # Blanked Out)

http:
api_password: ??*
server_port: 1705

----------------------------------------------- RPi-GPIO SWITCH

switch M1:
platform: rpi_gpio
ports:
5: Green Raspberry Pi

Slave configuration.yaml

------------------------------------ DS18b20 TEMPERATURE SENSORS

sensor S1:
platform: onewire
names:
28-00000617adbd: Living Room
28-04150115a1ff: Back
28-01156198ebff: Front

----------------------------------------------- RPi-GPIO SWITCH

switch S1:
platform: rpi_gpio
ports:
26: RED

25: GREEN

24: YELLOW

invert_logic: False

How do I get both instances to show every sensor and switch all the time, without having to turn them all on and off in the master? I thought of setting HA to turn on and then off all switches when initializing the slave, but this seems excessive.

3 Likes