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
80 stars 31 forks source link

HA Panel disarm without code #100

Open riaan199 opened 4 years ago

riaan199 commented 4 years ago

Describe the bug So I have the addon setup and everything is working 100% when using the alarm page, however, If I try to use the HA alarm panel the status does update in BWalarm but the HA panel allows me to disarm the BWalarm without entering any code at all.

I think this is more of an update in HA as I did install the same version I had back when it worked v1.12.1 and its still able to disarm without the need of code from the HA pannel.

To Reproduce In HA interface add an alarm card then arm It then click disarm without entering a code

* bwalarm.yaml** platform: bwalarm panel: cameras: [] enable_floorplan_panel: 'False' hide_sidebar: true panel_title: '' camera_update_interval: '' hide_sensors: 'False' enable_night_mode: false states: armed_away: immediate:

akasma74 commented 4 years ago

Could you specify what version of HA you are using (as there is no such thing as current version) and also the version of HA when it worked as expected (if you remember). How did you notice that bug, was it after update of this component or HA?

akasma74 commented 4 years ago

If I try to use the HA alarm panel the status does update in BWalarm

By the way, could you explain what exactly do you mean? There are 2 ways to control the alarm interactively - via its own panel or using Lovelace alarm card.

riaan199 commented 4 years ago
The current version of HA: Home Assistant 0.110.4 " arch armv7l
chassis embedded
dev false
docker true
hassio true
host_os HassOS 4.8
installation_type Home Assistant
os_name Linux
os_version 5.4.42-v7l
python_version 3.7.7
supervisor 225
version 0.110.4
virtualenv false"

Version it last worked on unfortunately not at the moment. The first time I noticed it was about 1 month ago. when someone commented on this video. https://www.youtube.com/watch?v=2snonN7XFoc

Issue The Lovelace alarm card is showing the status correctly and seems to function as it should however I can disarm it from the Lovelace card without entering any disarm code.

akasma74 commented 4 years ago

I tried to reproduce it on my system running HA 0.109 and then after updating to 0.110.5. In both cases it does not allow me to disarm without entering a code.

Can you back up your bwalarm.yamland use the default one with a code defined and see if it makes any difference?

RascleMB commented 4 years ago

I can confirm the actions described. I thought it was by design, to allow a Dashboard with Arm/Disarm functionality without need of a Code for on our Personal Carry Devices while having Mounted Devices in the residence that required a Code. In any case, you can Disarm the System utilizing the Lovelace Alarm Panel Card without needing to Enter a Security Code. Just click the Disarm Button. Steps to Reproduce:

  1. Set up HASS Custom Alarm as Normal
  2. Add Alarm Panel Card to Dashboard
  3. Arm the System (either via Lovelace Alarm Panel Card or BW Alarm Panel, see additional testing below on potential arming issue)
  4. Go to the Lovelace Alarm Panel Card and Click the Disarm Button, there is no prompt for an Alarm Code and the System Disarms.

I did some additional testing. If I set the Option to Require a Code to Arm the System, the Lovelace Alarm Panel Card cannot Arm the System at all. No matter if I Click Arm Home or Arm Away it does not do anything. However, if I use the BW Alarm Panel to Arm the System (using a code), the Alarm Panel Card will still Disarm the System without the need for a Code.

More additional Testing. If I set a "Master Code", then the Lovelace Card does in fact properly allow/require a Code to be entered to Arm/Disarm the System. Seems the no need for a Code only applies if there is no Master Code Set.

akasma74 commented 4 years ago

@RascleMB it would be great if you could do the following:

  1. set bwalarm's log level to debug
  2. reproduce the issue i.e arm/disarm the alarm
  3. post information about your system (HA version, bwalarm version), bwalarm.yaml and relevant part of your HA log here
RascleMB commented 4 years ago
  1. I do not see an Option for setting the Log Level to Debug, just an On/Off Switch.
  2. Done (though without Debug since could not locate it)
  3. System Info and bwalarm.yaml included. Could not locate any relevant logs, most likely due to not locating the Debug Option.
Your Versions:
This integration: v1.12.4
Home Assistant: v0.111.4
Python: v(3,7,7,final,0)

bwalarm.yaml (User Codes and Password Removed for Security)

platform: bwalarm
panel:
  cameras: []
  panel_title: Alarm
  camera_update_interval: ''
  enable_clock: 'True'
  enable_weather: 'True'
  enable_fahrenheit: 'True'
  hide_passcode: 'True'
  round_buttons: 'False'
  enable_sensors_panel: 'True'
  enable_custom_panel: false
enable_night_mode: false
custom_supported_statuses_on:
- 4
states:
  armed_away:
    immediate:
    - sensor.mobile_pico
    delayed: []
    override: []
    pending_time: 30
    warning_time: 30
    trigger_time: 600
  armed_home:
    immediate:
    - sensor.mobile_pico
    delayed: []
    override: []
    pending_time: '0'
    warning_time: 30
    trigger_time: 600
  armed_night:
    immediate:
    - sensor.mobile_pico
    delayed: []
    override: []
    pending_time: 30
    warning_time: 30
    trigger_time: 600
users:
- id: 4b3a9e48dbb04a08bd6b20a0b19c881e
  name: Hass.io
  enabled: false
  code: 
  picture: ha.png
- id: adcfb0d83b1e48a8b7d27812cc1f97fa
  name: rascle
  enabled: true
  code: 
  picture: ha.png
- id: 61273f56333c47b99f6c1d85cfa6eff0
  name: sleepy
  enabled: true
  code: 
  picture: ha.png
enable_persistence: true
admin_password: 
code_to_arm: false
akasma74 commented 4 years ago

Thanks. Unfortunately, I need to see what the code is doing by examining its log output. Please refer to the bottom part of this post to find out how to change log level and where Home Assistant log file is located.

RascleMB commented 4 years ago

As you know I wasn't the original poster and I was just trying to help, but if it is this hard to even get Debugging Enabled. I tried Adding "custom_components.bwalarm.alarm_control_panel: debug" to my configuration.yaml as your post suggested, but Config would not Validate. Tried using the Developer Tools, and there is no Logger Service of any kind listed.

Here is the info needed to "Reproduce" the Issue(s): Any Configuration WITHOUT a "Master Code" and "Require Code to Arm" Disabled: BW Alarm Panel: Works Normally. When Disarmed it only shows Home and Away Buttons (no place for Code) and will Arm the System, when Armed shows Disarm Button (along with buttons for entering the Code) and will Disarm with Valid Code. Lovelace Alarm Panel: Works Abnormally on Disarm. When Disarmed only shows Home and Away Buttons (no place for Code) and the Buttons will Arm the System, when Armed shows Disarm Button (no place for Code) and WILL Disarm the System even though no code was/could be Entered.

Any Configuration WITHOUT a "Master Code" and "Require Code to Arm" Enabled: BW Alarm Panel: Works Normally. When Disarmed shows Home and Away Buttons (along with Buttons for Entering Code) and will Arm the System with Valid Code, when Armed shows Disarm Button (along with buttons for entering the Code) and will Disarm with Valid Code. Lovelace Alarm Panel: Works Abnormally. When Disarmed only shows Home and Away Buttons (no place for Code) and the Buttons will NOT Arm the System, when Armed shows Disarm Button (no place for Code) and WILL Disarm the System even though no code was/could be Entered.

Any Configuration WITH a "Master Code" and "Require Code to Arm" Disabled: BW Alarm Panel: Works Normally. When Disarmed it only shows Home and Away Buttons (no place for Code) and will Arm the System, when Armed shows Disarm Button (along with buttons for entering the Code) and will Disarm with Valid Code. Lovelace Alarm Panel: Works Normally. When Disarmed only shows Home and Away Buttons (no place for Code) and the Buttons will Arm the System, when Armed shows Disarm Button (along with buttons for entering the Code) and will Disarm the System with Valid Code.

Any Configuration WITH a "Master Code" and "Require Code to Arm" Enabled: BW Alarm Panel: Works Normally. When Disarmed it shows Home and Away Buttons (along with buttons for entering Code) and will Arm the System with Valid Code, when Armed shows Disarm Button (along with buttons for entering the Code) and will Disarm with Valid Code. Lovelace Alarm Panel: Works Normally. When Disarmed only shows Home and Away Buttons (along with Buttons for Entering Code) and the Buttons will Arm the System with Valid Code, when Armed shows Disarm Button (along with buttons for entering the Code) and will Disarm the System with Valid Code.

Though I am new to HA (just started switching from Wink a couple of weeks ago, heck I haven't even moved my Alarm nor any of my sensors to HA yet and just set up a Lutron Pico Remote as an Alarm Trigger for Testing before moving that stuff) I do work in IT and do some Programming. Though I have not looked at your python code at this point, it seems/appears to be an Issue with the Underlying HA Alarm Panel when a "Master Code" is NOT set in your Integration.

akasma74 commented 4 years ago

Thanks, I'll use your description to reproduce the issue and report back if I have any questions.

Just a couple of notes:

I tried Adding "custom_components.bwalarm.alarm_control_panel: debug" to my configuration.yaml as your post suggested, but Config would not Validate.

Most likely wrong indentation, look at the second example here and replace component's name.

Tried using the Developer Tools, and there is no Logger Service of any kind listed.

If you click on Developer Tools icon on the left, then on Services tab at the top and type log in the Service box, you'll see logger.set_level. Select it, copy/paste the string in question in the Service Data field and click on CALL SERVICE button.

RascleMB commented 4 years ago

That was it. No logger: in configuration.yaml Must have missed that part in the post for the custom_component.bwalarm.alarm_control_panel: debug.

Prior to added the logger: to configuration.yaml there "was no logger in Developer Tools/Services for me to pick. The ONLY entries were: logbook.log system_log.clear system_log.write

Now that I have logger in configuration.yaml the options are there. As I indicated, not new to computers but new to HA. Must have missed that requirement somewhere. Just had to do a major restore of 9 Servers for a customer, so running on no sleep at this point, but will try to get some Logs for you now that I have the Options available.

akasma74 commented 4 years ago

Actually, there is no need for logs. I'm working on the bug fix as your detailed description enabled me to reproduce the issue - it happens only when no master code specified, right? I had mine specified and actually it was mandatory up to one of the last major versions when multiple users support was added.

I have a working version but it's not as simple as it looks because the changed code affects service calls and MQTT commands, too so I need to test it properly before releasing. Hope to complete it soon.

p.s As I had logger entry in my configuration.yaml, all logger service calls were accessible but in your case they weren't if you didn't have that entry. Pretty obvious but still, very easy to forget when it's always there ;) There is a lot in HA that's a bit different to other home automation platforms so the learing curve can be steep.

RascleMB commented 4 years ago

Ok thanks. That is correct, only seems to be an issue when there is no Master Code. I myself would prefer not to have a Master Code, to limit number of codes available for use, but guess I could set it to be the same as my code.

I understand. I work in IT and do some programming here and there as well. Quick question, does the fix cause the Lovelace Card to Prompt for a Code when/where required (like the BW Panel does) or will it prevent the Disarm Button on the Lovelace Card to no longer work since it does not prompt for a code?

Being a computer geek (I do not work, I go to the office and do my hobby all day long and get paid for it :) ) and already having programming knowledge has helped a lot in the learning curve, but yes definitely a lot to digest. Which is good, means lots of Options for getting things set up exactly the way you want. After taking on this project, now wishing I had switched from Wink to HA a long time ago. Only thing left is setting up Automation for the Alarm System to trigger the Siren and Flashing Lights when it triggers, and eventually Remote Access (not sure if I will go VPN Direct or Cloud based yet). Possibly tie in my Security Cameras eventually as well, but not sure about that yet since I already have Remote Access and can check them anytime/anywhere already.

akasma74 commented 4 years ago

I myself would prefer not to have a Master Code, to limit number of codes available for use, but guess I could set it to be the same as my code.

That would mean you wouldn't see any reference to a user with that code in the alarm's log as to work correctly all codes must be unique.

does the fix cause the Lovelace Card to Prompt for a Code when/where required

sure. it will also fix the situation when you click Disarm and it disarms without entering a code.

Only thing left is setting up Automation for the Alarm System to trigger the Siren and Flashing Lights when it triggers

shouldn't be difficult, there are examples here. however, in each setup there might be some things to tweak depending on devices you use.

and eventually Remote Access

I rarely need it so currently use Tor add-on and it works for me.

kalyway101 commented 3 years ago

I see you are already working on fixing this issue. I did just want to say that this is exactly what I have been experiencing on the HA 0.112.3 version. I have a MASTER PASSWORD set and 'Require a passcode to set the alarm' Disabled. I am able to Arm my alarm system, which I actually have linked via an automation to my Ring Alarm. However, I can disarm the system without needing to enter a code via the Lovelace card.

Lukejb14 commented 3 years ago

I'm also experiencing this issue: HA Lovelace alarm panel 'disarm' button can be pressed to disarm alarm and bypasses the passcode when the keypad is present. Let me know if you need me to provide anything further...

RascleMB commented 3 years ago

@kalyway101: Strange, the only way I can Disarm the System without a Passcode is if I DO NOT have a Master Code Set. With a Master Code Set, Lovelace on my system functions exactly the same as the Alarm Panel. Prompting for a Code when/where needed depending on if "Require Passcode to Set" is Enabled or Disabled. Actually if I do not have a Master Code Set and I Enable "Require Passcode to Set", I cannot even Arm the Alarm from Lovelace. The Arm Buttons do Nothing. However if I Arm the System through the Alarm Panel (with a Code) I am able to Disarm the System without a Code from Lovelace when there is no Master Code.

@Lukejb14: Do you have a Master Code Set in the HA Alarm Panel settings? The only way I experience being able to Disarm the System without any Code from Lovelace is when No Master Code was set up (see description of my experiences above @kalyway101 ).

I know akasma74 was working on a fix but have not heard anything recently. Does not affect me much as I actually like being able to Disable from Lovelace without a Code. I have a Phone set up just inside the Door that is logged in as a HA User that only has Access to the BWAlarm Panel (which properly requires Arm/Disarm Code when/where needed no matter if there is a Master Code present or not), and have "my" Login set to use the Lovelace Alarm Panel so I can Arm/Disarm the System without needing to enter the Code from it.

Lukejb14 commented 3 years ago

@Lukejb14: Do you have a Master Code Set in the HA Alarm Panel settings? The only way I experience being able to Disarm the System without any Code from Lovelace is when No Master Code was set up (see description of my experiences above @kalyway101 ).

@RascleMB: I'm assuming code: '5853' is the master code?

HassOS 4.11: configuration.yaml: alarm_control_panel: !include resources/bwalarm/bwalarm.yaml

bwalarm.yaml:

platform: bwalarm
panel:
  cameras:
  - camera.front
  enable_clock: true
  enable_clock_12hr: true
  enable_weather: false
  enable_fahrenheit: false
  hide_passcode: true
  round_buttons: true
  enable_camera_panel: false
enable_night_mode: false
states:
  armed_away:
    immediate: []
    delayed: []
    override: []
    pending_time: 0
    warning_time: 0
    trigger_time: 600
  armed_home:
    immediate: []
    delayed: []
    override: []
    pending_time: 0
    warning_time: 0
    trigger_time: 600
  armed_night:
    immediate: []
    delayed: []
    override: []
    pending_time: 0
    warning_time: 0
    trigger_time: 600
users:
- id: 871a8e42dbfd444eb0650771f59b81e1
  name: Hass.io
  enabled: false
  code: 871a8e42dbfd444eb0650771f59b81e2
  picture: ha.png
- id: d120a051ed7b4bc39a90afc6021a8831
  name: L
  enabled: false
  code: d120a051ed7b4bc39a90afc6021a8831
  picture: ha.png
- id: 918a8d0540554530991e82aad3fd7340
  name: T
  enabled: false
  code: 918a8d0540554530991e82aad3fd7340
  picture: ha.png
- id: 9b41eaaec8de4059b7eab5a882edb94f
  name: iPad
  enabled: false
  code: 9b41eaaec8de4059b7eab5a882edb94e
  picture: ha.png
code: '5853'
admin_password: admin
enable_log: true
log_size: 10

RPReplay_Final1595518343

akasma74 commented 3 years ago

Guys, could you all read this? I know it's a bug and I have a version that needs to be tested properly, hence the delay. Unfortunately, I'm very busy now but plan to release the fix as soon as I have time to do it properly.

tbrasser commented 3 years ago

Thanks for working on this! I've read both posts, just want to mention that this also shows up when there is only a 'master code' set, just like in Lukejb14's post above.

nunocampos105 commented 3 years ago

Hi,

Thanks first for your great work !

Is there any evolution regarding this point ?

Best regards, and thanks a lot !

akasma74 commented 3 years ago

Is there any evolution regarding this point ?

As I said, I have a working version that needs proper testing. I'm still very busy but plan to come back to testing as soon as I have time.

brano1990 commented 3 years ago

hi i have the same problem in home assistant version 2021.1.5

Has this problem been solved in any way?