MQTT Switch not showing

I have the MQTT server setup in Hass.io and the sonoff talking to it. I can’t get the switch to show up on the main page or in the Developer tools states. I made sure no other “switch:” commnd is in the config file. Has anyone else run into this issue or can see an obvious problem here?
Config
mqtt:
broker: core-mosquitto
username: !secret mqtt_user
password: !secret mqtt_password
discovery: true
discovery_prefix: homeassistant
switch:
- platform: mqtt
name: “Outdoor Christmas lights”
command_topic: “cmnd/sonoff/power”
state_topic: “stat/sonoff/POWER”
qos: 1
payload_on: “ON”
payload_off: “OFF”
retain: true
- platform: wake_on_lan etc…

Hass.io Mosquitto (v4) Log:
1543426914: New connection from 192.168.1.167 on port 1883.
[INFO] found DVES_USER on local database
1543426915: New client connected from 192.168.1.167(ip of sonoff) as DVES_1079CA (c1, k10, u’DVES_USER’)

Sonoff log (tasmota 6.3.0):
18:32:50 MQT: tele/sonoff/STATE = {“Time”:“2018-11-28T18:32:50”,“Uptime”:“0T16:42:54”,“Vcc”:3.177,“POWER”:“OFF”,“Wifi”:{“AP”:1,“SSId”:“XXXXX”,“BSSId”:“XXXXX”,“Channel”:11,“RSSI”:62}}
18:32:50 MQT: tele/sonoff/SENSOR = {“Time”:“2018-11-28T18:32:50”,“Switch1”:“ON”}

Use the “<>” described at the top of this age to format the code correctly. yaml is very format strict, and we can’t see your code formatting.

Yes, I will edit it. Thank you. I did not receive any errors in the yaml checker in Hass.io so I think it is alright.
image

I don’t know what the last line does- I’ve never used Wake on LAN.

You should see an entity named “switch.outdoor_christmas_lights” in the entity page.

I made those changes but no luck showing up on the interface. I looked at my States page and notice the outdoor christmas lights are there but only in the group.all_switches:

group.all_switches off entity_id: switch.ge_14291_inwall_smart_switch_switch,switch.masterbath_switch,switch.outdoor_christmas_lights,switch.rachioe80267_in_standby_mode,switch.wake_on_lan,switch.zone_1__front_drip,switch.zone_10__backyard_west_lawn,switch.zone_11,switch.zone_12__back_drip_garden,switch.zone_13,switch.zone_14__backyard_west_middle,switch.zone_2__front_lawn_east_driveway,switch.zone_3__east_lawn,switch.zone_4__west_driveway_lawn,switch.zone_9__back_drip_trees order: 0 auto: true friendly_name: all switches hidden: true

Question: if you can’t get the switch to show up, how do you know that HASSIO and sonoff are talking? I run my broker on a separate device, but I think your broker needs to be identified by an IP address where you have “core-mosquitto”. Do you have any other MQTT devices that work?

I think I know because the Hass.io Mossquito add-on has a log section that reported this, that 192.168.1.167 is the sonoff switch.

Hass.io Mosquitto (v4) Log:
1543426914: New connection from 192.168.1.167 on port 1883.
[INFO] found DVES_USER on local database
1543426915: New client connected from 192.168.1.167(ip of sonoff) as DVES_1079CA (c1, k10, u’DVES_USER’)

Thanks. So the switch is connecting to the broker, but I’m guessing HA isn’t connecting to the broker. I think it’s because there is no IP specified. You should see a designation in the broker log for HA just like there is for the sonoff switch. Do you see the IP of HASSIO in the broker log?

1 Like

Thank you so much! That was it. I think I assumed by setting up the mosquitto mqtt in hassio that my home assistant was automatically subscribed. I entered the correct IP (MQTT), user and password in the config file and now it is subscribed and the switch is showing up. Cheers and happy holidays.
image

1 Like

day1ok,
Would you please show what the new definition of “Outdoor Chrismas lights” switch looks like? I cannot seem to get my virtual MQTT switch to show up in UI.

1 Like

What do you mean by definition? My entity was defined as “switch.outdoor_christmas_lights” in the “states” section under developer tools. I used this name and added it to my config file under my “switches:” group to have it show up on my UI.

1 Like

Hey there,
Mine does show HA IP as a connection, but still…no entity shown in the Entity List…

Any light as to what may be causing it?

Thank you!