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.
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
@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.