-
Notifications
You must be signed in to change notification settings - Fork 4
60. tuyaTRIGGER info
The TRIGGERs do not connect to individual devices, but create a direct and bidirectional connection with Tuya-cloud events and 'automation', allowing complete control of both the smartlife logic and the devices not handled by the LOW-LEVEL MQTT channel. This technique produces a fast and reliable HI-LEVEL communication channel, stable over time because it is not very affected by the evolution of Tuya ecosystem.
TuyaSmart App and SmartLife App limits (2021-01-07)
Item Description Limit
Device Schedule quantity The maximum number of timers that can be added to a single device 30
Number of household devices Maximum number of devices that can be added in a single home 120
Number of scenes The maximum number of Tap-to-Run that a single home can create 100
Number of automations Maximum number of Automations that can be created in a single home 100
Number of scene actions The maximum number of tasks that can be added in a Tap-to-Run 150
Number of automation actions The maximum number of tasks that can be added in an Automation 150
Number of automation conditions The maximum number of conditions that can be added in an Automation 10
Number of multi-terminal logins The maximum number of mobile devices that
can simultaneously log in to an account 200
Number of homes The maximum number of Homes that can be created by a single App account 20
Number of home members The maximum number of home members that can be added in a single home 20
Number of rooms The maximum number of rooms that a single home can create 20
Number of room equipment The maximum number of devices that can be added in a single room 50
Number of equipment groups The maximum number of devices that can be added in a single device group 100
Number of home equipment groups The maximum number of device groups that a single home can create 20
Number of users The maximum number of each device group that
shared by device group can be shared with other users 20
Number of users sharing devices The maximum number of each device that can be shared with other users 20
Number of homes invited The maximum number of each App account that can be invited by other homes 20
more
- Number of Zigbee devices : gateway theoretical limit is 128 wired and 50 WiFi.
The total number of automations is limited (100 + 100) but this limit is on a "home" basis. If we use the classification "home" as "scope" (such as 'safety', 'irrigation', 'climate' ...) this limit can be easily overcome and the interrelationships between 'homes' can be entrusted by tuyaDAEMON.
The tuya_bridge
fake device handles the _trgPing
property: that is, a measure of the time taken by a complete TRIGGER round trip, to verify the real performance of TRIGGER:
- A
TRIGGER1050
command is executed by tuyaDEAMON and an MQTT message is sent to the device: SETtuya_bridge":countdown to 1050
- The device receives the MQTT message, sets its counter to 1050, then broadcasts an MQTT message:
tuya_bridge:countdown
changed to 1050 - (tuyaDEAMON receives and processes the message)
- Also tuya-cloud receives this MQTT message, looks for automation, and executes:
if "tuya_bridge"countdown:1050, "tuya_bridge"countdown:0
-
Tuya-cloud sends an MQTT command to the device: SET
tuya_bridge":countdown to 0
- The device receives the MQTT message, sets its counter to 0, then broadcasts an MQTT message:
tuya_bridge:countdown
changed to 0 - This MQTT message is captured by tuyaDEAMON and decoded.
So tstPing is the sum of <tuyaDAEMON send MQTT> + <device RX + broadcast update> + <tyua-cloud RX + find automation + send MQTT> + <device RX + broadcast update> + <tuyaDAEMON RX MQTT> + <network delays for 4 MQTT links>
Using my actual PC, 1G FTTH router, and a switch MOES QS-WIFI-S03 as tuya_bridge, I get (2022, Rome/it, in ms):
_trgPing: object
count: 5
avg: 114
max: 123
min: 112
Compare these values with the tuya response time and with the PING data from the smartlife-configuration-network test
.
On ANDROID, using _testPing24H
(does _tstPing
every 20 min), I get the following results:
This show the PING time variations in 24H:
The minimum values are in the range [100-250] ms, often even less than 100. The average values rise in the time interval [01: 00-14: 00] (local, UTC + 2): further investigation could pinpoint the cause. Some sporadic maximum values can be high, up to 450 ms. The slow Android O.S. does not seem to significantly affect the measurements.
This is only an example. New actual map is in 'triggerMAP' node in core-trigger flow (since 2.2.0):
-
TUYATRGs (1000-1990) are used to handle 'mirror' devices.
- the device changes status
- an automation is fired by this event and it sends a TUYATRG to node-red.
- on receiving the TUYATRG, node-red remaps the trigger as a usual device message, to log them, using a fake dps (convention: same as the trigger value). The mirror device and dps must be defined in
global.alldevice.fake
branch. - node-red sends an ACK (reset the 'counter' to 0)
example in tuyaTRIGGER:
the WiFi 'Motion Detector' device is battery powered. But a trigger is send at any status change by tuya-cloud to tuyaDAEMON:
-
TUYATRG1010: is mapped as
Motion Detector [123410408caab8e79837]:alarm[dps:1010]:OFF
In Tuya Automation we need:
If sensore di movimento:normale, tuya-bridge:countdown:1010
-
TUYATRG1020: is mapped as
Motion Detector [123410408caab8e79837]:alarm[dps:1010]:ON
In Tuya Automation we need:
If "sensore di movimento:Allarme", tuya-bridge:countdown:1020
-
TUYATRGs (1000-1990) are also used fired by smartlife to signal some user/device/weather/geolocation action
example in tuyaTRIGGER:
- TUYATRG1030: free
- TUYATRG1040: free
-
REDTRG (2000-2990) can be fired by node-red, to activate smartlife automations:
example in tuyaTRIGGER:
- REDTRG2010: free
- REDTRG2020: free
-
more TRIGGERs, with conditions defined by the user, can fire node-red flows asynchronously, without
global.alldevices
polling, or implement conditions not allowed by smartlife automatitions.example in tuyaTRIGGER:
- EVNTRIGGER00A: fired if temperature > 20 °C (from a virtual device)
- EVNTRIGGER00B: fired on PIR alarm (from a mirror device)