Alarm does not arm/disarm - Invalid code given for armed_home

Running Hass.io in Docker on Ubuntu 18.04

0.107.0

I’ve added the alarm_panel card and set up a test code.

However, it won’t change the armed status and logs continue to show: Invalid code given for armed_home

It doesn’t matter what code I set or whether i use secrets yaml.

Have found a lot of posts on this but none of them address a fix.

I haven’t yet added any automations but from what I understand, I should be able to at least change the status by entering the code.

If I go into States, I can set the state to armed/disarmed and it updates the card in Lovelave. But if I try to arm/disarm via code in States, it does not do anything the log again shows invalid code.

Configuration.yaml setup:

alarm_control_panel:
    - platform: manual
      name: Home NoiseMaker
      code: 012345
      trigger_time: 900
      disarmed:
        trigger_time: 0
      armed_home:
        delay_time: 0
        pending_time: 0
      armed_away:
        delay_time: 60
        pending_time: 30
      triggered:
        pending_time: 0

that’s probably because of this option.
add code_arm_required: false to your config.

Thanks. I tried that and it armed but now it won’t disarm. :expressionless:

what’s your Alarm card config?

cards:
  - entity: alarm_control_panel.home_noisemaker
    states:
      - arm_home
      - arm_away
    type: alarm-panel
type: vertical-stack

Soooo…I changed the code (6 digit PIN) and now it works. I changed it back to what I originally had and it breaks again. :confused:

So apparently setting a PIN that starts with 0 is why it doesn’t work. Enclosed the original PIN in single quote and that fixed it, can now arm / disarm all day long.

Edit: as @AhmadK pointed out, code variable requires a string and leading 0s get dropped. Since I was not properly declaring a string, my original PIN, which starts with a 0, was not working to ARM / DISARM the alarm. After declaring the code as a string, ‘012345’, arming / disarming the alarm now works as expected.

I’m happy you solved your issue.
Just wanted to point out 2 things:
1.

because (without quotes) 01234 is number 1234 so in order to preserve that 0 you need to describe it as a string by using quotes.
Actually, if you read the docs, it clearly says the code is a string.
When you use code: 01234, it’s initially a number (that immediately loses its leading 0s) that then being used in the alarm panel’s code as a string to match that you entered when disarming (another string).
So you have make it a string. In your case you did bot that and it was rightly interpreted as a number by YAML.

Your initial issue was different - you were unable to set your alarm. If you mark this post as a solution, everyone who will look at it will be confused and would likely say (or even post here 2 years later) that it doesn’t work for them. So when you mark a post as a solution, keep it in mind.
Hint: if you take your original alarm config and only quote code, will you be able to set your alarm? If yes, you marked your post as a solution correctly. If not, you’re misleading the community :wink:

@AhmadK thanks for the info! I totally missed that code variable is a string plus didn’t realize leading 0s get dropped if not declared as a string. So it made for a perfect problem.

Regarding the solution, I updated the config so that it reflects the leading 0 and how making it a string by enclosing in apostrophe, it resolves the initial problem I had of not being able to ARM or DISARM the alarm.

Thanks again!