akasma74 / Hass-Custom-Alarm

It is a fork of "Yet another take on a home assistant custom alarm" that will exist until its author is back to our Earth
79 stars 29 forks source link

Hass not loading alarm when state is triggered/pending #3

Closed xhemp closed 5 years ago

xhemp commented 5 years ago

Your components (from Alarm/Settings/About): This Panel: v1.3.6_ak74 Component (Bwalarm): v1.1.4_ak74

Platform & Browser: Home assistant 0.92.2 running on Centos7 Chrome Version 74.0.3729.131 (Official Build) (64-bit)

Describe the bug I’ve been having some issues with my Hass (camera.stream and google cast) so sometimes it’s freezing so I have to kill the process and restart Hass. Problem is that today I’ve done that and my alarm was engaged so I believe it just set it to triggered and now I can’t bring the alarm back on at all, this is what I get on Hass:

2019-05-04 10:28:43 ERROR (MainThread) [homeassistant.components.alarm_control_panel] Error while setting up platform bwalarm
Traceback (most recent call last):
  File "/home/hass/homeassistant/lib64/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 126, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/lib64/python3.6/asyncio/tasks.py", line 358, in wait_for
    return fut.result()
  File "/usr/lib64/python3.6/asyncio/coroutines.py", line 212, in coro
    res = func(*args, **kw)
  File "/home/hass/homeassistant/custom_components/bwalarm/alarm_control_panel.py", line 315, in async_setup_platform
    alarm = BWAlarm(hass, config, mqtt)
  File "/home/hass/homeassistant/custom_components/bwalarm/alarm_control_panel.py", line 340, in __init__
    self.init_variables()
  File "/home/hass/homeassistant/custom_components/bwalarm/alarm_control_panel.py", line 440, in init_variables
    self.immediate  = self._states[self._state]["immediate"]
KeyError: 'triggered'

To Reproduce Steps to reproduce the behavior:

  1. Change the alarm.json (which I attached, dropped as txt due to github constraints) to the main hass configuration directory

alarm.json.txt

  1. Try to restart Hass

Expected behavior I expected it to recognise the alarm was triggered and start Hass with the alarm loaded instead of not loading it.

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here.

isabellaalstrom commented 5 years ago

Behaviour is the same when alarm is in state "pending" on restart.

akasma74 commented 5 years ago

I know, it currently works only in "proper" states, i.e away, home or perimeter as far as I understand. Will look into it asap

akasma74 commented 5 years ago

Guys, I need to know how to reproduce this situation. If I trigger my alarm and restart the HA, for example, I get a slightly different alarm.json (armstate isn't disarmed and timeoutat isn't null)

xhemp commented 5 years ago

Hmm, when you triggered the alarm did it change the armstate? I was able to reproduce that just changing the armstate to triggered and tried to start hass. Maybe stop hass, change the alarm.json armstate to triggered and try to start?

akasma74 commented 5 years ago

Hmm, when you triggered the alarm did it change the arm state?

I think there is a bit of confusion in terms. When I say armstate, I'm referring to a field armstate in alarm.json

I was able to reproduce that just changing the armstate to triggered and tried to start has.

That's what I wanted to know. The problem is that when I do the same (i.e trigger the alarm and then restart HA), it's "armstate": "armed_away" in alarm.json, not "armstate": "disarmed". And your case is strange because armstate is name of the mode the component heads towards.. and from my point of view it cannot go from triggered to disarmed, that's what worries me.

xhemp commented 5 years ago

I think there is a bit of confusion in terms. When I say armstate, I'm referring to a field armstate in alarm.json

Yes, I meant the armstate in alarm.json. Why do you think it can't go from triggered to disarmed? I have just tested triggered the alarm and then disarmed it, it changed the alarm.json's armstate frield from triggered to disarmed.

That's what I wanted to know. The problem is that when I do the same (i.e trigger the alarm and then restart HA), it's "armstate": "armed_away" in alarm.json, not "armstate": "disarmed". And your case is strange because armstate is name of the mode the component heads towards.. and from my point of view it cannot go from triggered to disarmed, that's what worries me.

I also changed the armstate to triggered and tried to restart HASS and was able to reproduce the problem again.

akasma74 commented 5 years ago

I think there is a bit of confusion in terms. When I say armstate, I'm referring to a field armstate in alarm.json

Yes, I meant the armstate in alarm.json. Why do you think it can't go from triggered to disarmed?

Ok, let's say you set your alarm to arm_away and left home. If alarm triggers, the alarm changes it state to Warning (pending) and then to Triggered. After Trigger Time it changes its state back to arm_away. It won't change to disarm until you disarm it when you get home.

I have just tested triggered the alarm and then disarmed it, it changed the alarm.json's armstate frield from triggered to disarmed.

Sure. But did you restart HA after you triggered the alarm and were you able to disarm it when HA completed its restart?

That's what I wanted to know. The problem is that when I do the same (i.e trigger the alarm and then restart HA), it's "armstate": "armed_away" in alarm.json, not "armstate": "disarmed". And your case is strange because armstate is name of the mode the component heads towards.. and from my point of view it cannot go from triggered to disarmed, that's what worries me.

I also changed the armstate to triggered and tried to restart HASS and was able to reproduce the problem again.

I know what causes the problem, but I am unable to reproduce alarm.json with content like yours, that's why I'm asking for more info here. I have a solution, but it won't work if your problem is different to mine. And I cannot provide a solution to a problem if I cannot reproduce it.

xhemp commented 5 years ago

I think there is a bit of confusion in terms. When I say armstate, I'm referring to a field armstate in alarm.json

Yes, I meant the armstate in alarm.json. Why do you think it can't go from triggered to disarmed?

Ok, let's say you set your alarm to arm_away and left home. If alarm triggers, the alarm changes it state to Warning (pending) and then to Triggered. After Trigger Time it changes its state back to arm_away. It won't change to disarm until you disarm it when you get home.

That's one of the options but that was not the issue, the problem was that the alarm was in triggered state (armstate set to triggered on alarm.json) so when trying to restart HASS, it won't come up at all so I wouldn't even be able to access the alarm.

I have just tested triggered the alarm and then disarmed it, it changed the alarm.json's armstate frield from triggered to disarmed.

Sure. But did you restart HA after you triggered the alarm and were you able to disarm it when HA completed its restart?

See above.

That's what I wanted to know. The problem is that when I do the same (i.e trigger the alarm and then restart HA), it's "armstate": "armed_away" in alarm.json, not "armstate": "disarmed". And your case is strange because armstate is name of the mode the component heads towards.. and from my point of view it cannot go from triggered to disarmed, that's what worries me.

I also changed the armstate to triggered and tried to restart HASS and was able to reproduce the problem again.

I know what causes the problem, but I am unable to reproduce alarm.json with content like yours, that's why I'm asking for more info here. I have a solution, but it won't work if your problem is different to mine. And I cannot provide a solution to a problem if I cannot reproduce it.

The problem per se doesn't bother me to be honest as I know that changing the alarm.json's armstate to disarmed would allow me to bring HASS back if I have the same problem again but would be nice to understand why it's happening. If you need anything else from me (testing another scenario, etc), please, let me know.

akasma74 commented 5 years ago

I think there is a bit of confusion in terms. When I say armstate, I'm referring to a field armstate in alarm.json

Yes, I meant the armstate in alarm.json. Why do you think it can't go from triggered to disarmed?

Ok, let's say you set your alarm to arm_away and left home. If alarm triggers, the alarm changes it state to Warning (pending) and then to Triggered. After Trigger Time it changes its state back to arm_away. It won't change to disarm until you disarm it when you get home.

That's one of the options but that was not the issue, the problem was that the alarm was in triggered state (armstate set to triggered on alarm.json) so when trying to restart HASS, it won't come up at all so I wouldn't even be able to access the alarm.

Exactly. Imagine that the alarm was triggered (in the situation above) and HA restarted for some reason - it won't come up at all, I know. But it SHOULDN'T have "armstate": "disarmed" in alarm.json as in your case, it should be "arm state": "armed_away" (and I can easily reproduce it).

I have just tested triggered the alarm and then disarmed it, it changed the alarm.json's armstate frield from triggered to disarmed.

Sure. But did you restart HA after you triggered the alarm and were you able to disarm it when HA completed its restart?

See above.

that's apples and pears. Sorry, but your story is different to mine or you cannot explain how to reproduce the issue.

That's what I wanted to know. The problem is that when I do the same (i.e trigger the alarm and then restart HA), it's "armstate": "armed_away" in alarm.json, not "armstate": "disarmed". And your case is strange because armstate is name of the mode the component heads towards.. and from my point of view it cannot go from triggered to disarmed, that's what worries me.

I also changed the armstate to triggered and tried to restart HASS and was able to reproduce the problem again.

I know what causes the problem, but I am unable to reproduce alarm.json with content like yours, that's why I'm asking for more info here. I have a solution, but it won't work if your problem is different to mine. And I cannot provide a solution to a problem if I cannot reproduce it.

The problem per se doesn't bother me to be honest as I know that changing the alarm.json's armstate to disarmed would allow me to bring HASS back if I have the same problem again but would be nice to understand why it's happening.

To fully understand what causes your issue I need to have a full description of the problem and be able to reproduce it (or have enough data to make any assumptions), otherwise it's impossible to guarantee that I'm solving the right problem, is that clear?

If you need anything else from me (testing another scenario, etc), please, let me know.

I'll let you know when a code with the fix is available.

akasma74 commented 5 years ago

Can you test the latest release to see if the issue is resolved?

akasma74 commented 5 years ago

I'm closing this issue as there is no activity here.