Mervin
(Mervin Naicker)
August 19, 2020, 5:38pm
1
Hi. I have setup an ESP 8266 to read temp and humidity and control a single relay. I was successful with a single relay. I am trying to use Home assistant to code an ESP8266 to control a 2nd relay. The relays are using Pins D4 & D8. I want to know what code should be added to control the second relay.
My code looks like this currently but am getting errors when I try to validate it.
‘’’
sensor:
platform: dht
pin: D2
temperature:
name: “Living Room Temperature”
humidity:
name: “Living Room Humidity”
update_interval: 5s
switch:
platform: gpio
name: “Living Room Lights”
pin: D4
switch:
platform: gpio
name: “Awning Lights”
pin: D8
‘’’
Please could someone assist me with this problem.
Thanks
tom_l
August 19, 2020, 6:01pm
2
Hi and welcome to the forum. Please have a read of point 11 here then edit your post accordingly: How to help us help you - or How to ask a good question
You only need one switch:
, just list them both below one of the:
switch:
- platform: gpio
name: Living Room Lights
pin: D4
- platform: gpio
name: Awning Lights
pin: D8
Mervin
(Mervin Naicker)
August 19, 2020, 6:51pm
5
Hi
I tried that but when I validate it there are errors.
I am will try to post the error here
Try formatting your code, it should look like this:
sensor:
- platform: dht
pin: D2
temperature:
name: "Living Room Temperature"
humidity:
name: "Living Room Humidity"
update_interval: 5s
switch:
- platform: gpio
name: Living Room Lights
pin: D4
- platform: gpio
name: Awning Lights
pin: D8
Mervin
(Mervin Naicker)
August 19, 2020, 8:13pm
7
Hi. Your code works. The issue was the inverted commas in the name. I copied your code and pasted and see that there are no inverted commas.
Thank a million. You are a star.
really appreciate it.
tom_l
August 19, 2020, 8:42pm
8
You might want to reconsider your choice of D8.
1 Like
Mervin
(Mervin Naicker)
August 20, 2020, 6:52am
9
Thanks for the info,
best regards