Skip to content

Conversation

@ghoz
Copy link
Contributor

@ghoz ghoz commented Feb 18, 2025

The HS2WD-E siren does not report back its state.
As the siren command has a duration (and a max duration config) , it will stop at some point, but the triggering system as no way to know that.
Attempts to track current state by looking at the mode, duration (and strobe) when the command is sent.

This is not ready to merge.

2 open questions :

  • How to publish a state from a toZigbee convertSet context with a delay ? there is no easy publish available as in fromZigbee convert
  • Where to properly implement all this without duplicating tz.warning ? would adding a flag to meta be the right place to turn on this virtual state ?

clearTimeout(globalStore.getValue(entity, 'state_timer'));
globalStore.clearValue(entity, 'state_timer');
if (siren_on) {
const duration = Math.min(values.duration, 240);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

240 is a placeholder for the actual max duration for now

@ghoz ghoz marked this pull request as draft February 18, 2025 22:54
@ghoz ghoz changed the title WIP Attempt to track HS2WD-E siren status WIP Attempt to track HS2WD-E siren status. help needed Feb 19, 2025
@Koenkk
Copy link
Owner

Koenkk commented Feb 20, 2025

Where to properly implement all this without duplicating tz.warning ? would adding a flag to meta be the right place to turn on this virtual state ?

That's fine

How to publish a state from a toZigbee convertSet context with a delay ? there is no easy publish available as in fromZigbee convert

What is the use case for this? Do you want to publish siren OFF after a certain time?

@ghoz
Copy link
Contributor Author

ghoz commented Feb 20, 2025

What is the use case for this? Do you want to publish siren OFF after a certain time?

Yes, exactly . Not sure how other warning devices return their state, through ias Zone Status maybe, but this one doesn't return anything, which make it's use as an HA siren a bit tricky

I wanted to copy the idea of the occupancy sensors that don't reset their state, but as those timers are created from within fromZigbee convertSet they have access to publish, which is not available here...

@Koenkk
Copy link
Owner

Koenkk commented Feb 21, 2025

We have to add a publish to https://github.com/Koenkk/zigbee2mqtt/blob/1accb8b66b95b99658c50e4c0209edcb946a5fe2/lib/extension/publish.ts#L230 in that case. Would you mind making a PR for that?

ghoz added 6 commits March 14, 2025 21:01
The HS2WD-E does not report on its state.
Attempts to track current state by tracking  duration and siren mode/duraition
this is the last *read* value
when setting max_duration, it updates the state if Optimistic is on,
but the cluster attribute cache is still on the old one...
need to set the value, and force a refresh for it to be taken in account
@ghoz ghoz force-pushed the feat-heiman-siren-state branch from b2756c1 to 4265f6d Compare March 14, 2025 20:16
@ghoz
Copy link
Contributor Author

ghoz commented Mar 14, 2025

Beside the naming of the meta and the virtual state,
Only quirk left is that when setting the maxDuration, it does update the cached state, but not the cached zigbee attribute, so a manual read is needed for now after any chabge to the max duration which can be odd

@ghoz ghoz changed the title WIP Attempt to track HS2WD-E siren status. help needed Track HS2WD-E siren in a virtual state Mar 14, 2025
@ghoz ghoz marked this pull request as ready for review March 14, 2025 20:22

// Track and maintain a virtual state of the siren
// is on if duration set, and either strobe with dutycycle or alarm is set
const virtualState = meta.mapped.meta?.virtualState?.warning;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What holds us from not enabling this for every device?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I simply have no clue how other warning devices return their state ... as this siren doesn't support most of the options, it might not be the best example device to generalize

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it conforms against the ZCL spec so should be fine, let's try it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made available to all warning devices🤞
The siren_state will still needs to be exposed

/**
* Maintain a virtual state for devices that don't report it
*/
virtualState?: {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be removed now.

await endpoint.read("ssIasWd", ["maxDuration"]);
},
exposes: [
e.binary("siren_state", ea.STATE, "ON", "OFF").withDescription("Alarm state (Virtual)"),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be added to every device having tz.warning, maybe good to add it to exposes.ts

@github-actions
Copy link
Contributor

This pull request is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the stale label May 17, 2025
@github-actions github-actions bot closed this May 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants