#Automation based on custom event.

1 messages · Page 1 of 1 (latest)

hard idol
#

I've generated a couple custom MQTT events, and when I view the device, I see events for them, but I'm unable to fire an automation off of them.

The event configuration in configuration.yaml:

mqtt:
  - event:
     device:
       manufacturer: Govee
       model: H7172
       via_device: gv2mqtt
       identifiers:
         - gv2mqtt-9A52DEADBEEFCAFE
         - "9A:52:DE:AD:BE:EF:CA:FE"
       name: Smart Ice Maker
     unique_id: gv2mqtt-9A52DEADBEEFCAFE-icefull
     icon: "mdi:bucket"
     name: "Ice Maker Full"
     state_topic: "GA/61f8693d-388e-4ef5-94ee-972a54f25f69"
     event_types:
       - "ice maker full"
     value_template: |
       {
       {% if value_json.get("device") and value_json["device"] == "9A:52:DE:AD:BE:EF:CA:FE" %}
       {% for capability in value_json["capabilities"] %}
       {% if capability.get("type") and capability["type"] == "devices.capabilities.event"
          and capability.get("instance") and capability["instance"] == "iceFull" %}
       {% if capability.get("state") %}
       {% for state in capability["state"] %}
       {% if state.get("name") and state["name"] == "iceFull" %}
       "event_type": "{{ state["message"] }}"
       {% endif %}
       {% endfor %}
       {% endif %}
       {% endif %}
       {% endfor %}
       {% endif %}
       }
  - event:
     device:
       manufacturer: Govee
       model: H7172
       via_device: gv2mqtt
       identifiers:
         - gv2mqtt-9A52DEADBEEFCAFE
         - "9A:52:DE:AD:BE:EF:CA:FE"
       name: Smart Ice Maker
     unique_id: gv2mqtt-9A52DEADBEEFCAFE-lackwaterevent
     icon: "mdi:water-alert-outline"
     name: "Lack of Water"
     state_topic: "GA/61f8693d-388e-4ef5-94ee-972a54f25f69"
     event_types:
       - "Lack of Water"
     value_template: |
       {
       {% if value_json.get("device") and value_json["device"] == "9A:52:DE:AD:BE:EF:CA:FE" %}
       {% for capability in value_json["capabilities"] %}
       {% if capability.get("type") and capability["type"] == "devices.capabilities.event"
          and capability.get("instance") and capability["instance"] == "lackWaterEvent" %}
       {% if capability.get("state") %}
       {% for state in capability["state"] %}
       {% if state.get("name") and state["name"] == "lack" %}
       "event_type": "{{ state["message"] }}"
       {% endif %}
       {% endfor %}
       {% endif %}
       {% endif %}
       {% endfor %}
       {% endif %}
       }

Here's the automation definition:

alias: Ice Maker Out of Water
description: ""
triggers:
  - trigger: event
    event_type: Lack of Water
conditions: []
actions:
  - action: notify.notify
    metadata: {}
    data:
      message: Ice Maker Out of Water
      title: Ice Maker Out of Water
mode: single
subtle sentinel
#

Hi @hard idol,
Look in developer Tools Events to see that the event is exactly called. It will be in the list.
Having spaces in the name is unnecessary and may not work.
Try lower_case_chase style instead...
<a href="https://my.home-assistant.io/redirect/developer_events/" target="_blank" rel="noreferrer noopener"><img src="https://my.home-assistant.io/badges/developer_events.svg" alt="Open your Home Assistant instance and show your event developer tools." /></a>

My Home Assistant

Show your event developer tools in Home Assistant.

#

See, those names are all lower_case_chase format.

agile tinsel
#

That screenshot looks like event entities. If mqtt is creating event entities, then you'll want to use the state trigger for those, not the event trigger.