Automation with two mqtt.publish, only one automation is triggered

Hi All,

First time working with HASSIO and integration of nodemcu via MQTT.
i was able to configuration of light with on/off state and a input_number with automation to publish a payload when slider value is changes.

Then i added a input_select with a list of effects and set up another automation. This time only one of the automation is triggered. i can either get the input_number automation or the input-select automation to work but not both. The configuration seems sound but i am obviously missing something.

Below is the configuration:

light:
platform: mqtt
name: Hall LED
unique_id: hallBackLed
command_topic: “dsel/livingRoomLed/set”

input_select:
led_effects:
name: LED Effects
options:
- “ripple”
- “sinelon”
- “solid”
- “twinkle”
initial: “solid”
icon: mdi:spotlight-beam

input_number:
hall_brightness:
name: Brightness
initial: 30
min: 0
max: 100
step: 1
icon: mdi:brightness-6

automation:
alias: LED automation
hide_entity: true
initial_state: true
trigger:
platform: state
entity_id: input_select.led_effects
action:
service: mqtt.publish
data_template:
topic: “dsel/livingRoomLed/effects/set”
payload: “{{ states(‘input_select.led_effects’) }}”

automation:
alias: Hall - Adjust Brightness
hide_entity: true
initial_state: true
trigger:
platform: state
entity_id: input_number.hall_brightness
action:
service: mqtt.publish
data_template:
topic: “dsel/livingRoomLed/brightness/set”
payload: “{{ states(‘input_number.hall_brightness’)}}”

Any help is appreciated.

Thanks,
Dinesh

It might be the double quotes but it’s hard to tell without seeing the code formatted properly.

Please do this and somebody might be able to provide some help:
HomeAss_CodeMarking_From%40finity

1 Like

here it is. Thanks

light:
platform: mqtt
name: Hall LED
unique_id: hallBackLed
command_topic: “dsel/livingRoomLed/set”

input_number:
    hall_brightness:
        name: Brightness
        initial: 30
        min: 0
        max: 100
        step: 1
        icon: mdi:brightness-6

input_select:
    led_effects:
        name: LED Effects
        options: 
            - "ripple"
            - "sinelon" 
            - "solid"
            - "twinkle"
        initial: "solid"
        icon: mdi:spotlight-beam

automation:
    id: "34661"
    alias: LED Effects
    hide_entity: false
    initial_state: true
    trigger:
        platform: state
        entity_id: input_select.led_effects
    action:
        service: mqtt.publish
        data_template:
            topic: "dsel/livingRoomLed/effect/set"
            payload: "{{ states('input_select.led_effects') }}"
            
    id: "34662"
    alias: Hall - Adjust Brightness
    hide_entity: false
    initial_state: true
    trigger:
        platform: state
        entity_id: input_number.hall_brightness
    action:
        service: mqtt.publish
        data_template:
            topic: "dsel/livingRoomLed/brightness/set"
            payload: "{{ states('input_number.hall_brightness')}}"

Not sure about the light component, but given that all your other indentations are ‘off’, I’d start there; you have 4 instead of 2 spaces from layer to layer .

And I think the issue in your automations might have to do with the fact that you’d need to do something like this:

automation:
  - id: "34661"
    alias: LED Effects

            
  - id: "34662"
    alias: Hall - Adjust Brightness

wow thats worked out. I dint realize the spacing mattered.
Thanks for the quick reply. Cheers.

That’s going to be an issue that will follow you - and annoy the hell out of you - for quite some time to come.
From my experience and what I have read here, spacing issues are the single most frequent reason why your config causes error messages :wink: