thingsboard / dart_thingsboard_pe_client

ThingsBoard PE API client library for Dart developers.
BSD 3-Clause "New" or "Revised" License
49 stars 16 forks source link

Unable to Receive Alarms in the App #25

Open senshi900 opened 3 months ago

senshi900 commented 3 months ago

Hello, I'm encountering an issue where I'm not receiving alarms within the app. After investigating, I discovered a solution involving the following code snippet:

        ? json['details']
        : null, // Handle if details is not a Map<String, dynamic> to the alarm_model 

This code modification resolves the problem temporarily. However, when sharing the code with other developers, they're unable to observe the changes. Is there a solution to this issue that doesn't involve modifying the model?

Just for your reference, I'm using PE app version 1.1.0. The file where I implemented the changes is located at: "C:\Users\User\AppData\Local\Pub\Cache\hosted\pub.dev\thingsboard_pe_client-1.1.0\lib\src\model\alarm_models".

Thank you. image

ybeshkarov commented 3 months ago

Hello!

Could you provide more details about the issue? Do you have any error messages or logs that could help us understand the problem better?

senshi900 commented 3 months ago

Hello,

Thank you for your prompt response. Upon further investigation, it appears that there are no error logs generated regarding the issue. However, during debugging sessions, it became evident that the alarm object is arriving as null within the application, temporarily i solved the problem by ensuring that if the 'details' field in the JSON data is not a Map<String, dynamic>, it assigns null to the alarm model

note: the update is in line 94 for Alarm.fromJson solve the problem

Even though alarms are present on the website, they do not appear in the app.

image

ybeshkarov commented 3 months ago

Could you please put a breakpoint inside the Alarm.fromJson method and check the value of json['details']?

Alternatively, expand the json field and provide a screenshot. This will help us understand the datatype you are receiving.

@senshi900

senshi900 commented 2 months ago

sure here is a screenshot of the debugging result

image

image

but this line of code fix the problem image