Config error Trying to use GPIO for rf switch and relay switch

Hi, please if someone could help me. I am new to python programming and home assisant. I have set up home assisant to switch relays on a board contacted to gpio pins and also I have blinds and lights on 433 rf which I want to be able to also control through homeassitant. However I cant get both platforms to work together. Can anyone help ?

my code

homeassistant:
  # Name of the location where Home Assistant is running
  name: Granby House
  # Location required to calculate the time the sun rises and sets
  # Impacts weather/sunrise data (altitude above sea level in meters)
  elevation: 257
  # metric for Metric, imperial for Imperial
  unit_system: metric
  # Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
  time_zone: Europe/London

# Show links to resources in log and frontend
# introduction:

# Enables the frontend
frontend:

http:
  # Uncomment this to add a password (recommended!)
  # api_password: PASSWORD
  # Uncomment this if you are using SSL or running in Docker etc
  # base_url: example.duckdns.org:8123

# Checks for available updates
updater:

# Discover some devices automatically
discovery:

# Allows you to issue voice commands from the frontend in enabled browsers
conversation:

# Enables support for tracking state changes over time.
history:

# View all events in a logbook
logbook:

# Track the sun
sun:

# Weather Prediction
sensor:
  platform: yr

# Text to speech
tts:
  platform: google
switch:
  - platform: rpi_rf
    gpio: 17
      bedroom_light:test
          code_on:1234567
          code_off:1234568
      ambilight:t
        pulselength:200
        code_on:987654
        code_off:133742
      living_room_light:liv
        protocol:5
        code_on:654321
        code_off:654320
        signal_repetitions:15
  - platform: rpi_gpio
    ports:
      9: Relay 1
      10: Relay 2 
      22: Relay 3
      27: Relay 4
      4: Relay 6
      3: Relay 7 
      2: Relay 8
    invert_logic: true
mqtt:
  broker: 127.0.0.1
  port: 1883
  client_id: home-assistant-1
  username: pi
  password: raspberry

you have to be very careful to the space indent for each line in your configuration file. Try this:

switch:
  - platform: rpi_rf
    gpio: 17
    bedroom_light:
      code_on:1234567
      code_off:1234568
    ambilight:
      pulselength:200
      code_on:987654
      code_off:133742
    living_room_light:
      protocol:5
      code_on:654321
      code_off:654320
      signal_repetitions:15

Hi, Thank you so much for having a look. I made the changes now getting a new error and sill the same on the home assistant dashboard.

Error code

ERROR (MainThread) [homeassistant.bootstrap] Invalid config for [switch.rpi_rf]: required key not provided @ data[‘switches’]. Got None. (See ?, line ?). Please check the docs at https://home-assistant.io/components/switch.rpi_rf/

The config I am using

homeassistant:

Name of the location where Home Assistant is running

name: Granby House

Location required to calculate the time the sun rises and sets

latitude: 53.7034
longitude: -2.2007

Impacts weather/sunrise data (altitude above sea level in meters)

elevation: 257

metric for Metric, imperial for Imperial

unit_system: metric

Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones

time_zone: Europe/London

Show links to resources in log and frontend

introduction:

Enables the frontend

frontend:

http:

Uncomment this to add a password (recommended!)

api_password: PASSWORD

Uncomment this if you are using SSL or running in Docker etc

base_url: example.duckdns.org:8123

Checks for available updates

updater:

Discover some devices automatically

discovery:

Allows you to issue voice commands from the frontend in enabled browsers

conversation:

Enables support for tracking state changes over time.

history:

View all events in a logbook

logbook:

Track the sun

sun:

Weather Prediction

sensor:
platform: yr

Text to speech

tts:
platform: google

switch:

  • platform: rpi_rf
    gpio: 17
    bedroom_light:
    code_on:1234567
    code_off:1234568
    ambilight:
    pulselength:200
    code_on:987654
    code_off:133742
    living_room_light:
    protocol:5
    code_on:654321
    code_off:654320
    signal_repetitions:15
  • platform: rpi_gpio
    ports:
    9: Relay 1
    10: Relay 2
    22: Relay 3
    27: Relay 4
    4: Relay 6
    3: Relay 7
    2: Relay 8
    invert_logic: true
    mqtt:
    broker: 127.0.0.1
    port: 1883
    client_id: home-assistant-1
    username: pi
    password: raspberry

should not be a space after the : ?

yes, it should. This is my config:

switch:
  - platform: rpi_rf
    gpio: 17
    switches:
      RF switch 1:
        code_on: 1397077
        code_off: 1397076
      RF switch 2:
        code_on: 1394005
        code_off: 1394004
      RF switch 3:
        code_on: 1381717
        code_off: 1381716

Thankyou both, for helping me. Its working now. Its all building on a project I working on.

I am completely renovating an apartment, I have designed it to have full automation as I will be using it for short lets. Every socket and switch has RF 433 which can transmit and receive. So my plan is to use a pi and HA to listen for the for the signals and act or check the state of things ie The Blinds are up or down because the switch has (eg open the blinds in the front room)

I am also hooking up the electrics to a relay board to cut the power properly and ensure things like the oven are switched off when people leave the apartment.

Given my struggle to successful configure a few switches (well thanks to people helping) I am thinking I have a rather daunting task ahead. Can anyone point me in the right direction on this forum if they think a good place for me to find someone who wants to help and is a whizz at yaml ?

I think the best way is to check the HASS website ant the already discussed topics, and if don’t find your answer, ask the community… that’s why we are all here… :slight_smile: