Tasmota ws2812 effect_value_topic?

Hi everybody,

I have a WS2812 led strip hooked up to a nodeMCU running tasmota, which I have included in my home-assistant. My current configuration for it looks like this

- name: "Schlafzimmer LED"
  command_topic: "cmnd/tasmota-5909/POWER"
  brightness_command_topic: "cmnd/tasmota-5909/dimmer"
  rgb_command_topic: "cmnd/tasmota-5909/color"
  availability_topic: "tele/tasmota-5909/LWT"
  state_topic: "tele/tasmota-5909/STATE"
  state_value_template: "{{ value_json.POWER }}"
  brightness_state_topic: "tele/tasmota-5909/STATE"
  brightness_value_template: "{{ value_json.Dimmer }}"
  rgb_state_topic: "tele/tasmota-5909/STATE"
  rgb_value_template: "{{ value_json.Color }}"
  hs_state_topic: "tele/tasmota-5909/STATE"
  hs_value_template: "{{ value_json.HSBColor }}"
  effect_command_topic: "cmnd/tasmota-5909/scheme"
  #effect_value_template: >
  #  "{% if }
  #  "
     - "0"
     - "1"
     - "12"
  <<: &led_template
    platform: mqtt
    payload_on: "ON"
    payload_off: "OFF"
    payload_available: "Online"
    payload_not_available: "Offline"
    qos: 2
    retain: false

It works fine¹ so far. I can control colors and toggle it’s status. However, I cannot figure out how to create a readable list for the effects. Tasmota expects a payload sent to cmnd/<tasmota>/scheme from 0 to 12. This current solution I have works. If I click 12, I’ll get the “fire” pattern. These are some possible options

6 = candlelight pattern
7 = RGB pattern
8 = Christmas pattern
9 = Hannukah pattern
10 = Kwanzaa pattern
11 = rainbow pattern
12 = fire pattern

My goal is to have a list containing these strings, and if one of those strings matches, to submit the appropriate payload via mqtt (click “rainbow pattern”, submit payload 11).

I am not sure how to structure the template, though. I’ll need something like

{% if <what_goes_here_?> == "Hannukah pattern" %}
  return "9"
{%elif <what_goes_here_?> == "Christmas pattern" %}
  return "8"
{% endif %}

Correct? I just don’t know what variable I am supposed to for <what_goes_here_?>; also, I am a beginner when it comes to jina2 and home-assistant in general, but I assume it might be able to just use a dictionary instead of a whole bunch of if statements… is this correct? And if so, how can I implement it?

Since I don’t know the actual way to do this, let’s assume I declare these keys and values (json in this example)

{ "schemes": {
  "rainbow pattern": "11",
  "fire pattern": "12"}

and then an if statement that will see if any submitted value fits the dictionary, and if so, submits the value instead of the key…?

¹ this particular device started automatically turning on soon after being turned off on it’s own. This can happen within 10 seconds or a few minutes (haven’t figured out the exact period and whether or not it is always the same). I have retain set to false in home-assistant, but powerretain set to 1 in tasmota; however, when I turn this off in tasmota, home-assistant will not recognize the current state (let’s say I turn the device off in home-assistant; then it will actually turn off, but the switch will go right back to on).

Thanks in advance for your help :slight_smile:

Hi prankousky

I figured out how to resolve these mqtt problems. There is a major problem with documentation on MQTT and devices and the way the syntax is structured.

I struggled for hours to figure out how to resolve the issues and found a simple and elegant way.
Download MQTT fx, its a tool that you connect to your mqtt broker. Then scan the network while the mqtt devices are on. In Home Assistant go to the “configurations” option then go to “inegrations” then click on your MQTT broker. It will list all the devices auto discovered. Click the (i) sign on that device. You will be presented with a color wheel, option to switch the light on and off and also brightness. Open MQTTfx, click on the subscribe tab and look at the topics collector at the bottom. Click on start. Now while scanning click on the power button, color wheel, brightness options in Home Assistant and you will slowly pickup on the correct syntax for your MQTT device in the topic collector in MQTTfx.

Then just rectify your configuration with the correct topics and commands.

This should put you on the right track very quickly. Let me know if you need assistance.

1 Like

Thank you for your help @quintinsleeking

I have stopped using tasmota for LEDs altogether… but hopefully somebody else with the same problem will now know what to do :slight_smile:

WLED works much better. While it unfortunately cannot do additional things (for example, one could control both LEDs and sensors, switches, or whatever they’d want running tasmota), it has many more great effects and fantastic Home Assistant integration.

Seems you could help me now. Lol.

I switched over to WLED last night and it works great. I just have one question… How do you get the color wheel card for HA and wled on the lovelace interface?

Do you use mqtt or integrations? I had already set up mqtt, but then deleted those because when you add your WLED via integrations page, you get more options. I don’t actually use the color wheel card, just have an entity per WLED (in buttons-card). When I short-press them, they toggle, when long-pressing they will display the details (color wheel, brightness). This is automatically done by button-card, though (should work similar when using regular entities cards, I believe)

I would love to use the integration route. Not shure how to go about it. I can see the cards under integrations but cannoy figure out how to display on my lovelace home screen. Would really apreciate your assistance.

Should i add the entities wled… With a button card?

What happens when you create this card? That will work without any custom cards just with what Home Assistant has already installed…

type: entity-button
  action: toggle
  action: more-info
show_icon: true
show_name: true
entity: (((your_light_entity)))

I just created this very card with one of my WLED and when I click on the symbol, I get this

The actual custom:button-card I am using looks like this

  - type: "horizontal-stack"
    - type: "custom:button-card"
      entity: light.wz_vorne
      size: 20px
        action: more-info
    - type: "custom:button-card"
      entity: light.wz_mitte
      size: 20px
        action: more-info

Which results in this

and when holding each entity this

Is that what you need? If not, please explain, I am not a native speaker so perhaps I misunderstood what you are actually trying to achieve…?


I tried entity button and it works. I installed custom button card via HACS and it says its added to the lovalace.yaml. I have restareted 2000million times and i get the same error " No card type configured"

Do maybe know what else i can try?

Do you use yaml mode or do you create cards via lovelace GUI? I’d suggest not using yaml mode, or integrating gui-sandbox to try the card while in lovelace. You can make changes and see the result right away.

button card can be a bit tricky at first. I always have to use trial and error to get what I need as well.

Hi Prankousky

Im seriously fedup with the custom button cards. I figured out nearly my whole HACS setup reading wiki’s but this custom button card plugin does not work.

I even reloaded with just HACS and the custom button plugin loaded. Still no luck.