4CH Pro R2 will not trigger from Homeassistant

Any idea what I am doing wrong guys.

Thanks

for the command topic, try setting the power part to capitalised

Thank you for the reply, I have tried that too.
What confuse me is that all other Basic sonoffs work perfectly, but this 4ch just will not do anything when i move the switch.

on the console on the sonoff, does it have any information as to what topics have been used

could you also not enable discovery on the sonoff and then HA will populate automatically?

enter SetOption19 1 in the console to enable it

The console reports exactly the topic i used in mqtt on the sonoff portal, I have tried SetOption 19 but HA never discovered it. I also do prefer to do it manual config to have more control.
Also i removed mqtt fully and re configured it just to see if i missed anything.
Also I have re flashed the 4CH Pro
I can see in mqtt log that my 4CH Ip address makes a connection

If discovery does not work did you remember to add the discovery option in your HA config?
The bottom two lines.

mqtt:
  broker: !secret host
  port: 1883
  keepalive: 60
  username: !secret mqtt_name
  password: !secret mqtt_pass
  discovery: true
  discovery_prefix: homeassistant

For my non discovery devices this is how mine are set Like @aidbish mention I have POWER1 command part in capitals. I also have the availability_topic set, but I dont know if that is relevant to your issue or not.

  - platform: mqtt
    name: "LivingRoomWallUnit"
    state_topic: "stat/PrStrLivingRoom/POWER1"
    command_topic: "cmnd/PrStrLivingRoom/POWER1"
    availability_topic: "tele/PrStrLivingRoom/LWT"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    payload_available: "Online"
    payload_not_available: "Offline"
    retain: false

  - platform: mqtt
    name: "LivingRoomUSB"
    state_topic: "stat/PrStrLivingRoom/POWER5"
    command_topic: "cmnd/PrStrLivingRoom/POWER5"
    availability_topic: "tele/PrStrLivingRoom/LWT"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    payload_available: "Online"
    payload_not_available: "Offline"
    retain: false
    icon: mdi:usb

Thank you guys, I will start testing and I will get back with results!

Semi Succses !!
I followed your instructions to add the discovery and sure enough, it got discovered by HA as a switch and a button (BTN).
Now the challenge of adding it manual, I have no clue where the discovered items get stored, to at least read how HA reads it.

Any info will help, thanks again guys.

They go into .storage/core.device_registry

But I am changing mine back to non discovered as I can name them better

I would also like to change this switch to non discovered, so if you find the way, please share :slight_smile:
And thanks again for location.

SetOption19 0 in the console on the Sonoff

Ok i give up…i did the setting in sonoff console to remove auto detect, and tried to set it up manually again. I get Unavailable in the switch card.
I think it uses another topic name than the mqtt that i have imputed in sonoff console.
wills106 if you get it working on manual, please share :slight_smile:

Thanks all and for now it will be on auto discover…

Normally you would only config POWER1 to POWER4, but I am using a custom setup with a 5th relay.

configuration.yaml

mqtt:
  broker: !secret host
  port: 1883
  keepalive: 60
  username: !secret mqtt_name
  password: !secret mqtt_pass

#I have part of it setup under the light component
light:

  - platform: mqtt
    name: "LivingRoomWallUnit"
    state_topic: "stat/PrStrLivingRoom/POWER1"
    command_topic: "cmnd/PrStrLivingRoom/POWER1"
    availability_topic: "tele/PrStrLivingRoom/LWT"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    payload_available: "Online"
    payload_not_available: "Offline"
    retain: false

#Other parts are just switches
switch:

  - platform: mqtt
    name: "BobTheSwitch"
    state_topic: "stat/PrStrLivingRoom/POWER4"
    command_topic: "cmnd/PrStrLivingRoom/POWER4"
    availability_topic: "tele/PrStrLivingRoom/LWT"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    payload_available: "Online"
    payload_not_available: "Offline"
    retain: false

  - platform: mqtt
    name: "LivingRoomUSB"
    state_topic: "stat/PrStrLivingRoom/POWER5"
    command_topic: "cmnd/PrStrLivingRoom/POWER5"
    availability_topic: "tele/PrStrLivingRoom/LWT"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    payload_available: "Online"
    payload_not_available: "Offline"
    retain: false
    icon: mdi:usb

automations.yaml

#Check Power Status on startup for Sonoff Devices
- alias: "Power state on HA start-up"
  trigger:
    platform: homeassistant
    event: start
  action:
    - service: mqtt.publish
      data:
        topic: "cmnd/sonoffs/power1"
        payload: ""
    - service: mqtt.publish
      data:
        topic: "cmnd/sonoffs/power2"
        payload: ""
    - service: mqtt.publish
      data:
        topic: "cmnd/sonoffs/Power3"
        payload: "" 
    - service: mqtt.publish
      data:
        topic: "cmnd/sonoffs/power4"
        payload: ""
    - service: mqtt.publish
      data:
        topic: "cmnd/sonoffs/power5"
        payload: ""

The setup on my Sonoff it’s self.

Sadly didnt work for me, here is my code for the first switch only

  - platform: mqtt
    name: "Switch1"
    state_topic: "stat/Sonoff4CH/POWER1"
    command_topic: "cmnd/Sonoff4CH/POWER1"
    availability_topic: "tele/Sonoff4CH/LWT"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    payload_available: "Online"
    payload_not_available: "Offline"
    retain: false

You have your Full Topic back to front it should be %prefix%/%topic%/

hmm how did that happen, let me fix and get back !

@wills106 Your a star! Thank you so much, finally its working as it should!! :grinning::grinning::grinning:

woooohoooo!

Glad you got it sorted.

Have you been trying out different firmware’s on that device? As 2 of my wall switches had the same problem where the Full Topic got reversed for some reason. The only thing that I think could have caused it on mine was swapping about on different firmware’s.

Sorry for late reply, reached Max replies for new user :man_facepalming: ,14 hour wait

No I only used Tasmota on it, but maybe I should reset arduino ide file and start fresh next time. I did play around a bit and added a bunch of variables to make things easier.
I will keep an eye on Topics from now on, I totally missed that it was reversed!

Thanks again