Hassio Config for Sonoff Switch with Tasmota Firmware

I tried using Hassio but could not manage configuring my Sonoff switch with Tasmota firmware, i did lots of search but could not find a single topic which could give step by step instructions, hence i switched openhab even though i faced similar problems over there but members helped me out and managed to get it working.

I am not looking to again try and use Hassio and hence if some can help me with it i would be greatful

The server would be installed on raspberry pi

Check out BRUH Automation youtube video. This is how I set up my sonoffs and HA and they are working great.

1 Like

Maybe this will help.

If not maybe @drzz can help.

1 Like

As you’ve obviously already flashed it you just need the first part of this post I made setting up exactly that…

Hi!

Need help in adding sonoff tasmota switch to automations i am adding the following code

- action:
  • data:
    entity_id: switch.master_light
    service: switch.turn_on
    alias: Auto Lights On
    condition:
  • condition: state
    entity_id: switch.master_light
    state: ‘off’
    id: ‘1514221724123’
    trigger:
  • event: sunset
    offset: -00:30:00
    platform: sun

The above does not work can anyone help me with the right code

Not sure if you know this, but yaml is VERY picky on its spacing so if your yaml looks like what you posted, it surely wont work.

actually the coding is proper as automations were created using the UI i have just copied and pasted hence it does not appear proper i can get my led lights to switch on and off but not sonoff switches

Well, then the only thing i could think of is that you have not enabled sun: in your configuration.yaml file.
If that is not present, the sun event wont be enabled

actually i have sun enabled and i have another even which is supposed to switch off the light at a certain time that also does not work for some reason

Well, something must not be right somewhere.
What you have posted here seems legit though.
i would need to see more of your configuration to see what is up. But if your light switch is called “switch.master_light” and the switch works outside of the automations, i have no idea tbh :frowning:

Really i don’t think it actually is an issue, but why bother the condition btw? If the light is on when the automation kicks in, nothing happens anyway. It would just ask HA to turn on the lights, which is already on. No harm done.
Can’t see that is would actually conflict, but seems unnecessary :wink:

  • platform: mqtt
    name: “Master Light”
    command_topic: “cmnd/Masterlight/power”
    state_topic: “stat/Masterlight/POWER”
    qos: 1
    payload_on: “ON”
    payload_off: “OFF”
    retain: true

This is my code for the switch may be this will help you

identical to mine, nothing to spot there. Can you switch the light on and of without automating? If it really is only the automation that is not working, i’m all out of ideas i’m afraid. I would someone sees more than i do, so we can fix your issue, but it really looks right from my angle.

yes i can control the lights using the switch the only issue is with the automation

Hey, Samiraa, you may want to look into using the editor to format your YAML files so that others can help you. You’ll generally get a better response.

Instead of just cutting and pasting into the Reply or Comment box, use the following line at the start of your code: \`\`\`yaml (except take out the backslashes, just three back-ticks at the start of a line, the word yaml if it’s YAML code (python, etc).

You end the code section by just putting three back-ticks in a line by itself.

Good luck! Did you ever solve your problem, by the way, because this is something that I’m going to be doing, too.

targets:
  #-----------------------------------------------------------------------------
  # Apache 2.4
  - ami: ami-26d5af4c
    name: ubuntu15.10
    type: ubuntu
    virt: hvm
    user: ubuntu
  - ami: ami-d92e6bb3
    name: ubuntu15.04LTS
    type: ubuntu
    virt: hvm
    user: ubuntu
  - ami: ami-7b89cc11
    name: ubuntu14.04LTS
    type: ubuntu
    virt: hvm
    user: ubuntu
  - ami: ami-9295d0f8
    name: ubuntu14.04LTS_32bit
    type: ubuntu
    virt: pv
    user: ubuntu
  - ami: ami-116d857a
    name: debian8.1
    type: debian
    virt: hvm
    user: admin
    userdata: |
      #cloud-init
      runcmd:
        - [ apt-get, install, -y, curl ]
  #-----------------------------------------------------------------------------

hi
have you introduced MQTT broker to the hassio yet?
use the following on your config.yaml

(if you are using mosquitto)
mqtt:
broker: core-mosquitto
#username: USER NAME
#password: PASSWORD

Hi
I’m trying to configure the sonoff switch but the switch doesn’t work.
I use Home Assistant 0.64.3, one run on synology DS415+, docker, homeassistant/home-assistant:0.64.3
Can you help me?
This is my config.
Thx!

Problem solved. The bug was here:
the wrong code

state_topic: “cmnd/sonoff1/power”
command_topic: “stat/sonoff1/POWER”

The correct code:

state_topic: “stat/sonoff1/POWER”
command_topic: “cmnd/sonoff1/POWER”

Could you share some of those automations please?

Switch code:

> - platform: mqtt
>   name: "Mirror light"
>   state_topic: "stat/sonoff3/POWER"
>   command_topic: "cmnd/sonoff3/POWER"
>   qos: 1
>   payload_on: "ON"
>   payload_off: "OFF"
>   retain: true

Automation code:

   >  - action:
>   - data:
>       entity_id: switch.mirror_light
>     service: homeassistant.turn_on
>   alias: Mirror light turn on
>   condition:
>   - after: sunset
>     condition: sun
>   - before: '22:00:00'
>     condition: time
>   id: '1530388077833'
>   trigger:
>   - entity_id: binary_sensor.motion_sensor_158d000200df58
>     from: 'off'
>     platform: state
>     to: 'on'
> - action:
>   - data:
>       entity_id: switch.mirror_light
>     service: homeassistant.turn_off
>   alias: Mirorr light turn off
>   condition:
>   - after: sunset
>     condition: sun
>   id: '1530388194163'
>   trigger:
>   - entity_id: binary_sensor.motion_sensor_158d000200df58
>     from: 'on'
>     platform: state
>     to: 'off'