thin-edge.io icon indicating copy to clipboard operation
thin-edge.io copied to clipboard

Extend alarms API to support child devices

Open albinsuresh opened this issue 2 years ago • 2 comments

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 the child-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.

albinsuresh avatar Jun 20 '22 12:06 albinsuresh

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

  1. 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 below sudo 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 a external_sensor device is created in c8y and also verify that an alarm message is visible under the alarm’s critical section.

  2. 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 below sudo 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 a external_sensor device is created in c8y and also verify that an alarm message is visible under the alarm’s critical section. The count for messages has increassed to 2

  3. Reconciliation when the new alarm message arrives, restart the mapper a. Connect to cloud sudo tedge connect c8y b. Stop the c8y mapper sudo systemctl stop tedge-mapper-c8y.service c. Send an alarm message from a child/external device to c8y cloud as below sudo 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 mapper sudo systemctl start tedge-mapper-c8y.service e. Now verify that an external_sensor device is created in c8y and also verify that an alarm message is visible under the alarm’s critical section.

  4. Reconciliation when the alarm that is cleared a. Connect to cloud sudo tedge connect c8y b. Stop the c8y mapper sudo 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 below sudo tedge mqtt pub 'tedge/alarms/critical/temperature_high/external_sensor' '' -q 2 -r d. Start the mapper sudo systemctl start tedge-mapper-c8y.service e. Now verify that under external_sensor the alarm messages under the critical section are cleared.

PradeepKiruvale avatar Aug 09 '22 11:08 PradeepKiruvale

resolved by #1314

PradeepKiruvale avatar Aug 09 '22 11:08 PradeepKiruvale