Aqara smoke detector linkage alarm

So i think I found my issue.

for me i must have been tired when i thought i saw smoke detected in HA. that was actually not the case.

in reality z2m and ha didn’t get the message from the smoke detector unless i hit refresh.

I read the z2m docs for the specific device and saw it required a minimum zigbee cordinator firmware which i was way behind on.

I updated and repaired the devices and finally it works in HA.

in the mean time I made my own version of your automation without link, just home assitant triggering the others.

I will test yours tonight.

I noticed The notification problem for ios when setting up my wifes phone.

actionName was replaced by action (or atleast the actionable notifications docs for HA still says actionName instead of action), and some parts of notifications seem to be no longer platform dependent if I understand correctly.

either way I help test this blue print with both android and ios devices

Sorry, but I am still new to the HA environment, how and where will the update be made available? Will it be here in the forum, through an update of your first post?

Yes, I updated it now (the code in the original post) for the notifications to work again.

I haven’t tested the notifications on iOS since I only have an android, but I expect it to work (somewhat) anyway. Feel free to give feedback to further improve.

The linkage in the settings of the smoke detectors is necessary, otherwise you cannot manually trigger the smoke alarm on a smoke detector.

Also, there might be a small delay when manually triggering a smoke detector (so when one goes off it might take a few seconds before another one is activated since they sleep most of the time to save battery)

Nevermind… probably haven’t got the latest version of the blueprint…

HA needs update functionality within blueprints…

1 Like

An amazing blueprint. Now that this sensor is also working in zha I wanted to use it. I had a look at the binary sensor namespaces and they look exactly the same as you set in the blueprint so I’m hopeful.

binary_sensor.*_smoke
binary_sensor.*_buzzer_manual_mute

are exactly the same for example. 2 questions I’d appreciate your support on:

  1. What is the buzzer

select.*_buzzer

?
There is a similar one in zha:
switch.*_buzzer_manual_alarm
is it the same?
2) If there are multiple sensors, the entity ids get a _2 at the end (with zha, but probably with zigbee2mqtt too), in this instance the blueprint wouldn’t catch it? For example:
binary_sensor.*_smoke_2

is it OK to change

binary_sensor.*_smoke

to

binary_sensor.*_smoke*?

I am mot sure if I understand all your questions correctly. In z2m, the buzzer is muted through a select option in the device (I could show you a screenshot). There is no separate command, that’s why I need all the select options to manually trigger/mute the detectors.

For z2m, there was no number added at the add of an entity, but the number was added in between. You could either rename your devices or change the blueprint as you suggested.

hmm, OK that’s helpful thanks so much. I made the following minor updates so far, I’ll test with a candle later on. Note that in ZHA even the model name is different so I updated that in the selector as well.

The part I’m definitely not sure about is where I replaced

select.*_buzzer

with

switch.*_buzzer_manual_alarm*

Others were more obvious but I haven’t tested yet.

blueprint:
  name: Link Aqara smoke detectors
  description:
    Aqara smoke detectors have the \"ability\" to alarm each other once one has detected fire. 
    Since this linkage as achieved through the aqara hub, Home Assistant now has to take care of that job. 
    Select the smoke detectors you want to link. Also mutes all the smoke detectors when one is muted.
  source_url: https://community.home-assistant.io/t/aqara-smoke-detector-linkage-alarm/517656
  domain: automation
  input:
    smoke_detectors:
      name: Smoke detectors
      description: The smoke detectors you want to link.
      selector:
        device:
          integration: zha
          manufacturer: LUMI
          model: lumi.sensor_smoke.acn03
          multiple: true
    notify_device:
      name: Devices to notify
      description: Device to be notified via the mobile app
      selector:
        device:
          integration: mobile_app
          multiple: true
    message_title:
      name: Message title
      description: Title of the notification.
      selector:
        text:
    message_button:
      name: Button label
      description: The label the action-button has to stop the alarm, e.g. Stop alarm.
      selector:
        text:
    message_string:
      name: Message
      description: Message content prefixing the area name where smoke was detected.
      selector:
        text:
variables:
  notify_devices: !input notify_device
  message: !input message_string
  button_label: !input message_button
  devices: !input smoke_detectors
  buzzers: >-
    {% set data = namespace(buzzer=[]) %}
    {% set temp = [] %}
    {% for device in devices %}
      {% set temp = device_entities(device) | select('match', 'switch.*_buzzer_manual_alarm*') | list | join  %}
      {%- set data.buzzer = data.buzzer + [temp] -%}
    {% endfor %}
    {{ data.buzzer }}
  v_smoke_sensors: >-
    {% set data = namespace(alarm_entity=[]) %}
    {% set temp = [] %}
    {% for device in devices %}
      {% set temp = device_entities(device) | select('match', 'binary_sensor.*_smoke*') | list | join  %}
      {%- set data.alarm_entity = data.alarm_entity + [temp] -%}
    {% endfor %}
    {{ data.alarm_entity }} 
  sensor_trigger_entity: >- 
      {% set data = namespace(alarm=false, trigger_id="0") %}
      {% for sensor in v_smoke_sensors %}
        {% if is_state(sensor, "on")  %}
          {% set data.trigger_id = sensor %}
          {% set data.alarm = true %}
        {% endif %}
      {% endfor %}
      {{ data.trigger_id }}
trigger_variables:
  button_label: !input message_string
  devices: !input smoke_detectors
  smoke_sensors: >-
    {% set data = namespace(alarm_entity=[]) %}
    {% set temp = [] %}
    {% for device in devices %}
      {% set temp = device_entities(device) | select('match', 'binary_sensor.*_smoke*') | list | join  %}
      {%- set data.alarm_entity = data.alarm_entity + [temp] -%}
    {% endfor %}
    {{ data.alarm_entity }} 
  mute_sensors: >-
    {% set data = namespace(muted=[]) %}
    {% set temp = [] %}
    {% for device in devices %}
      {% set temp = device_entities(device) | select('match', 'switch.*_buzzer_manual_mute*') | list | join  %}
      {%- set data.muted = data.muted + [temp] -%}
    {% endfor %}
    {{ data.muted }}
trigger:
  - platform: template
    value_template: >- 
      {% set data = namespace(alarm=false) %}
      {% for sensor in smoke_sensors %}
        {% if is_state(sensor, "on")  %}
          {% set data.alarm = true %}
        {% endif %}
      {% endfor %}
      {{ data.alarm  }}
    id: "alarm"
  - platform: template
    value_template: >- 
      {% set data = namespace(alarm_muted=false) %}
      {% for sensor in mute_sensors %}
        {% if is_state(sensor, "on")  %}
          {% set data.alarm_muted = true %}
        {% endif %}
      {% endfor %}
      {{ data.alarm_muted  }}
    id: "mute"
condition:
action:
  - choose:
    - conditions:
      - condition: template
        value_template: "{{trigger.id == 'alarm'}}"
      sequence:
      - service: select.select_option
        target:
           entity_id: "{{buzzers}}"
        data:
          option: "alarm"
      - parallel:
        - sequence:
          - alias: "Setup notification variables"
            variables:
              action_stop: "{{ 'STOP_' ~ context.id }}"
              
          - alias: "Repeat notify for each device"
            repeat:
              for_each: "{{notify_devices}}"
              sequence:    
                - service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}"
                  data:
                    title: "{{ title | default('') }}"
                    message: '{{message}} {{area_name(sensor_trigger_entity)}}!'
                    data:
                      tag: "fire"
                      sticky: true
                      persistent: true
                      actions:
                        - action: "{{ action_stop }}" # The key you are sending for the event
                          title: "{{ button_label }}" # The button title
          - wait_for_trigger:
            - platform: event
              event_type: mobile_app_notification_action
              event_data:
                action: "{{ action_stop }}"
          - service: select.select_option
            target:
              entity_id: "{{buzzers}}"
            data:
              option: "mute" 
        - sequence:   
          - wait_template: >-
              {% set data = namespace(alarm_finished=true) %}
              {% for sensor in v_smoke_sensors %}
                {% if is_state(sensor, "on")  %}
                  {% set data.alarm_finished = false %}
                {% endif %}
              {% endfor %}
              {{ data.alarm_finished }}
          - service: select.select_option
            target: 
              entity_id: "{{buzzers}}"
            data:
              option: "mute" 
    - conditions:
      - condition: template
        value_template: "{{trigger.id == 'mute'}}"
      sequence:
      - service: select.select_option
        target: 
          entity_id: "{{buzzers}}"
        data:
          option: "mute"
      - alias: "Repeat notify for each device"
        repeat:
          for_each: "{{notify_devices}}"
          sequence:
          - service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}"
            data:
              title: "{{ title | default('') }}"
              message: 'clear_notification'
              data:
                tag: "fire"
mode: restart
max_exceeded: silent

Well, if ZHA does not use the the select option, you have to change a lot more in the blueprint. E.g., instead of using

sequence:
      - service: select.select_option
        target:
           entity_id: "{{buzzers}}"
        data:
          option: "alarm"

you would need something like

sequence:
      - service: switch.turn_on
        target:
           entity_id: "{{buzzers}}"

And so on.

Edit: Maybe you could post a screenshot of the device in HA. This is a z2m connected device for example:

Thanks so much for your continuous help.

Screenshot is here:

Makes sense for the “select” to “switch” conversion. Alarm part is obvious, any recommendations for the mute part? Shall I also create a “muters” variable the same way as you created “buzzers” so variables part become something like below?

variables:
  notify_devices: !input notify_device
  message: !input message_string
  button_label: !input message_button
  devices: !input smoke_detectors
  buzzers: >-
    {% set data = namespace(buzzer=[]) %}
    {% set temp = [] %}
    {% for device in devices %}
      {% set temp = device_entities(device) | select('match', 'switch.*_buzzer_manual_alarm*') | list | join  %}
      {%- set data.buzzer = data.buzzer + [temp] -%}
    {% endfor %}
    {{ data.buzzer }}
  muters: >-
    {% set data = namespace(muter=[]) %}
    {% set temp = [] %}
    {% for device in devices %}
      {% set temp = device_entities(device) | select('match', 'switch.*_buzzer_manual_mute*') | list | join  %}
      {%- set data.muter = data.muter + [temp] -%}
    {% endfor %}
    {{ data.muter }}
...
1 Like

OK… worked today!

But how do I dismiss the notification I got on my phone? I can’t swipe it away… and the Smoke alarms are silent again (luckily)

Hi all, I was reading this thread with a lot of interest.
I don’t use HA, but a combination of Z2M and node-red.
But I hope somehow I can learn from what you do in this blueprint.
The buzzer part is working here. I have 6 smoke detectors that are linked
and if one detects smoke all 6 sound.

However, the muting eludes me… On the primary smoke detector
(the one that was triggered by the smoke) I can press mute and buzzer_manual_mute
is set to true. I can test for that in Node-red and mute all other buzzers.
But on the secondary smoke detectors (the ones that were started with buzzer=“alarm” ) ,
pressing the mute button doesn’t set buzzer_manual_mute to true.

So my main question is: How do you detect a mute-button-press-action on one of the secondary devices?
(It would have been so easy if the button press trigered a mqtt message with a clear event flag.)

Regards,

Bert

This is an interesting aproach, I will check if I can read “pressing Mute button” messages in MQTT.

My resolution, as there are several smoke detectors that are triggered, is one dedicated MUTE Button that is mainly the same as my alarm-automation but setting them all to mute.

This is what I get when pressing the Mute button

<small>2023-11-13 09:18:12</small>`MQTT publish: topic
 'zigbee2mqtt/Rauchmelder Gast', payload 
'{"battery":100,"buzzer_manual_alarm":false,"buzzer_manual_mute":false,"heartbeat_indicator":false,"linkage_alarm":true,"linkage_alarm_state":null,"linkquality":123,"power_outage_count":19,"smoke":false,"smoke_density":0,"smoke_density_dbm":0,"test":false,"update":{"installed_version":17,"latest_version":17,"state":"idle"},"update_available":false,"voltage":3015}'`

And now the complete flow:

info 2023-11-13 09:39:45MQTT publish: topic 'zigbee2mqtt/Wassermelder', payload '{"battery":100,"battery_low":false,"linkquality":163,"tamper":false,"water_leak":true}'
info 2023-11-13 09:40:17MQTT publish: topic 'zigbee2mqtt/Rauchmelder Gast', payload '{"battery":100,"buzzer_manual_alarm":true,"buzzer_manual_mute":false,"heartbeat_indicator":false,"linkage_alarm":true,"linkage_alarm_state":null,"linkquality":69,"power_outage_count":19,"smoke":false,"smoke_density":0,"smoke_density_dbm":0,"test":false,"update":{"installed_version":17,"latest_version":17,"state":"idle"},"update_available":false,"voltage":3015}'
info 2023-11-13 09:40:24MQTT publish: topic 'zigbee2mqtt/Wassermelder', payload '{"battery":100,"battery_low":false,"linkquality":160,"tamper":false,"water_leak":false}'
info 2023-11-13 09:40:33MQTT publish: topic 'zigbee2mqtt/Rauchmelder Gast', payload '{"battery":100,"buzzer_manual_alarm":true,"buzzer_manual_mute":false,"heartbeat_indicator":false,"linkage_alarm":true,"linkage_alarm_state":null,"linkquality":72,"power_outage_count":19,"smoke":false,"smoke_density":0,"smoke_density_dbm":0,"test":false,"update":{"installed_version":17,"latest_version":17,"state":"idle"},"update_available":false,"voltage":3015}'
info 2023-11-13 09:40:34MQTT publish: topic 'zigbee2mqtt/Rauchmelder Gast', payload '{"battery":100,"buzzer_manual_alarm":false,"buzzer_manual_mute":false,"heartbeat_indicator":false,"linkage_alarm":true,"linkage_alarm_state":null,"linkquality":76,"power_outage_count":19,"smoke":false,"smoke_density":0,"smoke_density_dbm":0,"test":false,"update":{"installed_version":17,"latest_version":17,"state":"idle"},"update_available":false,"voltage":3015}'

The 9:40:33 is the initial pressing of the Mute button at the smoke detector. One second later I get the confirmation that the manual alarm is switched off. To me it seems like pressing the Mute button only send the current status.

One proposal, but I am unsure if this proposal is good, bad or ugly - you could misuse the selftest function to mute all sirens:

info 2023-11-13 15:59:32MQTT publish: topic 'zigbee2mqtt/Rauchmelder Gast', payload '{"battery":100,"buzzer_manual_alarm":true,"buzzer_manual_mute":false,"heartbeat_indicator":false,"linkage_alarm":true,"linkage_alarm_state":null,"linkquality":47,"power_outage_count":19,"smoke":false,"smoke_density":0,"smoke_density_dbm":0,"test":false,"update":{"installed_version":17,"latest_version":17,"state":"idle"},"update_available":false,"voltage":3013}'
info 2023-11-13 15:59:32MQTT publish: topic 'zigbee2mqtt/Rauchmelder Gast', payload '{"battery":100,"buzzer_manual_alarm":false,"buzzer_manual_mute":false,"heartbeat_indicator":false,"linkage_alarm":true,"linkage_alarm_state":null,"linkquality":43,"power_outage_count":19,"smoke":false,"smoke_density":0,"smoke_density_dbm":0,"test":false,"update":{"installed_version":17,"latest_version":17,"state":"idle"},"update_available":false,"voltage":3013}'
info 2023-11-13 15:59:38MQTT publish: topic 'zigbee2mqtt/Rauchmelder Gast', payload '{"battery":100,"buzzer_manual_alarm":false,"buzzer_manual_mute":false,"heartbeat_indicator":false,"linkage_alarm":true,"linkage_alarm_state":null,"linkquality":58,"power_outage_count":19,"smoke":false,"smoke_density":0,"smoke_density_dbm":0,"test":true,"update":{"installed_version":17,"latest_version":17,"state":"idle"},"update_available":false,"voltage":3013}'
info 2023-11-13 15:59:42MQTT publish: topic 'zigbee2mqtt/Rauchmelder Gast', payload '{"battery":100,"buzzer_manual_alarm":false,"buzzer_manual_mute":false,"heartbeat_indicator":false,"linkage_alarm":true,"linkage_alarm_state":null,"linkquality":69,"power_outage_count":19,"smoke":false,"smoke_density":0,"smoke_density_dbm":0,"test":false,"update":{"installed_version":17,"latest_version":17,"state":"idle"},"update_available":false,"voltage":3013}'

First message is the alarm, second is after mute, third is the selftest and fourth is after the selftest.

Hi, Can someone give me some information about this aqara smoke detectors? I cannot find any reviews and can only buy it from aliexpress so I won’t be able to return it when it’s bad.

Does it work perfectly with HA?
Is the build quality good, can it easily detect smoke?
The linkage alarm works? thanks to this blueprint?
Is it possible to trigger the alarm to use it as home security as well?
Is the battery life good, how much do you need to replace the battery?
Is it possible to silence the detectors via HA?

any other comments?

Thank you

Does it work perfectly with HA? - Paired through Z2M definitely YES and it really exposes WAY more things than my cheapo sensors
Is the build quality good, can it easily detect smoke? - Hard to guess, I am definitely thinking about testing it with a smoke spray
The linkage alarm works? thanks to this blueprint? - No Blueprint needed. Just connect through Z2M, switch on linkage and done.
Is it possible to trigger the alarm to use it as home security as well? - Yes but you have to decide yourself if you want that. Generally you can use the siren for everything you want, e.g. my first automation was an alarm once my basement is flooded.
Is the battery life good, how much do you need to replace the battery? - I ordered it 10 months ago, switched it on and would need to check if there was ANY visible battery drain.
Is it possible to silence the detectors via HA? - Yes, I have built an automation for that if a dedicated button is pressed, all are silenced. Of course also through HA dashboard.

1 Like

thank you for your answers, I was gonna choose between aqara and bosch but i think aqara is much better integrated :slight_smile:

This is what is in the state.json, so I really like the integration:

 "date_code": "20220617",
            "definition": {
                "description": "Aqara smart smoke detector",
                "exposes": [
                    {
                        "access": 5,
                        "description": "Indicates whether the device detected smoke",
                        "label": "Smoke",
                        "name": "smoke",
                        "property": "smoke",
                        "type": "binary",
                        "value_off": false,
                        "value_on": true
                    },
                    {
                        "access": 5,
                        "description": "Value of smoke concentration",
                        "label": "Smoke density",
                        "name": "smoke_density",
                        "property": "smoke_density",
                        "type": "numeric"
                    },
                    {
                        "access": 5,
                        "description": "Value of smoke concentration in dB/m",
                        "label": "Smoke density dbm",
                        "name": "smoke_density_dbm",
                        "property": "smoke_density_dbm",
                        "type": "numeric",
                        "unit": "dB/m"
                    },
                    {
                        "access": 2,
                        "description": "Starts the self-test process (checking the indicator light and buzzer work properly)",
                        "label": "Selftest",
                        "name": "selftest",
                        "property": "selftest",
                        "type": "enum",
                        "values": [
                            "selftest"
                        ]
                    },
                    {
                        "access": 1,
                        "description": "Self-test in progress",
                        "label": "Test",
                        "name": "test",
                        "property": "test",
                        "type": "binary",
                        "value_off": false,
                        "value_on": true
                    },
                    {
                        "access": 2,
                        "description": "The buzzer can be muted and alarmed manually. During a smoke alarm, the buzzer can be manually muted for 80 seconds (\"mute\") and unmuted (\"alarm\"). The buzzer cannot be pre-muted, as this function only works during a smoke alarm. During the absence of a smoke alarm, the buzzer can be manually alarmed (\"alarm\") and disalarmed (\"mute\"), but for this \"linkage_alarm\" option must be enabled",
                        "label": "Buzzer",
                        "name": "buzzer",
                        "property": "buzzer",
                        "type": "enum",
                        "values": [
                            "mute",
                            "alarm"
                        ]
                    },
                    {
                        "access": 5,
                        "description": "Buzzer alarmed (manually)",
                        "label": "Buzzer manual alarm",
                        "name": "buzzer_manual_alarm",
                        "property": "buzzer_manual_alarm",
                        "type": "binary",
                        "value_off": false,
                        "value_on": true
                    },
                    {
                        "access": 5,
                        "description": "Buzzer muted (manually)",
                        "label": "Buzzer manual mute",
                        "name": "buzzer_manual_mute",
                        "property": "buzzer_manual_mute",
                        "type": "binary",
                        "value_off": false,
                        "value_on": true
                    },
                    {
                        "access": 7,
                        "description": "When this option is enabled then in the normal monitoring state, the green indicator light flashes every 60 seconds",
                        "label": "Heartbeat indicator",
                        "name": "heartbeat_indicator",
                        "property": "heartbeat_indicator",
                        "type": "binary",
                        "value_off": false,
                        "value_on": true
                    },
                    {
                        "access": 7,
                        "description": "When this option is enabled and a smoke alarm has occurred, then \"linkage_alarm_state\"=true, and when the smoke alarm has ended or the buzzer has been manually muted, then \"linkage_alarm_state\"=false",
                        "label": "Linkage alarm",
                        "name": "linkage_alarm",
                        "property": "linkage_alarm",
                        "type": "binary",
                        "value_off": false,
                        "value_on": true
                    },
                    {
                        "access": 1,
                        "description": "\"linkage_alarm\" is triggered",
                        "label": "Linkage alarm state",
                        "name": "linkage_alarm_state",
                        "property": "linkage_alarm_state",
                        "type": "binary",
                        "value_off": false,
                        "value_on": true
                    },
                    {
                        "access": 1,
                        "description": "Remaining battery in %, can take up to 24 hours before reported.",
                        "label": "Battery",
                        "name": "battery",
                        "property": "battery",
                        "type": "numeric",
                        "unit": "%",
                        "value_max": 100,
                        "value_min": 0
                    },
                    {
                        "access": 1,
                        "description": "Voltage of the battery in millivolts",
                        "label": "Voltage",
                        "name": "voltage",
                        "property": "voltage",
                        "type": "numeric",
                        "unit": "mV"
                    },
                    {
                        "access": 1,
                        "description": "Number of power outages",
                        "label": "Power outage count",
                        "name": "power_outage_count",
                        "property": "power_outage_count",
                        "type": "numeric"
                    },
                    {
                        "access": 1,
                        "description": "Link quality (signal strength)",
                        "label": "Linkquality",
                        "name": "linkquality",
                        "property": "linkquality",
                        "type": "numeric",
                        "unit": "lqi",
                        "value_max": 255,
                        "value_min": 0
                    }
                ],
                "model": "JY-GZ-01AQ",
                "options": [],
                "supports_ota": true,
                "vendor": "Xiaomi"
            },
            "description": "text",
            "disabled": false,
            "endpoints": {
                "1": {
                    "bindings": [],
                    "clusters": {
                        "input": [
                            "genBasic",
                            "ssIasZone",
                            "genIdentify",
                            "genPowerCfg"
                        ],
                        "output": [
                            "genOta"
                        ]
                    },
                    "configured_reportings": [],
                    "scenes": []
                }
            },
            "friendly_name": "Rauchmelder Gast",
            "ieee_address": "ieeexxx",
            "interview_completed": true,
            "interviewing": false,
            "manufacturer": "LUMI",
            "model_id": "lumi.sensor_smoke.acn03",
            "network_address": 7254,
            "power_source": "Battery",
            "software_build_id": "2019\u0000www.",
            "supported": true,
            "type": "EndDevice"
        },

And this is how it appears in HA without any action from my side. The only thing I did was started pairing to Z2M and giving it a nice name.


The battery still reports 100%

1 Like

thanks! I’ve ordered the smoke detectors on aliexpress thanks to black friday it was 25€ a piece :slight_smile: