Esp8266 NodeMCU relays switch using mqtt

hey thanks for reading this,
I am new white home automation and i need some help i have setup my home assistent server on my raspberry pi and add the addon musquitto broker so i could connect my MQTT divices like a sonoff.
now i do have one problem when i take a look at the sonoff webpage or Tasmota web page i see that my esp conects to my broker `
[INFO] Setup mosquitto configuration
[WARN] SSL not enabled - No valid certs found!
[INFO] No local user available
[INFO] Initialize Hass.io Add-on services
[INFO] Initialize Home Assistant discovery
[INFO] Start Mosquitto daemon

1547315898: mosquitto version 1.4.15 (build date 2018-03-04 15:36:00+0000) starting
1547315898: Config loaded from /etc/mosquitto.conf.
1547315898: *** auth-plug: startup
1547315898: ** Configured order: http
1547315898: Opening ipv4 listen socket on port 1883.
1547315898: Opening ipv6 listen socket on port 1883.
1547315898: Opening websockets listen socket on port 1884.
1547315898: Warning: Mosquitto should not be run as root/administrator.
1547315898: New connection from 172.30.32.1 on port 1883.
1547315899: Socket error on client , disconnecting.
1547315899: New connection from 172.30.32.1 on port 1883.
[INFO] found homeassistant on local database
1547315899: New client connected from 172.30.32.1 as 23027429-94f8-4188-8af7-3072a47253a3 (c1, k60, u’homeassistant’).
1547315908: New connection from 192.168.1.27 on port 1883.
1547315908: New client connected from 192.168.1.27 as MQTTool-428403666 (c1, k60).
1547316078: Socket error on client MQTTool-428403666, disconnecting.
1547317699: Saving in-memory database to /data/mosquitto.db.
1547319500: Saving in-memory database to /data/mosquitto.db.
1547321301: Saving in-memory database to /data/mosquitto.db.
1547323102: Saving in-memory database to /data/mosquitto.db.
1547324903: Saving in-memory database to /data/mosquitto.db.
1547326704: Saving in-memory database to /data/mosquitto.db.
1547327824: New connection from 192.168.1.112 on port 1883.
1547327824: New client connected from 192.168.1.112 as DVES_111227 (c1, k10).
1547327897: Client 23027429-94f8-4188-8af7-3072a47253a3 disconnected.
1547327915: New connection from 172.30.32.1 on port 1883.
[INFO] found homeassistant on local database
1547327915: New client connected from 172.30.32.1 as 5e8d44fb-dece-4d5c-86e2-1930559d7b25 (c1, k60, u’homeassistant’).
1547328006: Socket error on client DVES_111227, disconnecting.
1547328006: New connection from 192.168.1.112 on port 1883.
1547328006: New client connected from 192.168.1.112 as DVES_111227 (c1, k10).`

but how do i get it show up in home assistent i dont see a popup from hey new devices found can somone help me i am new to this so dont be to hard on me
in advanced thanks you
Pepijn Trampe

You made it more difficult to help you because your log messages appear as one continuous paragraph of hard-to-read content. Can you try formatting the log messages so they appear on separate lines?

like this?

Yes, perfect!

I have made some progress maby usefull that i share it.
I made it work that i can interackt white the web browser to turn off 8 pins on my esp8266 i found a tutorial on youtube https://www.youtube.com/watch?v=c2IUIUnxjUY&t=859s but what i do not understand is how to configurate 8 switches whit mqtt i have this in my configuration.yaml

mqtt:
    broker: core-mosquitto
    username: Pepijn
    password: Trampe

switch:
    platform: mqtt
    name: "computer"
    command_topic: "cmnd/sonoff/power"
    state_topic: "stat/sonoff/POWER"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    retain: true

do i need to coppy this 7 times and choos ather names for each pin?
thanks for helping me
Pepijn Trampe

I deleted my 1st post because I didn’t read yours properly and my reply wasn’t relevant , it doesn’t mean your post will be deleted

ow oke thanks for your replay
but do you have a idea?

you need to give each switch its own name, example
switch:

  • platform: mqtt
    name: “Pool Light”
    command_topic: “commands/pool”
    payload_on: “Pool_Light”
    payload_off: “Pool_Light”
  • platform: mqtt
    name: “Spa Light”
    command_topic: “commands/pool”
    payload_on: “Spa_Light”
    payload_off: “Spa_Light”

oke but i run 8 switche/relay on 1 esp how can i adress every pin to his own switch in HA
or win de config,yaml file see that as 2 difrence switches

which esp are you using that has 8 outputs ?

esp8266 nodemcu and then i am using the tasmoda software and configurated to generic
so i can use gpio 1,2,4,5,12,13,15,16

Didn’t realise pins 1 and 2 could be configured as outputs, and be careful with pin 16, can cause boot problems. As for Tasmota, can’t help, never tried it

but when i configurate to sonoff 1 ch switch then wil it show up in

oke
thanks annyway :slight_smile:

Have you watched this, might help configure pins

There is a tasmota command to turn on ha discovery, then your config will be automatic.

oke i will look in to it thanks

This page covers it https://github.com/arendst/Sonoff-Tasmota/wiki/Home-Assistant

thanks the video that @ady8077 did poste did clear it up thanks

1 Like

i do think 8 switches are not possable but i’m still trying her i found a ather nice video for this topic
Pepijn Trampe