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

code_format: null #71

Open
emilp333 opened this issue Jan 16, 2020 · 7 comments
Open

code_format: null #71

emilp333 opened this issue Jan 16, 2020 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@emilp333
Copy link

Hi,

I'm not sure where this attribute is used throughout HA but I use the TileBoard dashboard and the Alarm tile does not work because this attribute is null. Looking at the manual alarm control panel I see that this attribute is "number". As soon as I set this manually to "number" it works as expected. Actually setting it to anything else then "null" works so I think this integration should set the attribute accordingly.
I think this is a standard attribute in the Alarm control panel component in HA and should be set.

Thanks!

@akasma74
Copy link
Owner

This attribute has nothing to do with HA in general but has its meaning in some Lovelace cards (like alarm card).

When you describe the issue, it would be great to see real evidence rather than "the Alarm tile does not work because this attribute is null" as I personally don't use TileBoard and don't know how to deal with such an issue.

This attribute exists in alarm.AlarmControlPanel and this component has it as well.
Do you understand how it should work?

@emilp333
Copy link
Author

emilp333 commented Jan 16, 2020

Ok, I agree my comment was a bit vague and I did not do my reading on it.

So I checked the documentation of the alarm control panel entity here https://developers.home-assistant.io/docs/en/entity_alarm_control_panel.html#code-formats.

Value Description
None No code required.
Number Code is a number (Shows ten-key pad on frontend).
Any Code is a string.

I think that description is rather clear. Since this alarm component only support number codes it should be number or at least none. I think the issue is with null.
TileBoard have implemented a check on this attribute and if it is null it does not show any numpad and thats why it is not working.

I also checked the code (I'm far from a coder. I'm a decent reverse engineer/ugly hacker) and the code actually includes setting this attribute but it does not seem to do it correctly.
Line 712 of alarm_control_panel.py
res = None if (self._code is None or (self._state == STATE_ALARM_DISARMED and not self.code_arm_required)) else alarm.FORMAT_NUMBER
This tells me that it should set "None" if there is no code set or if the alarm is disarmed and to "require code to arm" is false. Otherwise return alarm.FORMAT_NUMBER. I have no clue what this alarm.FORMAT_NUMBER is but in no case should it resolve to null.

I can of course do a really ugly hack and just set the res = "number" as a workaround but I would be happy to see this working as intended.

Thanks for you hard work! :)

@akasma74
Copy link
Owner

As you can see from the code, this integration returns None or Number (at least I believe that's the value of that alarm.FORMAT_NUMBER).
I agree that it should not resolve to null.

Will look into it soon, it won't take too long so don't rush with your workaround ;)

@akasma74 akasma74 added the bug Something isn't working label Jan 16, 2020
@akasma74 akasma74 self-assigned this Jan 16, 2020
@akasma74
Copy link
Owner

Here's the debug printout:

2020-01-16 20:37:53 DEBUG (MainThread) [custom_components.bwalarm.alarm_control_panel] [code_format] self._code: 1234, self._state: disarmed, code_arm_required: False, returning None

Looking at HA states (0.103.0) I can see loads of automations with last_triggered: null.
Looks like a HA bug to me..

@akasma74
Copy link
Owner

There you go.
Looks like everything is fine with both HA and this component.. or it isn't?

@emilp333
Copy link
Author

Thanks for the investigation. I found the issue now.
The function does not check for user codes. I do not have a master code set but only user codes. In this scenario code_format result to None/null.
If I set a master code it works as expected.

@akasma74
Copy link
Owner

Thanks for the update.
That's interesting.
I'll keep this issue open and think about possible improvements/validity of a situation with no master code & set user codes.

@akasma74 akasma74 added enhancement New feature or request question Further information is requested and removed bug Something isn't working enhancement New feature or request question Further information is requested labels Jan 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants