Oliver Maller
All projects

Project · Security · Home Assistant

An alarm panel without the licence

How I got an ICT Protege WX alarm and access controller into Home Assistant and Apple Home by speaking the same encrypted protocol as its own web pages, and what I learnt when an early tool made the controller reboot itself.

Controller
ICT Protege WX
Licence needed
None
Updates
About 1 s
Latest release
v0.9.0
Contents

An alarm that lived in its own world

My parents' house has an ICT Protege WX: an alarm panel and door access controller in one, with keypads, access-controlled doors and sensors through the house. It's the sort of system you find in offices and shops, and for years it sat completely apart from everything else in the house.

The rest of the house already runs on Home Assistant. The alarm couldn't join in. You couldn't arm it from your phone, the lights couldn't react to it, and nobody could tell at a glance who had come in last or which window had stopped it arming.

I wanted it in Home Assistant and in Apple Home like everything else: arm and disarm from anywhere in the house, lock and unlock the doors, see the motion sensors, and know who did what. Locally, with no cloud service in the middle.

This is how ha-protege-wx and its library aioprotegewx came together. The people in the examples are made up (Alex, Sam and Jordan), and so are the zone and door names, apart from where the controller's own wording matters.

No licence, and a tool that didn't fit

ICT's official way for other systems to talk to a WX is its Automation and Control service. It's a paid licence, and our controller doesn't have it. That closes the front door.

What every WX does have is a web interface. Ours answers on plain HTTP, port 7377, running web interface 2.3.x on WX firmware 4.00. An installer uses it to check status, read the event log and control areas and doors from a browser. If a browser can do it, so can a program, as long as it speaks the same language as those web pages.

Someone had been there before me. protege-wx-cli by Mitchell Johnson ports the web interface's own JavaScript to Python: the login hashing and the AES encryption, byte for byte. It's careful, clever work, and none of this would exist without it. But on our controller it didn't work at all.

It had been written for an older web interface, where every request is an HTTP GET and the browser makes up its own session ID. Web interface 2.3.x had moved on. Comparing the CLI's requests with what my browser sent turned up the differences one at a time:

  • Every request is a POST to /PRT_CTRL_DIN_ISAPI.dll, with the command in the body instead of the query string.
  • The controller issues the session. InitSession takes no session ID any more; the controller answers with a SESSID cookie. It sets that cookie on a bare IP address, which aiohttp's default cookie jar quietly refuses, so the client needs a jar that accepts it (CookieJar(unsafe=True)).
  • The login hashing hasn't changed. Same SHA-1 challenge and response as before.
  • Encrypted commands are sent as they are: hex of a 16-byte IV followed by AES-128-CBC, with no session prefix and no sequence suffix.
  • An empty X-CSRF-Token header goes with every request, because that's what the pages send.
  • Area status has four fields instead of three: Area16=128,0,0,0.

The library tries the 2.3 way first, and falls back to the older GET protocol if the controller doesn't hand out a session cookie. So one client handles both, and you never have to know which you have.

If you can log in to the controller in a browser, Home Assistant can control it.

Speaking its language

The login is a challenge and response. The controller sends a random number, and the client answers with SHA-1 hashes mixed with that number, so the password itself never crosses the network. A second number from the controller then makes the session key: 16 characters that become an AES-128 key for everything after.

# Simplified from aioprotegewx. Every step is a POST to /PRT_CTRL_DIN_ISAPI.dll.
seed0 = int(post("Command&Type=Session&SubType=InitSession"))  # also sets SESSID

pw = sha1(password)
name_hash = SHA1(xor_with_seed(username.lower(), seed0 + 1))
pass_hash = SHA1(xor_with_seed(pw, seed0))
seed1 = int(post(f"Command&Type=Session&SubType=CheckPassword"
                 f"&Name={name_hash}&Password={pass_hash}"))

key = SHA1(xor_with_seed(pw, seed1))[:16]  # the AES-128 session key
Logging in. xor_with_seed is a port of the web page's own xor() function. A wrong password comes back as FAIL, or FAIL:120 when the controller has locked the operator out for 120 seconds.

After that, every command is a line of plain text, padded to whole 16-byte blocks, encrypted, written out as hex and posted. Replies come back the same way. An area command looks like Command&Type=Control&SubType=GXT_AREAS_TBL&RecId=16&Command=10, where the last number is the verb: 0 disarms, 3 arms away, 4 force arms, 5 arms instant, 6 force arms instant, 7 and 8 start and end a walk test, 9 silences the siren and 10 arms stay. Doors and outputs have their own short lists.

Pick a command to watch it go from plain text to the bytes on the wire.

  1. The command, in plain text

    Command&Type=Control&SubType=GXT_AREAS_TBL&RecId=16&Command=10

    Type=Control sends a control verb. SubType=GXT_AREAS_TBL is the areas table, RecId=16 is the area, and Command=10 arms it in stay mode.

  2. As bytes, padded to 16-byte blocks

    P1436F6D6D 616E6426 54797065 3D436F6E
    P274726F6C 26537562 54797065 3D475854
    P35F415245 41535F54 424C2652 65634964
    P43D313626 436F6D6D 616E643D 31300202

    62 bytes of text and 2 bytes of padding, each 02, make 4 blocks. The padding byte says how many padding bytes there are.

  3. IV, then AES-128-CBC

    IV6B335139 76543178 4C6D3761 5232705A
    C15B721228 CC4596D1 85B1D755 85145C57
    C261F72DD7 33504E8A 15AEC791 C38D9D5B
    C37D35C3CE 4CEAB9A2 7477A490 2A935A63
    C4B40602E0 8BA1C719 5BC3ECE9 0D0E055F

    The IV is 16 random characters, sent in the clear. Each encrypted block is mixed with the one before it, so a change near the end of the command only changes the last blocks.

  4. The request on the wire

    POST /PRT_CTRL_DIN_ISAPI.dll HTTP/1.1
    Host: 192.0.2.10:7377
    Accept: text/plain, */*
    Content-Type: application/x-www-form-urlencoded; charset=UTF-8
    X-CSRF-Token: 
    Cookie: SESSID=(issued by InitSession)
    Content-Length: 160
    
    6B335139765431784C6D37615232705A5B721228CC4596D185B1D75585145C5761F72DD733504E8A15AEC791C38D9D5B7D35C3CE4CEAB9A27477A4902A935A63B40602E08BA1C7195BC3ECE90D0E055F
  5. The reply, decrypted

    IV48713457 73384E65 32596336 556A3042
    C13B4D8DBE 97E0F5DB 1972E375 02DE6147
    → OK
Real encryption, illustrative values: the key is 0123456789ABCDEF (the one in the library's tests) and the IVs are fixed so the figure doesn't change between visits. Because the IV is fixed here, every area command starts with the same blocks; the real client draws a fresh random IV for every request, so two identical commands never look alike on the wire. The address is a documentation example.

A reply of OK only means the controller accepted the command. It doesn't mean the house is armed. That difference matters a lot later.

The night the controller rebooted itself

Once I had the CLI talking to 2.3.x, I used it a lot. Check the status, arm, disarm, read the log, check again. Then commands stopped coming back, and the controller rebooted itself.

The cause was simple once I saw it. Each run of the CLI logged in, did its one thing and exited, and never logged out. Every run left a session behind on the controller, and the operator's sessions lived for an hour. By the time it fell over, about 25 abandoned sessions were sitting there. The command endpoint timed out, and the controller dealt with that by restarting.

For a toy, that's a funny story. For a security system, a reboot means a controller that isn't watching for a while, and a program that can cause one shouldn't be allowed near it. Play it through, then switch to the integration to compare.

  1. Every run logs in. The CLI starts a fresh session for each command and exits without logging out.
  2. Sessions pile up. Each one lives until the operator's one-hour timeout.
  3. About 25 later, the command endpoint stops answering and requests time out.
  4. The controller reboots itself, and every session is gone.
  5. The integration keeps one session, logs out when it stops, and its sessions time out after 15 minutes if Home Assistant crashes.
An illustration of the hour, not a recording. The runs are spaced evenly; the numbers from the real night are the roughly 25 sessions and the one-hour timeout. The integration's side follows its documented behaviour with a 15-minute operator timeout.

So the first rule of the integration became: be gentle with the controller. Protecting it matters more than reconnecting quickly.

  1. One sessionLog in once, keep that session, and log out on reload, removal and shutdown.
  2. One request at a timeLike the web pages, never several in flight.
  3. Gentle reconnectsA dropped session is re-established once. Refused straight away? Wait 30 s, doubling up to 10 minutes.
  4. Login budgetNever more than 6 logins in 10 minutes, shared by every client for the same controller, so reloads can't get round it.
  5. No lockoutsA rejected password stops all login attempts after at most two tries, and asks you to sign in again.
  6. Small pollsEvery second: areas, zones and the newest log page. Doors, troubles and outputs when the log says they changed, and at least every 5 s.
How the integration treats the controller, from the library's login guard and the integration's polling.

One rule came straight from that night. A plain FAIL to a login that has worked before might not be a bad password at all: it might be a full session table. So the first time it happens, the client backs off instead of trying again. A second one in a row is treated as a real rejection, so a changed password can't keep counting towards the operator's lockout. And when the controller says FAIL:120, that's its own verdict, and the client stops.

After a minute with nothing happening, it also slows down to one read every 2 seconds, and switches back the moment a zone, door, delay or event changes. That halves the load on the controller for most of the day.

Reading the panel honestly

Area status comes back as one line per area, such as Area16=128,129,8,0. The second number is the state and the third is a set of flags. The codes come from the web interface's own pages: 0 is disarmed, 1 to 5 are "disarmed, but not ready" (a zone open, a trouble, a bypass problem, someone still inside), 128 is armed, 129 is the exit delay, 130 the entry delay. The flags say whether an alarm went off, whether the siren is sounding, whether it was armed remotely, forced, instant or in stay mode.

Mapping that to Home Assistant's alarm states took more care than it sounds. Two rules shaped it.

Unknown is never safe. If a code isn't one the library knows, or a field won't parse, the area is unknown and the panel shows as unavailable. It never falls back to disarmed, a door never falls back to locked and a zone never falls back to closed. A tampered or shorted zone reads as open, because it can't prove it's closed. Garbage in the flags makes the whole area unknown too, because garbage could be hiding an alarm.

Triggered means happening now. The "alarm activated" flag stays set after an alarm until the memory is cleared. On its own it only counts while the area is armed or in its entry delay. A sounding siren always counts. Otherwise the house would show Triggered all evening after someone set it off by accident in the morning.

Step through an evening. Each step shows the line the controller sends, what the library reads from it, and what Home Assistant shows.

Area states: disarmed, not ready, exit delay, armed, entry delay, triggered, and unknown delay ends disarm Not ready1 to 5 Disarmed0 Exit delay129 Armed128 Entry delay130 Triggeredalarm or siren flag Unknownany other code
Status lines and what they become
Controller sendsLibrary readsHome Assistant shows
Area16=128,0,0,0disarmedDisarmed
Area16=128,1,0,0zone_open (not ready)Disarmed, with the open zones listed
Area16=128,129,8,0exit_delay · remote_armedArmed away (or Arming, if you choose)
Area16=128,128,8,0armed · remote_armedArmed away
Area16=128,130,8,0entry_delay · remote_armedPending
Area16=128,128,11,0armed · alarm_activated, siren_activated, remote_armedTriggered
Area16=128,0,5,0disarmed · alarm_activated, alarms_in_memoryDisarmed (the alarm is only in memory)
Area16=128,999,0,0unknown_999Unavailable, never Disarmed
Decoded with the library's own tables. The status lines are built from those tables for the example rather than captured, apart from 128,0,0,0, which is what a real controller sent for a disarmed area. The first field isn't used.

The exit delay has a twist. Apple Home, through the HomeKit Bridge, shows every "arming" state as Away. So by default, during the exit delay the panel reports the mode being armed (Home while arming stay, Away while arming away), and Apple Home gets it right. An option switches it back to a plain "Arming".

An arm isn't done until the controller says so

That OK from the controller only means "command received". If a window is open, the controller happily says OK and then refuses to arm, writing two lines to its log: the zone that's open, and Failure To ARM. So after every arm, the integration reads the area again, for about two seconds, and only reports success once fresh status shows it armed or in its exit delay. If the log says it failed, you get an error naming the open zones: Alarm didn't arm because these zones were open: Kitchen. Close them or use force arm. If the controller stops answering in that time, you're told the arm couldn't be confirmed and to check the keypad, not that it worked.

Who did what

The status lines say what the house is doing. The event log says who did it. Every arm, disarm, door, card and PIN is written there in plain English, and reading it is what turns "the alarm was disarmed" into "Alex disarmed it with a PIN".

The lines are easy for a person to read and awkward for a program, because names can contain spaces. "Front Door" might be a door, or a door called "Front" followed by the word "Door". So the parser doesn't split on words. It matches each line against the names it already knows for areas, doors, zones and trouble inputs, longest first.

Event log lines and how they're read
The lineKindSubjectTypeWho and how
Area Alarm Stay Arming Started By Home AssistantareaAlarmarming_started (stay)Home Assistant
Input Living OpenedinputLivingopened
Area Alarm Failure To ARM By Home AssistantareaAlarmfailed_to_armHome Assistant
User Alex Entry Granted Front Door Using User By PinaccessFront Dooraccess_grantedAlex, PIN
Door Gate Unlocked By Door Front DoordoorGateunlockedDoor Front Door
Trouble Input System Restarted OpenedtroubleSystem Restartedtrouble
Output Keypad 1 Green LED OFF By Group PG004noise
Line formats from a real controller, with the date and time trimmed off the front (each line starts like Sun 25/10/2026 19:21:35) and a made-up user. Keypad lights and beepers are "noise" and never reach automations.

Even the date needed care. A controller set to month/day prints 4 March as 04/03, which reads as 3 April to anyone expecting day/month. Every line starts with the weekday, though, so the parser tries both orders and keeps the one whose weekday matches. That fix went out in 0.8.2.

News or history

The integration reads the newest page of the log every second and keeps the last 500 lines it has seen, so nothing is announced twice. The harder questions are about lines it hasn't seen yet:

  • Lines older than 2 minutes are history, not news. After a network drop, Home Assistant catches up on what it missed and keeps it for context, but doesn't fire automations for a door that opened twenty minutes ago.
  • Events are never lost. If every line on the newest page is new, more happened than one page holds, so it reads back up to three pages until it finds one it knows.
  • A restart doesn't hide an alarm. The first page after Home Assistant starts is history, except alarms, failures to arm and emergencies from the last 10 minutes. Those are announced, marked as replayed, so an alarm during a restart still reaches your phone.
  • An emergency is always news. A duress, panic or medical alarm fires an event, a persistent notification and a critical Repairs alert that stays until someone marks it handled, however late it's read.

The log also keeps an eye on the controller's clock. A line read within a poll of happening says how far the controller's time is from Home Assistant's, and if it's more than 2 minutes out, Repairs says so. Lines read late show the time they really happened in the logbook.

Rules for a security system

Most Home Assistant integrations can afford to be a bit optimistic. This one can disarm a house and open its front door, so I wrote the rules down early and test against them:

  • Unknown is never safe. Nothing unreadable ever shows as disarmed, locked, closed or ready.
  • An arm is only a success once it's confirmed.
  • Events are never lost, and old lines are history, not news.
  • A wrong password is never retried until you sign in again, so Home Assistant can't lock out the operator.
  • The controller has the final say. If it refuses, Home Assistant agrees with it.

PINs for arming and disarming are Home Assistant's own, separate from the keypad users. Each is stored only as a salted PBKDF2 hash. After 5 wrong PINs in 5 minutes, every PIN is refused for 5 minutes, and reloading the integration doesn't reset that. A PIN can be limited to certain days, hours or a last day, for a cleaner or a tradesperson. Here's how it holds up when things go wrong.

"Force arm away" is pressed on a dashboard where arming needs a PIN.Fixed in 0.4.3

A button can't take a PIN. Before 0.4.3, the force-arm buttons armed anyway, which was a hole in the PIN rule. Now they refuse while arming needs a PIN, and you use the protege_wx.arm action with force: true and a code instead. If you don't require a PIN to arm, nothing changed.

Someone tries PINs on the wall tablet.PIN guard

After the fifth wrong PIN in five minutes, every PIN is refused for five minutes, even the right one: Too many wrong PINs. The All areas panel checks a PIN once, so one wrong guess counts once, not once per area.

A visitor unlock is running when Home Assistant restarts.Visitor unlock

A visitor unlock holds a door open for 15 minutes (or as long as you choose) and then locks it. The relock time is saved, so it still locks after a restart. Reloading or removing the integration locks the door straight away. If the door won't lock after three tries, Repairs says so until it does.

Someone changes the operator's password on the controller.Login guard

The next login is rejected, and the client stops trying after at most two attempts. Home Assistant asks you to sign in again, instead of hammering the controller until the operator is locked out for everyone.

One poll is lost to a Wi-Fi hiccup.Honest states

Up to two failed polls in a row keep the last readings, so one dropped request doesn't blank the whole house. On the third, everything goes unavailable rather than showing old states as current. After 15 minutes unreachable, Repairs tells you.

"Turn on all switches" in the Kitchen.Apple Home · Voice

Hold open and Arm when ready are configuration switches, so they're left out of the HomeKit Bridge and voice assistants by default. Turning on a whole room or device can't hold every door open or arm the house.

The keypad user enters a duress code.Emergency

The log line is recognised wherever the word appears in the action (but not in a name like "Panic Room"), and raised as an emergency: a protege_wx_emergency event, a persistent notification and a critical Repairs alert that stays until someone marks it handled.

One rule is about the network rather than the code. The web interface is plain HTTP. The password never crosses it, but anyone who can see traffic on the network can see the requests and could tamper with them. So the controller and Home Assistant belong on a trusted network, ideally a separate one for security devices, and the web interface should never be reachable from the internet.

Living with it

Once it could arm and disarm reliably, the features grew out of using it every day:

  • Every part of the system. An alarm panel per area with Away, Home, Night and Holidays; a lock and a Hold open switch per door; motion, door and window sensors per zone; bypass selectors; trouble inputs and an Alarm fault sensor; switches for outputs.
  • Arm-failure feedback. Whether you armed from Home Assistant or a keypad, a refused arm says which zones were open.
  • Arm when ready. Turn it on and the area arms the moment the last window shuts, or gives up after 30 minutes and tells you what was still open.
  • An alarm card. Quiet and simple: the state, one line about what matters now (open zones, the exit countdown, what set it off), the modes in one row, a round phone-style PIN pad, and recent activity. It follows your theme, light or dark, and ships with the integration.
  • Apple Home. Through the HomeKit Bridge, the panel, the locks and the sensors appear in the Home app, with Away, Home and Night in the right places.
  • Voice. Ask Assist Is the house armed?, Can I arm? (Not yet: Living and Kitchen are open, but you can arm it in home mode.) or Who came in last?
  • Automations. Triggers for Access granted, Door forced or left open, Area failed to arm and emergencies, a "ready to arm" condition, and blueprints for notifications with a camera snapshot, auto-arming when everyone's left, and a door unlock schedule.
  • An alarm history calendar of armed periods, alarms and failures, and a Last seen sensor for each person who badges in.
  • Lockdown. New in 0.9.0, protege_wx.lockdown locks every door on every controller, carrying on past one that won't lock.

It's also ready for Home Assistant's Marketplace in 2026.11, and found automatically when the controller gets its address by DHCP.

Where it's at

The integration is at v0.9.0, and the library, split out in 0.8.0 so other projects can use it, is aioprotegewx 0.1.2 on PyPI. It runs at my parents' house every day:

  • Arms, disarms and unlocks on a real WX with web interface 2.3.x, about once a second, with no licence.
  • Confirms every arm, and names the open zones when one is refused.
  • Shows who did what, from keypads, cards, PINs and Home Assistant users.
  • Works in Apple Home, by voice and on a wall tablet with the alarm card.
  • Keeps a single session on the controller, and logs out whenever it stops.

Both projects are fully typed and tested against a fake controller that speaks both protocols with the real cryptography and reproduces the real controller's log lines, including refusing to arm with a zone open. Every push is checked on the oldest supported Home Assistant (2025.6) and the latest.

One thing I'm careful to say plainly: it's been tested on one real controller. The older GET protocol is written for and tested against the simulated controller only. If you have a WX on older firmware, a compatibility report would help a lot.

Which integration should you use?

There's another Protege integration, ICT Protege by caboose014, and the two are made to sit side by side. If your WX only offers its web interface over HTTPS (firmware 4.00.1676 or later can be set that way), or has the Automation and Control licence, use theirs: with the licence, the panel pushes changes instantly and checks codes itself. If it's plain HTTP, like ours, use this one. Their project inspired mine, and it credits this one in return.

What's next

  • Setting the controller's clock. The drift check only warns for now, because I haven't captured the web interface command that sets the time.
  • The controller's own users and cards. Reading them needs the web interface's user records, which I haven't captured yet either.
  • More controllers. Reports from other WX controllers, especially on older web interfaces, so the GET protocol can be marked as tested on real hardware.

The controller's own lockdown mode isn't on the list: the web interface has no command for it, which is why protege_wx.lockdown locks each door with its own command instead.

Install from the Marketplace (Home Assistant 2026.11 and later) or HACS, create an operator for Home Assistant with a 15-minute session timeout and only the permissions it needs, and add the integration with the web interface's address. The docs cover setup, every entity, the card, automations and troubleshooting. Both projects are MIT licensed.

Thank you to Mitchell Johnson, whose protege-wx-cli worked out the protocol this builds on, and to caboose014, whose ICT Protege integration inspired this one. ICT and Protege are trademarks of Integrated Control Technology; this project isn't affiliated with or endorsed by ICT.