Faulty config for controlling a bulb with MQTT

I am trying to control a Shelly Bulb from an automation and have a help question about that.

The action part of the automation consists of the following steps:
• Lamp on
• Wait 2
• Lamp off
• Wait 2
• Set lamp to green
• Lamp on
• Wait 2
• Lamp off

It goes wrong at “set lamp to green”.
The action seems to stop there, probably because my config is wrong.
If I use the config at “Developer Tool (MQTT tab)” it works fine.

Annotation 2020-04-21 155848

In the HA log I find the following entry
Logfile
2020-04-21 15:38:09 ERROR (MainThread) [homeassistant.components.automation] Voordeur dicht: Error executing script. Invalid data for call_service at pos 5: extra keys not allowed @ data[‘blue’]

It’s probably a trifle, but I can’t find it…
So please help me sorting this out.

My config (automations.yaml) is as follows:

  • id: voordeur_dicht
    alias: Voordeur dicht
    description: Als voordeur dicht gaat gaat bulb in achterkamer uit
    trigger:
    • entity_id: sensor.sensative_strips_access_control
      from: ‘22’
      platform: state
      to: ‘23’
      condition: []
      action:
    • data:
      payload: ‘on’
      topic: shellies/shellybulb-7914D8/color/0/command
      service: mqtt.publish
    • timeout: ‘2’
      wait_template: ‘’
    • data:
      payload: ‘off’
      topic: shellies/shellybulb-7914D8/color/0/command
      service: mqtt.publish
    • timeout: ‘2’
      wait_template: ‘’
    • data:
      blue: 10
      brightness: 100
      effect: 0
      gain: 80
      green: 151
      mode: color
      red: 15
      temp: 3175
      white: 0
      service: mqtt.publish
    • data:
      payload: ‘on’
      topic: shellies/shellybulb-7914D8/color/0/command
      service: mqtt.publish
    • timeout: ‘2’
      wait_template: ‘’
    • data:
      payload: ‘off’
      topic: shellies/shellybulb-7914D8/color/0/command
      service: mqtt.publish

Ko, I told you in another topic already, if you post code, to put it between the 2x three backticks created by clicking </>

3 errors :
1/ no topic defined
2/ no json for data
3/ forgot payload

  - data:
      payload: '{"blue": 10, "brightness": 100, "effect": 0, "gain": 80, "green": 151, "mode": color, "red": 15, "temp": 3175, "white": 0}'
      topic: ???
    service: mqtt.publish

Oh, another error :

  - delay: 00:02:00

and not

timeout: ‘2’
wait_template: ‘’

Hi Francis,

thanks for your patience with me and your quick response.

Regarding the posting of code I did not understand you last time: thought that a snippet was not okay, but that I should include the code as text. I have put my modified code between the backticks, hope that is is ok now.

  - delay: 00:02:00
  - data:
      payload: '{"blue": 10, "brightness": 100, "effect": 0, "gain": 80, "green": 151, "mode": color, "red": 15, "temp": 3175, "white": 0}'
      topic: shellies/shellybulb-7914D8/color/0/set
    service: mqtt.publish

With your directions, I got it working fast.

That I forgot the topic is just stupid.

I think the style of configuration is the essential point here. In the previous thread about this, a colleague pointed out the difference between the style for “device automation” and the “traditional style”. Is that indeed where things went wrong here?

Thanks again, nice that it works now.

Device automation is relative new, and not so well documented. I think it is only meant to be used in the automation editor.

Ok, thanks again. I will try again (with the knowledge I have now) if I can also get it working from the automation editor with the classic style.