YAML Help with PresenceLight

I’m setting up PresenceLight with Home Assistant for Teams status.
I’ve followed his guide, it errors out right away. I’ve tweaked the code to the below, but still receiving “Message malformed: Unable to determine action @ data[‘action’][0]” error.

alias: Teams presence - IKEA Light Bulb Living Room
trigger:
  - platform: webhook
    allowed_methods:
      - POST
    local_only: false
    webhook_id: "secret!"
action:
  - choose:
    - conditions:
        - condition: template
          value_template: "{{ trigger.json.presence_status == 'Busy' }}"
      sequence:
        - service: light.turn_on
          data:
            entity_id: light.hue_color_downlight_1
            color_name: red
    - conditions:
        - condition: template
          value_template: "{{ trigger.json.presence_status == 'Available' }}"
      sequence:
        - service: light.turn_on
          data:
            entity_id: light.hue_color_downlight_1
            color_name: green
    - conditions:
        - condition: template
          value_template: "{{ trigger.json.presence_status == 'Away' }}"
      sequence:
        - service: light.turn_on
          data:
            entity_id: light.hue_color_downlight_1
            color_name: yellow
    default:
      service: light.turn_on
      data:
        entity_id: light.hue_color_downlight_1
        color_name: white

mode: single

Thank you, fixed!

alias: Teams presence - IKEA Light Bulb Living Room
trigger:
  - platform: webhook
    allowed_methods:
      - POST
    local_only: false
    webhook_id: "secret!"
action:
  - variables:
      colors:
        Busy: red
        Available: green
        Away: yellow
  - service: light.turn_on
    target:
      entity_id: light.hue_color_downlight_1
    data:
      color_name: "{{ colors.get(trigger.json.presence_status, 'white') }}"
mode: single

I still receive the same error from your edited code above.
Message malformed: Unable to determine action @ data[‘action’][0]

If it helps, here is the original code. This original give an error on the “” condition.

alias: Teams presence - IKEA Light Bulb Living Room
description: >-
  Show the Microsoft Teams status via a color of the Light Bulb in the Living
  Room
trigger:
  - platform: webhook
    allowed_methods:
      - POST
    local_only: true
    webhook_id: "<enter secret webhook id here>"
condition: []
action:
  - choose:
      - conditions:
          - condition: template
            value_template: "{{ trigger.json.presence_status == 'Busy' }}"
        sequence:
          - service: light.turn_on
            metadata: {}
            data:
              color_name: red
            target:
              entity_id: light.ikea_bulb
      - conditions:
          - condition: template
            value_template: "{{ trigger.json.presence_status == 'Available' }}"
        sequence:
          - service: light.turn_on
            metadata: {}
            data:
              color_name: green
            target:
              entity_id: light.ikea_bulb
      - conditions:
          - condition: template
            value_template: "{{ trigger.json.presence_status == 'Away' }}"
        sequence:
          - service: light.turn_on
            metadata: {}
            data:
              color_name: yellow
            target:
              entity_id: light.ikea_bulb
      - conditions: null
        sequence:
          - service: light.turn_off
            metadata: {}
            target:
              entity_id: light.ikea_bulb
            data: {}
mode: single

When do you get the error message?

  1. When you attempt to save the automation in the Automation Editor.
  2. When the automation is triggered by a received Webhook.

If it’s #2 then post an example of the JSON message contained by the Webhook.

Unfortunately, it’s when trying to save.

I’m using Home Assistant version 2024.3.1 and don’t get any errors when saving the example I posted above.

What is the version number of your Home Assistant?

Odd indeed…

  • Core2024.3.3
  • Supervisor2024.03.1
  • Operating System12.1
  • Frontend20240307.0

It saves correctly now. I discovered the issue was my own stupidity.
I was not in YAML mode for the whole automation, only the action.

My next step since it’s saved, is to test the automation.

Thank you @123 , you were extremely helpful!

In that case, I suggest you try the example I posted. It achieves the same result with far less code.