Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Divera Alarm Sensor not available #14

Closed
JbbDE opened this issue Apr 16, 2023 · 8 comments
Closed

Divera Alarm Sensor not available #14

JbbDE opened this issue Apr 16, 2023 · 8 comments

Comments

@JbbDE
Copy link

JbbDE commented Apr 16, 2023

This sensor is shown in home assistant as not provided by the Integration.
It only worked one time, when I reinstalled the integration.

This error is visible:

`Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht

Logger: homeassistant.helpers.entity
Source: custom_components/divera/connector.py:118
Integration: Divera 24/7 (documentation, issues)
First occurred: 15. April 2023 um 09:23:56 (4375 occurrences)
Last logged: 21:51:33

Update for select.divera_user_status fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 550, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 755, in async_device_update
raise exc
File "/config/custom_components/divera/select.py", line 56, in async_update
await self._coordinator.async_request_refresh()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 200, in async_request_refresh
await self._debounced_refresh.async_call()
File "/usr/src/homeassistant/homeassistant/helpers/debounce.py", line 89, in async_call
await task
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 226, in async_refresh
await self._async_refresh(log_failures=True)
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 341, in _async_refresh
self.async_update_listeners()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 142, in async_update_listeners
update_callback()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 568, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 635, in _async_write_ha_state
attr.update(self.extra_state_attributes or {})
File "/config/custom_components/divera/sensor.py", line 66, in extra_state_attributes
return self._connector.get_last_alarm_attributes()
File "/config/custom_components/divera/connector.py", line 98, in get_last_alarm_attributes
"groups": list(groups),
File "/config/custom_components/divera/connector.py", line 118, in __search_group
group = self.data["data"]["cluster"]["group"][str(group_id)]
KeyError: '23636'
`

@fwmarcel
Copy link
Owner

hi @JbbDE, that is interesting.
Your last alarm seems to have alerted a group that is not assigned to your unit. According to my understanding, this should not happen at all.

Can you provide (anonymized) information about this. How are the alarm groups displayed in the app?
Is there a group there that doesn't belong to your unit?
Are you using the Pro version of Divera?

@JbbDE
Copy link
Author

JbbDE commented Apr 17, 2023

Sorry to say, but I'm no expert with Divera, just using it about two weeks by now.
But as far as I can tell our city uses Divera Pro.
We share our Fire brigade with full-time staff, who are alerted first and sometimes also alert the volunteer fire brigade in parallel. So the full-time employees might have their own unit.

IMG_20230417_150447

@fwmarcel
Copy link
Owner

thank you very much for the information.
now the error can at least be understood.
The error always occurs with alarms in which several groups from different units are involved.
Unfortunately I can't recreate this situation myself, as I only have access to the alarm version, so I may need several attempts and support to solve it.

But I think we will find a solution for this in any case.
Is the presentation of the units and the groups of the other units relevant for you?

@JbbDE
Copy link
Author

JbbDE commented Apr 17, 2023

I think, sometimes I might receive alarms from groups that belong to other units but include me. These will be relevant for me...

@fwmarcel
Copy link
Owner

hello @JbbDE . i have released a fix for now, so that the error no longer occurs for the time being.
However, not all groups should be displayed for you.
Please try the new version once with you and report back...

So that I can display the missing information, I need your support.
Caution this is quite complex. But unfortunately I have no other option....

https://api.divera247.com/?urls.primaryName=api%2Fv2%2Fpull#/Daten/get_api_v2_pull_all
On the page you can enter your API-Key under "Authorize".
Then under "/api/v2/pull/all" and "Try it out" and "Execute".
You should get a huge server response in the window below.

However, there is a lot of "private" information in there.
These do not interest me either. But I need some parts from the server response.
That's why I'm describing what information I need from the json schema:

In the response, please look for your alert.
You should find it under the path "data.alarm.items.".
All details are listed under the alarm. For me this looks something like this.

    "alarm": {
      "items": {
        "1122334": {
          ....
          "group": [
            1234
          ],
          "cluster": [],
          ....

There I am interested in the following values:
"cluster" and "group".
In your case I would expect that there is a list of several numbers in both of them.
For me, this looks something like this:

      "group": {
        "1234": {
          "name": "Group 1",
          "ric": "",
          "foreign_id": ""
        },
        ...

Please look for all these numbers in the server response.
The numbers of the groups should show up under the path "data.cluster.group.".
In your case, I would guess that some of the numbers show up there. Others, however, do not. Is that correct? If so, under which path do they appear?
It is important that the name of the group can be found there somewhere.

The same applies to the units. Under which path are they displayed and what does a section look like?

@JbbDE
Copy link
Author

JbbDE commented Apr 19, 2023

Hi @fwmarcel , thank you for your fix!
Currently I see no errors using it, so I'm waiting for the next alarm.
The last alarm can be seen on the homeassistant map and the entity data is also available.

@JbbDE JbbDE closed this as completed Apr 19, 2023
@tobias161183
Copy link

Hi @fwmarcel: I cannot find the DIVERA repository in HACS. Have you deleted it?

@fwmarcel
Copy link
Owner

@tobias161183 please do not use closed issues for other topics. The integration is still available

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants