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

The alarm panel status is always unknown, not the armed/disarmed state I expect #223

Open
robinsmidsrod opened this issue Nov 9, 2024 · 18 comments
Labels
bugfix Inconsistencies or issues which will cause a problem for users or implementers.

Comments

@robinsmidsrod
Copy link

Describe the bug

The alarm panel status is always unknown, not the armed/disarmed state I expect. I've tried to turn off the integration for some hours to see if it was a rate-limit. It doesn't seem to be. I've also tried logging into the website, and everything works there.

Version

v0.4.3

Expected behavior

The alarm panel status in HA should be armed/disarmed whenever it's changed by the provider.

Additional context

I'm getting this information in the logs:

This error originated from a custom integration.

Logger: custom_components.sector
Source: custom_components/sector/coordinator.py:391
integration: Sector Alarm (documentation, issues)
First occurred: November 7, 2024 at 22:55:30 (16 occurrences)
Last logged: 09:13:36

Timeout during fetching https://mypagesapi.sectoralarm.net/api/Panel/GetPanelStatus?panelId=01xxx084 with data None
Timeout during fetching https://mypagesapi.sectoralarm.net/api/Panel/GetTemperatures?panelId=01xxx084 with data None

Logger: homeassistant.components.binary_sensor
Source: helpers/entity_platform.py:764
integration: Binary sensor (documentation, issues)
First occurred: November 7, 2024 at 22:37:58 (3 occurrences)
Last logged: November 8, 2024 at 12:22:58

Platform sector does not generate unique IDs. ID sa_bs_01xxx084_None already exists - ignoring binary_sensor.sector_online

Logger: homeassistant.components.alarm_control_panel
Source: components/alarm_control_panel/__init__.py:210
integration: Alarm control panel (documentation, issues)
First occurred: November 7, 2024 at 22:37:58 (3 occurrences)
Last logged: November 8, 2024 at 12:22:58

Entity None (<class 'custom_components.sector.alarm_control_panel.SectorAlarmPanel'>) is setting state directly which will stop working in HA Core 2025.11. Entities should implement the 'alarm_state' property and return its state using the AlarmControlPanelState enum, please report it to the custom integration author.

Logger: homeassistant.const
Source: helpers/deprecation.py:222
First occurred: November 7, 2024 at 22:37:57 (4 occurrences)
Last logged: November 7, 2024 at 22:37:57

STATE_ALARM_ARMED_AWAY was used from sector, this is a deprecated constant which will be removed in HA Core 2025.11. Use AlarmControlPanelState.ARMED_AWAY instead, please report it to the author of the 'sector' custom integration
STATE_ALARM_ARMED_HOME was used from sector, this is a deprecated constant which will be removed in HA Core 2025.11. Use AlarmControlPanelState.ARMED_HOME instead, please report it to the author of the 'sector' custom integration
STATE_ALARM_DISARMED was used from sector, this is a deprecated constant which will be removed in HA Core 2025.11. Use AlarmControlPanelState.DISARMED instead, please report it to the author of the 'sector' custom integration
STATE_ALARM_PENDING was used from sector, this is a deprecated constant which will be removed in HA Core 2025.11. Use AlarmControlPanelState.PENDING instead, please report it to the author of the 'sector' custom integration
@hnrkgrln
Copy link

hnrkgrln commented Nov 9, 2024

I am experiencing the same issue.

Controlling the alarm from HA is still working but the alarm state doesn't reflect the changes and it doesn't matter how the alarm is changed (pad, app or HA).

@gjohansson-ST gjohansson-ST added the bugfix Inconsistencies or issues which will cause a problem for users or implementers. label Nov 9, 2024
@gustavzet
Copy link

Same issue here, arose when upgrading to HA Core 2024.11.

@sebastian-steinmann
Copy link
Contributor

seems related to this?
#217

@Jamnoran
Copy link

Same issue here.

@sebastian-steinmann
Copy link
Contributor

Think I have a fix her, but kinda blind coding
#224

@gjohansson-ST
Copy link
Owner

Hi guys

There should be more logs here trying to tell what's going on. We won't be able to fix it here as we're rewriting the integration and therefore can't patch the version you're using.
But we could try to figure it out and you can always fix locally if needed.

There's not reason for the new enum to cause this error, it's just a deprecation notice for now.
Anyone can turn on debug logs for sector and see if you get something more?

@gjohansson-ST gjohansson-ST pinned this issue Nov 11, 2024
@garnser
Copy link
Collaborator

garnser commented Nov 11, 2024

Anyone can turn on debug logs for sector and see if you get something more?

In configuration.yaml:

logger:
  default: warning
  logs:
    custom_components.sector: debug

@sebastian-steinmann
Copy link
Contributor

Not getting much, only the deprecation warnings, and

Logger: homeassistant.components.binary_sensor
Kilde: helpers/entity_platform.py:764
integrasjon: Binær sensor (dokumentasjon, problemer)
Førs oppstått: 21:55:50 (1 hendelser)
Sist logget: 21:55:50

Platform sector does not generate unique IDs. ID sa_bs_01241417_None already exists - ignoring binary_sensor.online_2

@sebastian-steinmann
Copy link
Contributor

Also a timeout:
Timeout during fetching https://mypagesapi.sectoralarm.net/api/Panel/GetPanelStatus?panelId=xxx with data None

@gjohansson-ST
Copy link
Owner

gjohansson-ST commented Nov 11, 2024

So hopefully like said before you can fix the incorrect file youself.
Open custom_components/sector/alarm_control_panel.py
Scroll to the bottom of the file and add the follow

@property
def state(self) -> str:
    """Return the state."""
    return self._attr_state

In the bottom of the file it should then look like:

    @property
    def available(self) -> bool:
        """Return entity available."""
        return True

    @property
    def state(self) -> str:
        """Return the state."""
        return self._attr_state

Dont forget the indentations so it's correct!

@sebastian-steinmann
Copy link
Contributor

That did the trick! Thanks

@robinsmidsrod
Copy link
Author

It worked for me as well. I tried to turn on the alarm (home mode) from HA, and it changed state, and then I turned off the alarm from the wall panel, and (eventually) the state in HA switched to disarmed.

So this looks like an acceptable fix.

Will this be in a new release soon, or is this just a band-aid that is not the correct way to do things?

@gjohansson-ST
Copy link
Owner

Will this be in a new release soon, or is this just a band-aid that is not the correct way to do things?

As mentioned above there are new enums and state handling in the alarm entity which will replace this quick fix.
On the other hand it requires HA 2024.11 but I think it's worth it anyhow so anyone wanting the new version eventually needs to be on that level.

@sebastian-steinmann
Copy link
Contributor

@gjohansson-ST did they add new enums and deprecate the old in the same release? thats kinda eager?

@gjohansson-ST
Copy link
Owner

They is me in this case as I made the PR for the new enums and deprecation 🤣
Actually it's supposed to be deprecated meaning it should still work but there is a flaw I noticed which broke sector. I need to fix that in HA.

@advitae
Copy link

advitae commented Nov 12, 2024

that trick doesn't work for me... I had an error loading.

/homeassistant/custom_components/sector/alarm_control_panel.py

@Property
def available(self) -> bool:
"""Return entity available."""
return True

@property
def state(self) -> str:
     """Return the state."""
    return self._attr_state

@gjohansson-ST
Copy link
Owner

No idea why that wouldn't work for you so I can only assume you have some typing error in the file.
Anyway I have now made a bugfix to sort this issue, so hopefully it's there shortly so it will be part of 2024.11.2

@advitae
Copy link

advitae commented Nov 13, 2024

No idea why that wouldn't work for you so I can only assume you have some typing error in the file. Anyway I have now made a bugfix to sort this issue, so hopefully it's there shortly so it will be part of 2024.11.2

Finally it work! I had to restart it a couple of times until it worked. the mysteries of programming 🤷. Thanks for the trick 😉!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Inconsistencies or issues which will cause a problem for users or implementers.
Projects
None yet
Development

No branches or pull requests

8 participants