Alarm Control Panel Sizing

Hey all, am a refugee from smartthings given the issues with actually having a useful panel for a tablet/alarm.

Like others I found the alarm panel in HA too small to be useful so tried searching to no avail, and a bunch of other stuff (custom panels etc), but all I wanted to do was resize the fonts/text on the current panel.

I’ve found a way to do that which I thought would be useful to share for others if they’re trying to achieve the same thing.

long story short I ended up adjusting the homeassistant javascript to resize the number fonts, button size, and panel width to get the numbers and buttons bigger.

Was a bit of faffing to figure it out but ultimately it comes down to;

  • finding the chunk file the alarm control panel code gets built into
  • adding in / adjusting styling elements
  • mucking around to clear the cache for things that load the file

to find the chunk that gets coded you

  • open developer tools (F12), go to Sources, select the folder 'frontend_latest"
  • right click -> search in folder, and search for ‘alarmcode’
  • this should find one file called ‘chunk.xxxxxxxxxxxxxx.js’ mine was called chunk.74157e5a57fb84601820.js

now you need to go to the ha install and adjust this file.

For mine i use docker, so i had to get a shell in the docker container using
sudo docker exec -it homeassistant /bin/bash

Once in there i had to find the chunk file using
find / -iname "chunk.74157e5a57fb84601820.js*"

This should fine 3 files. Then I needed to edit the JS file in vi (eww) using the command below.
vi /usr/local/lib/python3.8/site-packages/hass_frontend/frontend_latest/chunk.74157e5a57fb84601820.js

I then edited the file from #keypad down to look like this. Differences are;

  • max width changed to 400px
  • height:75px given to #keypad mwc-button (this further spaces the buttons vertically, but doesn’t make the button’s itself bigger. that requires changes on the inner button control which i haven’t quite figured out yet)
  • font-size in mwc-button.numberkey changed to 2rem
#keypad {
        display: flex;
        justify-content: center;
        flex-wrap: wrap;
        margin: auto;
        width: 100%;
        max-width: 400px;
      }

      #keypad mwc-button {
        padding: 8px;
        width: 30%;
        box-sizing: border-box;
        height: 75px;
      }

      .actions {
        margin: 0;
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
      }

      .actions mwc-button {
        margin: 0 4px 4px;
      }

      mwc-button#disarm {
        color: var(--error-color);
      }

      mwc-button.numberkey {
        --mdc-typography-button-font-size: var(--keypad-font-size, 2rem);
      }
    `}}]}}),i.oi)}}]);

one this was done I needed to update the GZ as that still had the old js.

Backup the original file
mv /usr/local/lib/python3.8/site-packages/hass_frontend/frontend_latest/chunk.74157e5a57fb84601820.js.gz /usr/local/lib/python3.8/site-packages/hass_frontend/frontend_latest/backup-chunk.74157e5a57fb84601820.js.gz.backup

Then zip the new one
gzip -k /usr/local/lib/python3.8/site-packages/hass_frontend/frontend_latest/chunk.74157e5a57fb84601820.js

Then restart HA.

At this point i thought i was done, but browser caching was exceptionally annoying and I had to actually clear the cache completely to get it to work. I had funny results in postman, browsers etc until i did this. To see if it worked, do a curl command from both the box directly, and a cmdline eleswhere. you shoudl see the changes applied. if that works but the the app/web site doesn’t reflect the changes then you need to clear your browser cache.

Hope this helps others as it’s helped me.

end result
image

*edited for formatting and correctness

Note to future readers: I all you want is to have a bigger font size for the number keys, there is a much easier way: Using a custom theme as we have introduced a theme variable to control the keypad font size some releases ago.
This will however not make the keys themselves bigger, just their font.

frontend:
  themes:
    keypad_theme:
      keypad-font-size: "30px"

Also there are tools like https://github.com/thomasloven/lovelace-card-mod that allow you to add custom CSS (e.g. to adjust the size of the keypads) without having to modify the HA frontend code.

3 Likes

Thanks for the tips. I couldn’t find any examples where that had worked for an alarm panel (only where people couldn’t quite get it to work). If there’s a working example using the card mod I’ve love to see it.

So I had a hard time too getting it to look right on my fire tab size and just making the alarm panel bigger in general. Since i haven’t seen where anyone else has posted a working solution with the card mod i’ll give my solution for you or anyone else. There are still some oddities where there are two hover highlights for the keys and no outline for the clear or arm/disarms but is usable to me:

type: alarm-panel
entity: alarm_control_panel.ha_alarm
states:
  - arm_home
  - arm_away
card_mod:
  style: |
    ha-card { 
      --paper-input-container-shared-input-style_-_font-size: 2.5rem;
      --keypad-font-size: 2.5rem;
      --mdc-typography-button-font-size: 1.5rem;
      --mdc-button-outline-color: rgba(0, 0, 0, 0);
      --paper-font-subhead_-_font-size: 1.5rem;
      --mdc-shape-small: 100%;
    }
    #keypad {
      width: 30%;
      max-width: 500px !important;
    }
    #keypad mwc-button {
      border-radius: 5px;
    }
    mwc-button.numberkey {
      border-color: rgba(100,100,100,.1);
      border-width: 2px;
      border-style: solid;
    }
    #keypad mwc-button:hover {
      background: rgba(100,100,100,.2);
    }
    #keypad mwc-button {
      padding: 30px !important;
      margin: 4px;
      width: 30%;
      box-sizing: border-box;
      height: 100px;
    }
    paper-input {
        max-width: 300px !important;
    }
9 Likes

This does nothing?

type: alarm-panel
states:
  - arm_home
  - arm_away
entity: alarm_control_panel.master
frontend:
  themes:
    keypad_theme:
      keypad-font-size: 30px

Still the same

You seem to be adding the lines directly in the card config. That is incorrect.

Those need to go in your theme definitions, see Home Assistant Frontend - Home Assistant

1 Like

Thanks mate!

I ended up using Alarmo and the Alarmo card in the end.

Thank you, this is perfect

1 Like

It’s been a while since I’ve posted on this issue and there seems to be some success in resizing the alarm panel elements however, many of the instructions are disjointed, not clear, or difficult to follow. Does anyone have a definitive RECENT solution to this? The small alarm interface is almost prohibitive for visually impaired and people of 50.

Follow dhatcher instructions and create a new card with his code:

I took a look at the Alarmo integration in HACS and there it was! The alarm panel has a slider that allows you to resize the buttons to your desired dimensions. FINALLY! Easy to set up.

For those like me that doesn’t think the Code field is very useful and a waste of space. Just add this row in the code from @dhatcher:

    #alarmCode {
      content-visibility: hidden;
    }

It will make small square shaped panels like Sonoff NS Panel Pro much happier.

2 Likes

@oneAU thanks for this addition! Have you or anyone else had luck in customizing the status icon in the top right corner of the alarm panel? In my setup if you click on it it launches what appears to be the default alarm panel card… I’d like to disable the action on the icon click or remove/replace the icon all together. Any help would be appreciated!