tuya-local icon indicating copy to clipboard operation
tuya-local copied to clipboard

Possibility of Request for Orion Grid Connect Outdoor Siren?

Open jamiergrs opened this issue 3 years ago • 20 comments

I'm wondering if it is possible to get support for the Orion grid connect outdoor siren, specifically ability to change the alarm_state. If you connect this device through the official tuya integration you only get ability to change volume and alarm time. Adding through this integration gives a device not supported message.

Happy to provide any information / details as required

jamiergrs avatar Jul 17 '22 04:07 jamiergrs

It may be possible, but I will need more information about the device. Best is to send the local dps mapping which is output to the Home Assistant log as a warning message when you try to add it, and information from iot.tuya.com developer portal about the device attributes, specifically the info under Cloud / API_ Explorer / Device Control / the last "Get Device Specification Attribute" listed. Also, while you are in there, the product_id which you can get from General Devices Management / Get Device Information - but a lot of the information under there is private (local key, device id, owner id, latitude, longitude) so don't post it all.

make-all avatar Jul 17 '22 13:07 make-all

See below for the information:

Get Device Information

{ "result": { "active_time": 1657944076, "category": "sgbj", "category_name": "Siren", "create_time": 1657944076, "gateway_id": "", "icon": "smart/icon/ay1536534747810ekKBj/737088b8db34d661fed632b77a715cbd.png", "id": "bfea172b71cf9e6b45mybn", "ip": "#####", "lat": #####, "local_key": #####", "lon": #####, "model": "SWS08HA", "name": "Outdoor Siren", "online": true, "owner_id": "#####", "product_id": "im2eqqhj72suwwko", "product_name": "Outdoor siren", "sub": false, "time_zone": "+08:00", "update_time": 1657944095, "uuid": "2458413e365474c4" }, "success": true, "t": 1658132671286, "tid": "0c1ae1e3067311ed889e9287a6a8350d"

Device Specification Attribute

{ "result": { "category": "sgbj", "functions": [ { "code": "alarm_state", "desc": "{"range":["alarm_sound","alarm_light","alarm_sound_light","normal"]}", "name": "报警器状态", "type": "Enum", "values": "{"range":["alarm_sound","alarm_light","alarm_sound_light","normal"]}" }, { "code": "alarm_volume", "desc": "{"range":["low","middle","high","mute"]}", "name": "报警音量", "type": "Enum", "values": "{"range":["low","middle","high","mute"]}" }, { "code": "alarm_time", "desc": "{"unit":"min","min":1,"max":10,"scale":0,"step":1}", "name": "报警时长", "type": "Integer", "values": "{"unit":"min","min":1,"max":10,"scale":0,"step":1}" } ], "status": [ { "code": "alarm_state", "name": "报警器状态", "type": "Enum", "values": "{"range":["alarm_sound","alarm_light","alarm_sound_light","normal"]}" }, { "code": "alarm_volume", "name": "报警音量", "type": "Enum", "values": "{"range":["low","middle","high","mute"]}" }, { "code": "charge_state", "name": "充电状态", "type": "Boolean", "values": "{}" }, { "code": "alarm_time", "name": "报警时长", "type": "Integer", "values": "{"unit":"min","min":1,"max":10,"scale":0,"step":1}" }, { "code": "battery_percentage", "name": "电池电量百分比", "type": "Integer", "values": "{"unit":"%","min":0,"max":100,"scale":0,"step":1}" }, { "code": "temper_alarm", "name": "防拆报警", "type": "Boolean", "values": "{}" } ] }, "success": true, "t": 1658132842296, "tid": "72064a73067311ed889e9287a6a8350d" }

Log Information

Logger: custom_components.tuya_local.config_flow Source: custom_components/tuya_local/config_flow.py:73 Integration: Tuya Local (documentation, issues) First occurred: 4:28:36 PM (1 occurrences) Last logged: 4:28:36 PM

Device matches None with quality of 0%. DPS: {'1': 'normal', '5': 'middle', '6': True, '7': 10, '15': 0, '20': True, 'updated_at': 1658132915.8694942}

jamiergrs avatar Jul 18 '22 08:07 jamiergrs

Hi, that is not the correct Device Specificaton Atrribute, you need to use the last one listed under "Device Control", as that is the only function in the entire API that lists the dp_id field needed for local protocol use.

make-all avatar Jul 18 '22 23:07 make-all

Apologies, here is the correct one

{ "result": { "category": "sgbj", "functions": [ { "code": "alarm_state", "dp_id": 1, "type": "Enum", "values": "{"range":["alarm_sound","alarm_light","alarm_sound_light","normal"]}" }, { "code": "alarm_volume", "dp_id": 5, "type": "Enum", "values": "{"range":["low","middle","high","mute"]}" }, { "code": "alarm_time", "dp_id": 7, "type": "Integer", "values": "{"unit":"min","min":1,"max":10,"scale":0,"step":1}" } ], "status": [ { "code": "alarm_state", "dp_id": 1, "type": "Enum", "values": "{"range":["alarm_sound","alarm_light","alarm_sound_light","normal"]}" }, { "code": "alarm_volume", "dp_id": 5, "type": "Enum", "values": "{"range":["low","middle","high","mute"]}" }, { "code": "charge_state", "dp_id": 6, "type": "Boolean", "values": "{}" }, { "code": "alarm_time", "dp_id": 7, "type": "Integer", "values": "{"unit":"min","min":1,"max":10,"scale":0,"step":1}" }, { "code": "battery_percentage", "dp_id": 15, "type": "Integer", "values": "{"unit":"%","min":0,"max":100,"scale":0,"step":1}" }, { "code": "temper_alarm", "dp_id": 20, "type": "Boolean", "values": "{}" } ] }, "success": true, "t": 1658186784806, "tid": "0a45270506f111ed8219daf929f70cab" }

jamiergrs avatar Jul 18 '22 23:07 jamiergrs

It looks like HomeAssistant has support for a siren platform, which supports setting volume, tone and duration. So I guess that is where the limitation of the official cloud-based tuya integration support is coming from.

I don't currently have siren support, but it looks quite simple to add. As this integration supports multiple entities per device, adding the alarm state to this will be a matter of adding a select entity (also sensors for the battery, charge state and tamper alarm - or is the tamper alarm another setting in the Tuya app?)

make-all avatar Jul 19 '22 07:07 make-all

Actually it looks like the alarm state could be emulated as tones. Maybe that would be better as it keeps everything in the standard alarm entity, so might work better in the UI.

make-all avatar Jul 19 '22 07:07 make-all

I think keeping it all together in the alarm entity would work better in the UI.

As for the tamper alarm, that is simply a state in the app that is either true or false based on whether someone has opened the cover on the siren

jamiergrs avatar Jul 19 '22 07:07 jamiergrs

This was released in the latest version. But I am not sure if I understood the way this device works correctly, so please feed back on how it is working compared to the Tuya app.

make-all avatar Aug 15 '22 23:08 make-all

Hi, Just got my hands on one of these sirens. It gets added to HA , battery, Charging status and Tamper Detection shows correctly but it doesnt trigger the alarm from HA. Please let me know what information you need, I can work with you to resolve the issue. image

zerocritical avatar Sep 15 '22 02:09 zerocritical

My guess is,

to turn on, tone should be set to one of these - sound (for sound only), light (For light only) or sound+light (for both sound and light)

to turn off, tone should be set to normal

zerocritical avatar Sep 15 '22 02:09 zerocritical

You should be able to test that, as the tone is exposed in the siren entity. Unless there is a specific siren card, you may need to call a service from the developer console to test.

make-all avatar Sep 15 '22 02:09 make-all

My interpretation of the available controls when writing the config was that the siren could only be triggered by a hardware input, which is supposed to connect to the alarm controller, and the settings available via the network were just for configuration. But if the Tuya app is able to trigger the siren then there must be some way, and the presence of "normal" in the tone settings did raise some questions in my mind.

make-all avatar Sep 15 '22 02:09 make-all

Yes, can trigger siren from the app. Here are the screenshots from the app:

when triggered: image

when disabled: image

zerocritical avatar Sep 15 '22 02:09 zerocritical

The selling point of this siren is that it can be triggered using an event from another Tuya device.. like a door contact sensor or camera. So it allows to trigger remotely from the app.

zerocritical avatar Sep 15 '22 02:09 zerocritical

So to test, you should be able to go into Developer Tools, on the Services tab, and run the siren.turn_on service with a tone argument ("sound", "light" or "sound+light"). If that works, to turn it off, you may need to run the turn_on service again with a tone argument of "normal" rather than using the turn_off service.

make-all avatar Sep 15 '22 02:09 make-all

Brilliant! It works!!

I was trying to trigger from services before but without specifying the tone! with tone, it works perfectly to trigger and disable. :)

zerocritical avatar Sep 15 '22 02:09 zerocritical

By any chance would you be able to add configuration parameters to edit volume and duration? Like this:

image

zerocritical avatar Sep 15 '22 03:09 zerocritical

volume and duration are also set as parameters when calling the siren.turn_on service.
The Home Assistant interface to sirens only has the three services turn_on, turn_off and toggle, and nothing else. I added the current settings as extra attributes so you can read them back, but that is not part of the standard interface. Volume has a range between 0.0 and 1.0 per the HA interface, which will snap to the nearest value from 0.0=mute, 0.33=low, 0.67=middle, 1.0=high. Duration has the same 1 - 10 range as the Tuya docs, which I think is in minutes.

In response to this report, I now know how to make this siren work, so in the next release, "normal" will disappear from the available tones list, and be replaced with a working turn_off. turn_on without a tone argument and the toggle service will select sound by default.

make-all avatar Sep 15 '22 14:09 make-all

The siren should now fully function in 0.19.0, including the turn_off and toggle service calls, and turn_on with or without arguments..

make-all avatar Sep 19 '22 09:09 make-all

Note that 0.19.0 and 0.19.1 had some issues that might make it difficult to judge whether this is working correctly. And I found a further problem after 0.19.2 which probably stops the turn_off command from functioning, so if you want to check it, please use the main development branch (can be installed from HACS by selecting "Redownload" from the tuya-local details page, main should be at the bottom of the list of versions available - it will nag you to upgrade after that, but you can ignore it until a later version than 0.19.2 is available).

make-all avatar Sep 28 '22 07:09 make-all