Support Fire Angel Zigbee Module (P-LINE)#7941
Conversation
|
Hey @ebaauw, thanks for your pull request! Tip Modified bundles can be downloaded here. DDB changesModified
ValidationTip Everything is fine ! 🕠 Updated for commit 1fba9f0 |
Handle cases where voltage is beyond range 1.9V ... 3.0V.
| zclVal.clusterId = 0x0500; // IAS Zone cluster | ||
| zclVal.attrId = 0x0001; // IAS Zone Type | ||
| zclVal.data = 0; | ||
|
|
||
| if (DB_LoadZclValue(&zclVal) && zclVal.data != 0) | ||
| { | ||
| ResourceItem *item = device->item(RAttrZoneType); | ||
| if (item && item->toNumber() != zclVal.data) | ||
| { | ||
| item->setValue(zclVal.data, ResourceItem::SourceDevice); | ||
| item->clearNeedPush(); | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
This works but you may consider just using the normal item based value storage which doesn't require extra code.
The reason I used this in the OTA version is to have the value in the database also for non DDF devices, so at the time they get a DDF the value is already available. Not sure if we need that here too.
There was a problem hiding this comment.
After some testing, I think we do need the RAttrZoneType ResourceItem on the Device, but there's no need to save its value explicitly to ZCL_VALUES. Still no need to have the item on the lights or sensors resource.
| addItem(DataTypeString, RAttrDdfPolicy); | ||
| addItem(DataTypeString, RAttrDdfHash); | ||
| addItem(DataTypeUInt32, RAttrOtaVersion); | ||
| addItem(DataTypeUInt16, RAttrZoneType); |
There was a problem hiding this comment.
Just noticed this one, I'm not too happy about adding RAttrZoneType in this place and to every device.
I think it's okay to get the PR up and running, but ideally we can mark items in sub-resources to be cascaded to the parent (aka Device*) in future.
There was a problem hiding this comment.
I think there's a bit of a catch 22 there? We only have the subdevices once the DDF has been matched, but we need the zone type to match the DDF. We might do a check that it gets added only to devices with the IAS Zone cluster?
There was a problem hiding this comment.
That's a good idea, the following should do the trick in device.cpp and gets executed right before the DDF is matched but also after the Simple Descriptors have been read.
void DEV_GetDeviceDescriptionHandler(Device *device, const Event &event)
{
DevicePrivate *d = device->d;
if (event.what() == REventStateEnter)
{
// if there is a IAS Zone Cluster add the RAttrZoneType
if (DEV_GetSimpleDescriptorForServerCluster(device, 0x0500_clid))
{
device->addItem(DataTypeUInt16, RAttrZoneType);
}
DEV_EnqueueEvent(device, REventDDFInitRequest);
}
...
There was a problem hiding this comment.
Unfortunately, this doesn't work. I think the value of RAttrZoneType is not persisted across restarts. After re-adding the logic to persist zone type in ZCL_VALUES, it still doesn't work, as the attempted restore happens before the state enter event, which adds the item. When adding the item on restore, it works!
but there's no need to save its value explicitly to
ZCL_VALUES
I can no longer reproduce this. Maybe it worked, because at that time the resource item was still defined on the subdevices, or simply because the value was still in ZCL_VALUES. Or maybe I simply screwed up and tested against the wrong build. When manually removing the value from the database, the sensors resource reverts to ZHAAlarm.
Need to persist the zone type value in ZCL_Values after all.
Only create RAttrZoneType on devices with IAS_Zone cluster
Re-create RAttrZoneType when restoring its value from the database.
|
Tested in my setup with a breakpoint in debugger, adding the zone type item works. |
|
This pull request is now merged. The new DDB files have been uploaded to the store. DDB FilesModified
🕤 Updated for commit ae412b4 |
This PR does two things:
matchexpr, cf. the work done in Expose OTA file version for matchexpr #7642 for OTA File Version;Ad 1) I changed the following:
RAttrZoneTypefor/attr/zonetype, based on 0x0500/0x0001;Write the value of 0x0500/0x0001 to thezcl_valuestable in the database;RAttrZoneTypetoDevice;Read the value of 0x0500/0x0001 into theDeviceRAttrZoneTypeon device DDF initialisation;RAtttrZoneTypeonlightsandsensorsAPI endpoints. Not sure if we want or need this. It was already included insensorsweb socket notifications out of the box. Note that this attribute doesn't need to be defined on any of the subdevices for thematchexprto work, since the C++ code already added it to theDevice.Note that I didn't add a hook to reload the DDF when 0x0500/0x0001 is read (and changes value), due to the recent issues with the API ignoring messages from devices after DDFs are re-initialised.
Ad 2) I added DDFs for:
matchexprfor Zone Type having value Fire sensor;matchexprfor Zone Type having value Carbon Monoxide (CO) sensor;matchexprfor other Zone Type values.Note the Zigbee module can also be installed in heat alarms, but I don't know what Zone Type these use. Could very well be Fire sensor.
On initial pairing, you should get a ZHAAlarm
sensorsresource; after reading IAS Zone and restarting deCONZ, this changes to a ZHAFire or ZHACarbonMonoxide.{ "config": { "battery": 91, "on": true, "pending": [], "reachable": true }, "ep": 1, "etag": "d790c79357ddb6e33be69053fb9ca957", "lastannounced": null, "lastseen": "2024-09-25T09:17Z", "manufacturername": "Fireangel", "modelid": "Alarm_SD_Device", "name": "Smoke Alarm", "state": { "fire": false, "lastupdated": "2024-09-25T09:17:22.956", "lowbattery": false, "tampered": false, "test": false }, "swversion": "3.1.8.14", "type": "ZHAFire", "uniqueid": "00:15:5f:00:dc:c8:ea:77-01-0500" }The only differences between the different devices are the
type(ZHAAlarm, ZHAFire, ZHACarbonMonoxide) and thestateattribute for an alarm (alarm,fire,carbonmonoxide).I'm polling the alarm every 5 minutes for the Zone State, as the module doesn't support Supervision Reports nor attribute reporting for this attribute. This should keep
state/lastupdatedfairly current, but I need to assess the impact on battey usage.state/tamperedis set shortly after the smoke alarm is removed from it's base plate. It takes a couple of seconds before the Zone Status Change Notification is sent. [Note to self: check if CO alarm also supports this].state/testbriefly switches totruewhen pressing the device button, activating a self-test (cover your ears!).The Zigbee module only reports voltage if its (user replaceable) battery. This should be reported every 12 hours out of the box.
config/batteryextrapolates the voltage linearly from documented range of 1.9V ... 3.0V to 0% ... 100%. Note that there's no indication for the internal, non-replaceable battery of the sensor.swversionreports the firmware version of the Zigbee module, based on the File Version of the OTAU cluster.Additionally, there's a Warning Device
lightsresource.{ "capabilities": { "alerts": [ "none", "select", "lselect" ] }, "etag": "4d11a9ea58d1d06dffb73e74c989685f", "hascolor": false, "lastannounced": null, "lastseen": "2024-09-25T09:17Z", "manufacturername": "Fireangel", "modelid": "Alarm_SD_Device", "name": "Smoke Alarm", "state": { "alert": "none", "reachable": true }, "swversion": "3.1.8.14", "type": "Warning device", "uniqueid": "00:15:5f:00:dc:c8:ea:77-01" }state/alertcan be used to activate the siren (cover your ears!). Note the module only supports Sqawk, so you only get a short alarm.