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