thin-edge.io
thin-edge.io copied to clipboard
Extend alarms API to support child devices
Is your feature request related to a problem? Please describe.
Provide APIs for child devices to raise alarms so that they are associated with their child device twins in Cumulocity. The mapping logic for child devices is documented here: https://github.com/thin-edge/thin-edge.io/pull/1205
AC:
- An an alarm for a child device can be published to
tedge/alarms/<severity>/<alarm-type>/<child-device-id>
topic where thechild-device-id
is the unique device id for that child device - The c8y-mapper on receipt of such messages should convert the Thin Edge JSON alarm payload to its equivalent SmartREST format and publish it to
c8y/s/us/<child-device-id>
topic. - Even if the
child-device-id
received with an incoming alarm does not already exist in the cloud, it need not be created explicitly as the SmartREST alarm message will create it automatically.
Testing the child device alarm message feature
Download the thin-edge.io from here Alarms for child devices (#1314) · thin-edge/thin-edge.io@098cd1b (github.com)
Given the thin-edge.io is installed and configured device to connect to the Cumulocity
-
Normal case when the child device does not exist on c8y cloud a. Connect to cloud
sudo tedge connect c8y
b. Send an alarm message from a child/external device to c8y cloud as belowsudo tedge mqtt pub 'tedge/alarms/critical/temperature_high/external_sensor' '{ "message": "Temperature is very high", "time": "2021-01-01T05:30:45+00:00" }' -q 2 -r
c. Now verify that aexternal_sensor
device is created in c8y and also verify that an alarm message is visible under thealarm’s critical
section. -
Normal case when the child device already exists a. Connect to cloud
sudo tedge connect c8y
b. Send an alarm message from a child/external device to c8y cloud as belowsudo tedge mqtt pub 'tedge/alarms/critical/temperature_high/external_sensor' '{ "message": "Temperature is very high", "time": "2021-01-01T05:30:45+00:00" }' -q 2 -r
c. Now verify that aexternal_sensor
device is created in c8y and also verify that an alarm message is visible under thealarm’s critical
section. The count for messages has increassed to 2 -
Reconciliation when the new alarm message arrives, restart the mapper a. Connect to cloud
sudo tedge connect c8y
b. Stop the c8y mappersudo systemctl stop tedge-mapper-c8y.service
c. Send an alarm message from a child/external device to c8y cloud as belowsudo tedge mqtt pub 'tedge/alarms/critical/temperature_high/external_sensor' '{ "message": "Temperature is very high", "time": "2021-01-01T05:30:45+00:00" }' -q 2 -r
d. Verify that. the alarm has not shown in c8y. d. Start the mappersudo systemctl start tedge-mapper-c8y.service
e. Now verify that anexternal_sensor
device is created in c8y and also verify that an alarm message is visible under thealarm’s critical
section. -
Reconciliation when the alarm that is cleared a. Connect to cloud
sudo tedge connect c8y
b. Stop the c8y mappersudo systemctl stop tedge-mapper-c8y.service
c. Send an empty message to clear the alarm message from a child/external device to c8y cloud as belowsudo tedge mqtt pub 'tedge/alarms/critical/temperature_high/external_sensor' '' -q 2 -r
d. Start the mappersudo systemctl start tedge-mapper-c8y.service
e. Now verify that underexternal_sensor
the alarm messages under thecritical section
are cleared.
resolved by #1314