Sonoff T1 US/AU config

Hi,

I have been trying to setup my Sonoff Light Switch(2 channel) to Hassio.

I have been able to get it to turn on the light be immediately after i turn it on in hassio the button switches to off but the light stays on. I cannot get it to turn off via hassio only on.

my code is below.

# Enables the frontend
frontend:
mqtt:
  broker: core-mosquitto

  # Enables configuration UI
config:

panel_iframe:
  configurator:
    title: Configurator
    icon: mdi:wrench
    url: http://192.168.1.139:3218

switch:
    platform: mqtt
    name: "Sonoff Switch 01"
    command_topic: "cmnd/sonoff/power"
    state_topic: "stat/sonoff/POWER"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    state_on: "ON"
    state_off: "OFF"
    retain: true

If it helps this is my config, you will need to change IP address and username / password to what ever you are using.

configuration.yaml

mqtt:
  broker: 192.168.x.x
  port: 1883
  keepalive: 60
  username: user
  password: userpass

light:

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

If you have a light switched on before HA starts it wont know if it’s on or not so add the following to

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: ""

Hope it helps.

This happens because ha does not receive the state_topic: message with a payload matching payload_on: after the command has been sent.

Use a mqtt client to display the messages being sent. and match your
state_topic: and payload to that being sent. I tend to use mosquitto_sub for this see mqtt testing page but I have heard people using an app called mqtt.fx with some success.

Didn’t a recent firmware update make the topic power1 and power2???

Hi All,

Many thanks, with the help of everyone i have managed to get it to work.

Thanks guys you are very helpful and very quick!!!

Code below that is working.

light:
    platform: mqtt
    name: "MasterBedroom"
    state_topic: "stat/sonoff/POWER1"
    command_topic: "cmnd/sonoff/POWER1"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    payload_available: "Online"
    payload_not_available: "Offline"
    retain: false

sorry another question!

To add the second switch do I do it like below?

light:
    platform: mqtt
    name: "MasterBedroom"
    state_topic: "stat/sonoff/POWER1"
    command_topic: "cmnd/sonoff/POWER1"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    payload_available: "Online"
    payload_not_available: "Offline"
    retain: false

light2:    
    platform: mqtt
    name: "MasterBedroom  w2"
    state_topic: "stat/sonoff/POWER2"
    command_topic: "cmnd/sonoff/POWER2"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    payload_available: "Online"
    payload_not_available: "Offline"
    retain: false

Yeah as per next post… I was trying to edit. iPad is not cooperating!

Is it a double wall switch or two seperate ones? (Edit Miss read, you have said it’s a dual)

If it’s a double light switch then yes. Otherwise you need to change the sonoff part ie:

cmnd/sonoffLM/POWER1

cmnd/sonoffLS/POWER1

cmnd/sonoffBob/POWER1

The bit between cmnd and POWER is the device name.

This might help more

  - platform: mqtt
    name: "LivingroomMaster"
    state_topic: "stat/sonoffLM/POWER"
    command_topic: "cmnd/sonoffLM/POWER"
    availability_topic: "tele/sonoffLM/LWT"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    payload_available: "Online"
    payload_not_available: "Offline"

  - platform: mqtt
    name: "LivingroomSlave"
    state_topic: "stat/sonoffLS/POWER"
    command_topic: "cmnd/sonoffLS/POWER"
    availability_topic: "tele/sonoffLS/LWT"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    payload_available: "Online"
    payload_not_available: "Offline"

You will change the Topic on each sonoff

1 Like

Thanks guys… All working.

2 Likes

Thanks too.
any direction on how to set this up in Node Red?
Cheers

OK but this is WITH tasmota right?