Zigbee Neo Siren AB02B2-v2 trying to switch melody

It is now 2023 and I have the same problem as in this post. Was this ever resolved.
I update the cluster attributes to change the melody and get a green tick. But the melody on the device does not change.
Is there something else I need to do??

Hi jerrm,

I’d like to know if your neo siren can be connected via Sonoff dongle or third-party hub?

I’ve used it with the Sonoff ZBDongle-P under both ZHA and z2m.

I would expect it should work with other coordinators supported by those platforms.

There is a switch but no way to change the actual alarm…just a switch

The attributes were never exposed as entities in ZHA, at least not 1+ years ago when I had it under ZHA.

You had to manage with zha service calls, see script above.

yeah,I setup zigbee2mqtt. That seems to expose the rest of the entities. Thanks

I just followed the istruction you left.
Thank you very much, was very very halpfull.
As a novice on the HA world, in the first moments I was lost on what or how to do with your script.
May I try to integrate with this steps for other novice like me:

  1. Go under Settings (left down corner) -->Automations & scenes–> Tap Scripts → add script (right top corner) → create a new script → edit in YAML (top right corner)
  2. Paste as is the code shared and save (the one who starts with “alias: Tuya Siren ZHA” )
  3. Go under Developer Tools → services
  4. Type “Script: Tuya Siren ZHA” and click to “go to YAML mode”
  5. Paste the code of second screenshot (value of variables just for example)

data:
  ieee_id:  (you can find it under ZHA coordinator, select your device and in the left corner "Zigbee info")
  melody: 1
  duration: 60
  volume: 1
  alarm: "on"
  1. Use the following page as reference for what type of melody you want to set:
    Neo Siren with Temperature & Humidity Sensor NAS-AB02B2 Zigbee compatibility (unter the section “Table of Tunes”)
    Quick recap of the page:
    Melody: 0-18
    Volume: 0-low, to 2-high
    Duration: Duration in seconds

  2. After modified as needed, press “Call service”

6 Likes

This was very helpful. Thank you.

For anyone else who was stuck wondering how to change the settings for different use cases without going into the services section, see the following:

  1. First follow the steps recommended by everyone from before this post.

  2. Then, play around with the services section that Brubba wrote about to figure out what tunes and other settings you’d like to use.

  3. Create a new automation with whatever triggers you’d like to set it off (OPTIONAL but highly recommended to reduce the number of automations you need and cluttering HA - use trigger IDs so that one automation controls all siren setting changes).

  4. Prepare presets under a ‘choose’ action that will be used for whatever you specify based off this (but make sure you use YOUR correct IEEE ID from the ZHA info section).

  5. Now, you’ll have different chimes for different trigger IDs. In my case, the doorbell being rung will play a ringing sound, and my perimeter alarm will use the siren sound effect at maximum volume.

Thanks to everyone in this thread for the tips and initial scripts!

I was having an issue where @jerrm 's script would work but only on every other service call. I wasn’t able to figure out why this was the cause BUT I was able to fix it by modifying the script to normally toggle the siren if the melody hadn’t changed since the last call.
I also took the liberty of improving the UI experience and adding more defaults to the script to make usage easier.

Based on jerrm’s script and @Brubba 's setup steps from above here is the Idiot’s Guide to the ZHA Neo Siren:

STEP 1: Gather Setup Info and Variables

  • Create an Input Text to save last used melody
    • Settings → Services & Services → Helpers → Create Helper → Text
      • Name: neo_alarm_melody
    • Create
  • Get required device values
    • Settings → Devices → Zigbee Home Automation → Devices → find the siren device and open device details page
      • Device Info → Zigbee info → IEEE
        • Example: a4:c1:38:a0:19:76:33:8b
      • Controls → Switch
        • Click on Switch to open its details → Gear icon → Look for Entity ID
          • Example switch.neo_siren_switch

You now have three pieces of information needed to set up the script:

  • Input Text helper Entity ID you created EX neo_alarm_melody
  • IEEE ID of the ZHA siren device EX a4:c1:38:a0:19:76:33:8b
  • Siren Switch Entity ID (used to toggle siren) EX neo_siren_switch

STEP 2: Setup Script

  • Go to Settings → Automations & scenes → Scripts → Add Script → Create new script
  • In the New Script page click “…” in the top right corner → Edit in YAML
    • Delete the existing contents (or replace it) with the code below:
# based on https://community.home-assistant.io/t/zigbee-neo-siren-ab02b2-v2-trying-to-switch-melody/425552/8
#
# This script includes these improvements:
# 
# * Add full UI fields with descriptions and predefined values
# * Add default variables to make service call usage easier
# * Improve performance by only calling ZHA device write actions when currently set melody is different than parameter melody
#    * Done by using input_text to store last set melody type
#
# SETUP: See instructions at bottom of the script
#
alias: Tuya Siren ZHA
sequence:
  - if:
      - condition: not
        conditions:
          - condition: template
            value_template: >-
              {{ is_state('input_text.' + (melody_entity_id |
              default(default_melody_id)), (melody | default(default_melody)))
              }}
    then:
      - service: input_text.set_value
        target:
          entity_id: input_text.{{(melody_entity_id | default(default_melody_id))}}
        data:
          value: "{{ melody }}"
      - service: zha.set_zigbee_cluster_attribute
        data:
          ieee: "{{ ieee_id | default(default_ieed) }}"
          endpoint_id: 1
          cluster_id: 6
          cluster_type: in
          attribute: 1126
          value: "{{ melody | default(default_melody) }}"
      - service: zha.set_zigbee_cluster_attribute
        data:
          ieee: "{{ ieee_id | default(default_ieed) }}"
          endpoint_id: 1
          cluster_id: 6
          cluster_type: in
          attribute: 615
          value: "{{ duration | default(default_duration) }}"
      - service: zha.set_zigbee_cluster_attribute
        data:
          ieee: "{{ ieee_id | default(default_ieed) }}"
          endpoint_id: 1
          cluster_id: 6
          cluster_type: in
          attribute: 1140
          value: "{{ volume | default(default_volume) }}"
      - service: zha.set_zigbee_cluster_attribute
        data:
          ieee: "{{ ieee_id | default(default_ieed) }}"
          endpoint_id: 1
          cluster_id: 6
          cluster_type: in
          attribute: 0
          value: "{{ alarm | default(1) }}"
  - service: switch.turn_on
    target:
      entity_id: switch.{{ (siren_entity_id | default(default_siren_id)) }}
    data: {}
description: Tuya Siren ZHA
fields:
  ieee_id:
    default: a4:c1:38:a0:19:76:33:8b
    description: IEEE value found under 'Zigbee Info' on the siren 'Device Info' page in HA
    example: a4:c1:38:00:12:34:56:78
    selector:
      text: null
  melody:
    default: "0"
    description: "Melody that will be played based on ID from https://zigbee.blakadder.com/Neo_NAS-AB02B2.html"
    example: 1-18
    selector:
      select:
        mode: dropdown
        # https://zigbee.blakadder.com/Neo_NAS-AB02B2.html
        options:
          - label: Doorbell Chime
            value: "0"
          - label: Fur Elise
            value: "1"
          - label: Westminster Chimes
            value: "2"
          - label: Fast double door bell
            value: "3"
          - label: William Tell Overture
            value: "4"
          - label: Turkish March
            value: "5"
          - label: Safe/Security Alarm
            value: "6"
          - label: Chemical Spill Alert
            value: "7"
          - label: Piercing Alarm Clock
            value: "8"
          - label: Smoke Alarm
            value: "9"
          - label: Dog Barking
            value: "10"
          - label: Police Siren
            value: "11"
          - label: Doorbell Chime (reverb)
            value: "12"
          - label: Mechanical Telephone
            value: "13"
          - label: Fire/Ambulance
            value: "14"
          - label: 3/1 Elevator
            value: "15"
          - label: Buzzing Alarm Clock
            value: "16"
          - label: School Bell
            value: "17"
  duration:
    default: 4
    description: Duration melody will be played for
    selector:
      number:
        min: 0
        max: 100
        mode: box
        unit_of_measurement: "seconds"
  volume:
    default: "1"
    description: Volume of the melody
    selector:
      select:
        options:
          - label: Low
            value: "0"
          - label: Medium
            value: "1"
          - label: High
            value: "2"
  alarm:
    default: "on"
    description: When writing alarm settings, should alarm be on? Leave as default
    example: on or off
    selector:
      select:
        options:
          - label: "Off"
            value: "off"
          - label: "On"
            value: "on"
    
  neo_siren_switch:
    default: neo_siren_switch
    selector:
      entity: {}
    name: siren_entity_id
    description: The switch entity for the siren
  neo_melody_text:
    default: neo_alarm_melody
    description: The text_input helper entity that stores the current melody type
    selector:
      entity: {}
    name: melody_entity_id
variables:
# THESE ARE THE DEFAULTS ACTUALLY USED when using this script through a service call and fields are not set
# the defaults in the fields above ^^ are only used when enabling a field through the UI
#
# Ideally, should set the field defaults above and the variable defaults below to the same value
#
#
  # IEEE value found under 'Zigbee Info' on the siren 'Device Info' page in HA
  default_ieed: a4:c1:38:a0:19:76:33:8b
  # melody ID found at https://zigbee.blakadder.com/Neo_NAS-AB02B2.html
  default_melody: 0
  default_duration: 4
  default_volume: 1
  # CREATE AN INPUT HELPER (input_text) and use its entity id here
  default_melody_id: neo_alarm_melody
  # The entity id of the siren's switch
  default_siren_id: neo_siren_switch
mode: parallel

Now replace the following sections with the data you gathered in STEP 1:

  • fields → ieee_id → default → IEED ID
  • fields → neo_siren_switch → default → Siren Siwtch Entity ID
  • fields → neo_melody_text → default → Input Text helper Entity ID
  • variables → default_ieed → IEED ID
  • variables → default_melody_id → Input Text helper Entity ID
  • variables → default_siren_id → Siren Siwtch Entity ID

Then Save Script

STEP 3: Using the script

Congratulations, you can now use the script! Compared to the original script and other examples in this thread you do not need to specify any parameters when calling the script now. However you may stay specify everything/anything if you want.

Using in the UI (in an automation or via service call) you will now have pre-filled fields

Using in YAML mode is the same but you only need to specify melody, volume, and duration (optimally).

7 Likes

@FoxxMD this worked a treat! Thank you (and to @jerrm and @Brubba).

This whole thread has been very helpful and educational.
I find in one of my orders I received both AB02B0 as well as AB02B2 models (I think someone just grabbing boxes off a shelf) and the B0 doesn’t seem to respond the same way. Anyone know of a thread providing similar directions for that version? It does not respond at all to the B2 methods

@FoxxMD

Many thanks for pulling the notes together, tweaking the script and providing the detailed guide on this.

Following your script implementation for ZHA, I’ve set up the helper text input and kept the name,“neo_alarm_melody”

I configured the script as you documented with my siren’s IEEE and switch entity as instructed. However, I’m encountering some inconsistencies:

In the Developer Tools, adjusting script variables to change the melodie, it typically fails on the first attempt if it’s a change from the previous melody. Here’s the error:

“Failed to call service script.1707788213189. Failed to set attribute: value: 1 attribute: 1140 cluster_id: 61184 endpoint_id: 1”

The script runs without error on the second try as it uses the melody value from the text input helper and is not trying to change the cluster value.

About 20% of the time, changing the melody to a new melody in Developer tools works on the first run.

It’s the same behavior within an automation making a service call to the script, it rarely successfully changes the melody on the first attempt, usually taking 7-10 seconds before a popup error:

“Failed to set attribute: value: 1 attribute: 1140 cluster_id: 61184 endpoint_id: 1”

After this delay, if I manually run the script again, it works-- as expected based on the same behavior in the Developer Tools.

I’ve added a 10-second wait event in my automation to counter this, but it feels clunky and further slows down the intent of the automation-- to notify me based on a trigger.

I’ve made no modifications to your original script, just adapted it to my siren’s IEEE ID and the correct entity names for the text input helper and the siren switch as shown in the device settings.

Is this your experience too?

Many thanks again.

Clarification-- after my wait event, the automation re-runs the script. So, two service calls to the script separated by a wait event as the first one will fail with the error, but it does update the cluster and change the melody. The second execution simply plays the melody as the script knows not to perform the zha.set_zigbee_cluster_attribute, it just toggles the siren switch.

I managed to get the changes to take place more reliably when I just put in a loop to repeat them, so they each get 40 attempts. No extra time delays. This is in MQTT not ZHA. But is still isn’t 100% - in fact I can’t even get the device to reliably make any sound when switched on by an automation. I put in a loop of 40 tries to make sure it did. It usually does sound but not always. I’ve made a barebones automation to gather data.

The automatic config looks like this

alias: Test bell reduced
> description: ''
> trigger: []
> condition: []
> action:
>   - repeat:
>       count: 40
>       sequence:
>         - type: turn_on
>           device_id: d8c939486d1d8527887d804022281d7b
>           entity_id: 2ffe11a53a56dd0825c47c4b665bf012
>           domain: switch
> mode: single

When it doesn’t work the trace timeline shows “Turn on unknown entity” 21 times, every line is the same.

On one of the lines when it works it says (switch.office_noisemaker_alarm) turned on. The rest say Turn on unknown entity.

It seems that if you run it fairly quickly after a fail it does not fail but if it’s left a bit it is more likely to fail - but that isn’t really a particularly scientific observation.

I was hoping to use this as a mutli purpose device, including as a doorbell, so I don’t want to include to many pauses!

I have the traces downloaded but can’t see how to attach them here.

If anyone has any idea how to take this forward I’d appreciate it.

As an update, it always works from the UI, along with changing volume, melody and duration.

That seems to by my experience as well with ZHA. I still think these little sirens are a good deal if used with a single melody-- I bought a few more. There doesn’t seem to be a lot of simple zigbee chimes that work with ZHA and I’m reluctant to switch to z2m, as I like staying as HA native as possible since I’m a noob.

@jerrm and @FoxxMD THANKS for sharing these scripts🙏

I noticed that that the switch entity seems to hang sometimes. That is it stays on after the siren has played a sound. When that occurs the next command to play will fail.

For my siren I have solved the issue by not using HA service (now called actions) calls at all. I only use ZHA commands, not only for setting the melody etc, but also for playing the sounds.

Furthermore I send an OFF command before and after the ON command. Additionally I also wait 150ms after each ZHA command.

sequence:
  - # turn off (just in case ZHA device hangs in on state)
    service: zha.issue_zigbee_cluster_command
    data:
      ieee: "your-mac-address-here"
      endpoint_id: 1
      cluster_id: 6
      cluster_type: in
      command: 0x00
      command_type: server
      params: {}
  - delay: { milliseconds: 150 }

Next come the commands to set up the desired sound in a fashion as posted already.
And then finally the variation for playing the sound.

  - # turn on
    service: zha.issue_zigbee_cluster_command
    data:
      ieee: "your-mac-address-here"
      endpoint_id: 1
      cluster_id: 6
      cluster_type: in
      command: 0x01
      command_type: server
      params: {}
  - delay:
      seconds: "sound-duration-plus-one"
  - # turn off (switch entity of ZHA device sometimes hangs in state "on")
    service: zha.issue_zigbee_cluster_command
    data:
      ieee: "your-mac-address-here"
      endpoint_id: 1
      cluster_id: 6
      cluster_type: in
      command: 0x00
      command_type: server
      params: {}

Thank you for that great work und the good Description. It works fine!

Before I start, Thank you.
I’m extremely new to this and I’m just wondering, If I’m doing something wrong, The volume doesn’t seem to make any difference.

Edit
The volume does change, There was a delay