Sonoff B1 Tasmota Configuration

It’s been a bit of a challenge to sort out how to configure my Sonoff B1 to use the MQTT Light component. Using some of the other threads in this forum(this one and this one), as well as the commands documentation, I’ve managed to get things working.

However, I’m running into the bounds of my knowledge. I’ve never implemented effects before, and tasmota incorporates effects from 0 through 4. I’d like to have these effects show up in the UI with descriptive names, but I can’t see any way to define that in the effects list, while still having the MQTT send the number correlated to the effect I want. How can specify human-friendly names to each of these effects?

I’m also not able to figure out how to enable the speed control, as the effects use the speed to determine how fast/slow to zip through the different colours. How can I set up the interface to have a speed input?

Thanks!

Hi,

This is not a solution for your problem… but according to the links you mentioned, I have tried to configure a sonoff b1 with tasmota and it gave me a lot of errors… And i don’t understand why and how to stop from appear at error log… That doesn’t happen to you?

Thank you

Are you getting errors in home assistant, or in tasmota? Can you share the error message?

Hi,
The errors i’m receiving is on Hass, in tasmota everything is ok, i noticed the problem was related to the stat-topic-result that was send from tasmota, sometimes send the payload with more than one field with comma as separate and sometimes (for power p.e.) it only send info like ‘on’ or ‘off’.
The thing is the stat topic for brightness and for rgb, if I comment those lines the errors stop occurring.
I’m not sure if this an “error” from hass or something that should be fixed from tasmota.
Now I’m out of home and not able to get error log and configuration file.

Thank you for your help.

Here’s an example entry in my lights.yaml file. This is what I’m using for the B1. I’ve used yaml parameters to help keep things tidy. Still haven’t managed to get color temperature to parse properly and render in the UI, but this is at the very least, functional.

  - platform: mqtt
    name: "Sonoff B1 A"
    command_topic: "cmnd/sonoff/b1_a/POWER"
    state_topic: "stat/sonoff/b1_a/POWER"
    brightness_command_topic: "cmnd/sonoff/b1_a/DIMMER"
    brigtness_state_topic: "stat/sonoff/b1_a/DIMMER"
    color_temp_command_topic: "cmnd/sonoff/b1_a/CT"
    color_temp_state_topic: "stat/sonoff/b1_a/CT"
    rgb_command_topic: "cmnd/sonoff/b1_a/COLOR"
    rgb_state_topic: "stat/sonoff/b1_a/COLOR"
    effect_command_topic: "cmnd/sonoff/b1_a/SCHEME"
    effect_state_topic: "stat/sonoff/b1_a/SCHEME"
    <<: &SONOFF_B1_PARAMS
      rgb_command_template: "{{ '#%02x%02x%02x0000'| format(red, green, blue) }}"
      rgb_value_template: "{{ '#%02x%02x%02x0000'| format(red, green, blue) }}"
      color_temp_value_template: "{{ value_json.CT }}"
      brightness_scale: 100
      on_command_type: "first"
      effect_list:
        - 0
        - 1
        - 2
        - 3
        - 4
      payload_on: "ON"
      payload_off: "OFF"
      payload_available: "Online"
      payload_not_available: "Offline"
      retain: false
      optimistic: false
      qos: 0

  - platform: mqtt
    name: "Sonoff B1 B"
    command_topic: "cmnd/sonoff/b1_b/POWER"
    state_topic: "stat/sonoff/b1_b/POWER"
    brightness_command_topic: "cmnd/sonoff/b1_b/DIMMER"
    brigtness_state_topic: "stat/sonoff/b1_b/DIMMER"
    color_temp_command_topic: "cmnd/sonoff/b1_b/CT"
    color_temp_state_topic: "stat/sonoff/b1_b/CT"
    rgb_command_topic: "cmnd/sonoff/b1_b/COLOR"
    rgb_state_topic: "stat/sonoff/b1_b/COLOR"
    <<: *SONOFF_B1_PARAMS
3 Likes

Here’s what I came up with for the Sonoff B1 that I just received. Tasmota does not appear to support any other effects than 0-4 on the B1.

- platform: mqtt
  name: "Test B1"

  command_topic: "cmnd/sonoff-xxxxxx/POWER"
  state_topic: "stat/sonoff-xxxxxx/POWER"
  payload_on: "ON"
  payload_off: "OFF"

  brightness_command_topic: "cmnd/sonoff-xxxxxx/DIMMER"
  brightness_scale: 100
  brightness_state_topic: "stat/sonoff-xxxxxx/RESULT"
  brightness_value_template: "{{ value_json.Dimmer }}"

  rgb_command_topic: "cmnd/sonoff-xxxxxx/COLOR"
  rgb_command_template: "{{ '%02x%02x%02x0000' | format(red, green, blue) }}"
  rgb_state_topic: "stat/sonoff-xxxxxx/RESULT"
  rgb_value_template: "{{ value_json.Color[0:2]|int(base=16) }},{{ value_json.Color[2:4]|int(base=16) }},{{ value_json.Color[4:6]|int(base=16) }}"

  color_temp_command_topic: "cmnd/sonoff-xxxxxx/CT"
  color_temp_state_topic: "cmnd/sonoff-xxxxxx/RESULT"
  color_temp_value_template: "{{ value_json.CT }}"

  effect_command_topic: "cmnd/sonoff-xxxxxx/SCHEME"
  effect_state_topic: "stat/sonoff-xxxxxx/RESULT"
  effect_value_template: "{{ value_json.Scheme }}"
  effect_list:
    - 0
    - 1
    - 2
    - 3
    - 4

  availability_topic: "tele/sonoff-xxxxxx/LWT"
  payload_available: "Online"
  payload_not_available: "Offline"

Does the UI detect the color temperature properly? That is, if you set the color temperature, then close the browser tab and re open it, and open the light again, does it show the current level? Mine always defaults to cold.

OK, I think that this does it. The problem with previous versions is the fact that Sonoff-Tasmota reuses the “stat/xxxxxx/RESULT” topic but doesn’t always supply all of the information that HA is looking for. So the fix is to check to see if the information is there, otherwise fill in with the current state. It’d be nice too if HA could make use of the “tele/xxxxxx/STATE” messages that Sonoff-Tasmota sends out periodically to refresh the state but that’ll take some coding.

- platform: mqtt
  name: "Test B1"

  command_topic: "cmnd/sonoff-xxxxxx/POWER"
  state_topic: "stat/sonoff-xxxxxx/POWER"
  payload_on: "ON"
  payload_off: "OFF"

  brightness_command_topic: "cmnd/sonoff-xxxxxx/DIMMER"
  brightness_scale: 100
  brightness_state_topic: "stat/sonoff-xxxxxx/RESULT"
  brightness_value_template: "{% if value_json.Dimmer is defined %}{{ value_json.Dimmer }}{% else %}{{ states.light.test_b1.attributes.brightness / 255 * 100 }}{% endif %}"

  rgb_command_topic: "cmnd/sonoff-xxxxxx/COLOR"
  rgb_command_template: "{{ '%02X%02X%02X0000' | format(red, green, blue) }}"
  rgb_state_topic: "stat/sonoff-xxxxxx/RESULT"
  rgb_value_template: "{% if value_json.Color is defined %}{{ value_json.Color[0:2]|int(base=16) }},{{ value_json.Color[2:4]|int(base=16) }},{{ value_json.Color[4:6]|int(base=16) }}{% else %}{{ states.light.test_b1.attributes.rgb_color|join(',') }}{% endif %}"

  color_temp_command_topic: "cmnd/sonoff-xxxxxx/CT"
  color_temp_state_topic: "stat/sonoff-xxxxxx/RESULT"
  color_temp_value_template: "{% if value_json.CT is defined %}{{ value_json.CT }}{% else %}{{ states.light.test_b1.attributes.color_temp }}{% endif %}"

  effect_command_topic: "cmnd/sonoff-xxxxxx/SCHEME"
  effect_state_topic: "stat/sonoff-xxxxxx/RESULT"
  effect_value_template: "{% if value_json.Scheme is defined %}{{ value_json.Scheme }}{% else %}{{ states.light.test_b1.attributes.effect }}{% endif %}"
  effect_list:
    - 0
    - 1
    - 2
    - 3
    - 4

  availability_topic: "tele/sonoff-995a08/LWT"
  payload_available: "Online"
  payload_not_available: "Offline"
3 Likes

Coloring works here too! Thanks so much.

FYI, esphomelib/esphomeyaml works with the B1 now. I personally like esphomelib/esphomeyaml better than Tasmota but it’s mainly a matter of preference.

This is an excellent configuration! Just for those who may be looking this works with a “Tasmotized” Novostella Smart LED floodlamp.

Now - I’m off to figure out how to send a “warm white” command for automation. This is awesome work. Thanks!

Old post. Did did you ever figure out the warm white to the novostella? Can you share?

Yes, in terms of my automation. I just entered the following in the service data section of the “call service” part of the automation:

color_temp: 800

That command activates the novastella warm white leds.

The lovelace entries have a color temp slider. So should your entries. If yours does not, here is my configuration.yaml code for adding the floodlights:

light:
 - platform: mqtt
   name: "Floodlight One"
   command_topic: "cmnd/FloodOne/POWER"
   state_topic: "stat/FloodOne/POWER"
   payload_on: "ON"
   payload_off: "OFF"
   brightness_command_topic: "cmnd/FloodOne/DIMMER"
   brightness_scale: 100
   brightness_state_topic: "stat/FloodOne/RESULT"
   brightness_value_template: "{% if value_json.Dimmer is defined %}{{ value_json.Dimmer }}{% else %}{{ states.light.test_b1.attributes.brightness / 255 * 100 }}{% endif %}"
   rgb_command_topic: "cmnd/FloodOne/COLOR"
   rgb_command_template: "{{ '%02X%02X%02X0000' | format(red, green, blue) }}"
   rgb_state_topic: "stat/FloodOne/RESULT"
   rgb_value_template: "{% if value_json.Color is defined %}{{ value_json.Color[0:2]|int(base=16) }},{{ value_json.Color[2:4]|int(base=16) }},{{ value_json.Color[4:6]|int(base=16) }}{% else %}{{ states.light.test_b1.attributes.rgb_color|join(',') }}{% endif %}" 
   color_temp_command_topic: "cmnd/FloodOne/CT"
   color_temp_state_topic: "stat/FloodOne/RESULT"
   color_temp_value_template: "{% if value_json.CT is defined %}{{ value_json.CT }}{% else %}{{ states.light.test_b1.attributes.color_temp }}{% endif %}"
   effect_command_topic: "cmnd/FloodOne/SCHEME"
   effect_state_topic: "stat/FloodOne/RESULT"
   effect_value_template: "{% if value_json.Scheme is defined %}{{ value_json.Scheme }}{% else %}{{ states.light.test_b1.attributes.effect }}{% endif %}"
   effect_list:
     - 0
     - 1
     - 2
     - 3
     - 4
   availability_topic: "tele/FloodOne/LWT"
   payload_available: "Online"
   payload_not_available: "Offline"

I hope this helps.