Is it possible to change switch to light?

Hello,

I have a 4 channel relay on a nodemcu.

Which looks like this.

switch:

  • platform: gpio
    pin: D1
    name: “Salon1”
    id: Relay_1
  • platform: gpio
    pin: D2
    name: “Salon2”
    id: Relay_2
  • platform: gpio
    pin: D3
    name: “Salon3”
    id: Relay_3
  • platform: gpio
    pin: D4
    name: “Salon4”
    id: Relay_4

How can i setup these as lights ?

I can only do one of the relays with this. Couldn’t manage to get the other 3 working.

Please post the yaml and logs for what doesn’t work.

This is what it looks like.

light:
  - platform: binary
    name: "Light 1"
    output: light_output1
  - platform: binary
    name: "Light 2"
    output: light_output2
  - platform: binary
    name: "Light 3"
    output: light_output3
  - platform: binary
    name: "Light 4"
    output: light_output4    

output:
  - id: light_output1
    platform: gpio
    pin: D1
  - id: light_output2
    platform: gpio
    pin: D2
  - id: light_output3
    platform: gpio
    pin: D3
  - id: light_output4
    platform: gpio
    pin: D4

Log

INFO Reading configuration /config/esphome/isiklar.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing isiklar (board: nodemcuv2; framework: arduino; platform: platformio/espressif8266 @ 3.2.0)
--------------------------------------------------------------------------------
HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
Dependency Graph
|-- <ESPAsyncTCP-esphome> 1.2.3
|-- <ESPAsyncWebServer-esphome> 2.1.0
|   |-- <ESPAsyncTCP-esphome> 1.2.3
|   |-- <Hash> 1.0
|   |-- <ESP8266WiFi> 1.0
|-- <DNSServer> 1.1.1
|-- <ESP8266WiFi> 1.0
|-- <ESP8266mDNS> 1.2
|-- <noise-c> 0.1.4
|   |-- <libsodium> 1.10018.1
RAM:   [====      ]  41.8% (used 34204 bytes from 81920 bytes)
Flash: [=====     ]  48.0% (used 501189 bytes from 1044464 bytes)
========================= [SUCCESS] Took 1.63 seconds =========================
INFO Successfully compiled program.
INFO Resolving IP address of isiklar.local
INFO  -> 192.168.50.110
INFO Uploading /data/isiklar/.pioenvs/isiklar/firmware.bin (505344 bytes)
INFO Compressed to 354412 bytes
Uploading: [============================================================] 100% Done...


INFO Waiting for result...
INFO OTA successful
INFO Successfully uploaded program.
INFO Starting log output from isiklar.local using esphome API
INFO Successfully connected to isiklar.local
[00:51:38][I][app:102]: ESPHome version 2022.6.2 compiled on Aug  3 2022, 00:49:15
[00:51:38][C][wifi:491]: WiFi:
[00:51:38][C][wifi:353]:   Local MAC: EC:FA:BC:63:3E:C8
[00:51:38][C][wifi:354]:   SSID: [redacted]
[00:51:38][C][wifi:355]:   IP Address: 192.168.50.110
[00:51:38][C][wifi:356]:   BSSID: [redacted]
[00:51:38][C][wifi:358]:   Hostname: 'isiklar'
[00:51:38][C][wifi:360]:   Signal strength: -46 dB ▂▄▆█
[00:51:38][C][wifi:364]:   Channel: 7
[00:51:38][C][wifi:365]:   Subnet: 255.255.255.0
[00:51:38][C][wifi:366]:   Gateway: 192.168.50.1
[00:51:38][C][wifi:367]:   DNS1: 192.168.50.1
[00:51:38][C][wifi:368]:   DNS2: 0.0.0.0
[00:51:38][C][logger:275]: Logger:
[00:51:38][C][logger:276]:   Level: DEBUG
[00:51:38][C][logger:277]:   Log Baud Rate: 115200
[00:51:38][C][logger:278]:   Hardware UART: UART0
[00:51:38][C][gpio.output:010]: GPIO Binary Output:
[00:51:38][C][gpio.output:011]:   Pin: GPIO5
[00:51:38][C][gpio.output:010]: GPIO Binary Output:
[00:51:38][C][gpio.output:011]:   Pin: GPIO4
[00:51:38][C][gpio.output:010]: GPIO Binary Output:
[00:51:38][C][gpio.output:011]:   Pin: GPIO0
[00:51:38][C][gpio.output:010]: GPIO Binary Output:
[00:51:38][C][gpio.output:011]:   Pin: GPIO2
[00:51:38][C][light:104]: Light 'Light 1'
[00:51:38][C][light:104]: Light 'Light 2'
[00:51:38][C][light:104]: Light 'Light 3'
[00:51:38][C][light:104]: Light 'Light 4'
[00:51:38][C][captive_portal:088]: Captive Portal:
[00:51:38][C][mdns:084]: mDNS:
[00:51:38][C][mdns:085]:   Hostname: isiklar
[00:51:38][C][ota:085]: Over-The-Air Updates:
[00:51:38][C][ota:086]:   Address: isiklar.local:8266
[00:51:38][C][ota:089]:   Using Password.
[00:51:38][C][api:138]: API Server:
[00:51:38][C][api:139]:   Address: isiklar.local:6053
[00:51:38][C][api:141]:   Using noise encryption: YES
[00:51:48][D][api:102]: Accepted 192.168.50.109
[00:51:49][D][api.connection:861]: Home Assistant 2022.7.7 (192.168.50.109): Connected successfully

and looks like this
Lights_error

So when you flash that you’ll get logs. We need them. (I did ask).

Ok got it. Didnt renew the card :S It is all good now.

thanks for the replies

1 Like