Door Policy Code Schema

OnlyCat provides a code view for developers to define advanced Door Policies, which govern how the cat flap responds to events.

We’re publishing the JSON Schema for Door Policies below, with further examples and documentation to follow in due course.

At their core, Door Policies consist of an array of rules – much like firewall rules. Each rule has a criteria, and possible actions.

How it works

On every frame, the current state of the cat flap is matched against the defined rules. If a rule matches (eg. a specific cat is attempting to enter), the associated actions will execute (eg. let the cat in and play a sound).

Rule priority

For as long as a rule is matching, the rules below it will not be evaluated – so the actions that are invoked are the ones associated with the first matched rule. For example, if a rule is defined to block entry with contraband, rules below which allow entry for a specific cat will not run, unless contraband is no longer being detected.

Wait State

Some criteria, eg. rfidCode or eventClassification will cause rule execution to be suspended until the relevant information is available, for example if rfidCode is specified the cat flap will await a microchip to be scanned, before a decision can be made whether to run the rule’s actions or proceed to matching rules below it.

				
					{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Transit Policy Schema",
  "type": "object",
  "properties": {
    "transitPolicy": {
      "type": "object",
      "properties": {
        "idleLock": {
          "type": "boolean",
          "description": "Indicates if the device should be locked when idle."
        },
        "rules": {
          "type": "array",
          "description": "List of rules to evaluate transit events.",
          "items": {
            "type": "object",
            "properties": {
              "criteria": {
                "type": "object",
                "properties": {
                  "eventTriggerSource": {
                    "description": "Event trigger source(s) to match.",
                    "anyOf": [
                      {
                        "type": "integer",
                        "enum": [0, 1, 2, 3],
                        "description": "Possible values: 0 (MANUAL), 1 (REMOTE), 2 (INDOOR_MOTION), 3 (OUTDOOR_MOTION)."
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "integer",
                          "enum": [0, 1, 2, 3]
                        },
                        "description": "Array of event trigger sources."
                      }
                    ]
                  },
                  "eventClassification": {
                    "description": "Event classification(s) to match.",
                    "anyOf": [
                      {
                        "type": "integer",
                        "enum": [0, 1, 2, 3, 4, 10],
                        "description": "Possible values: 0 (UNKNOWN), 1 (CLEAR), 2 (SUSPICIOUS), 3 (CONTRABAND), 4 (HUMAN_ACTIVITY), 10 (REMOTE_UNLOCK)."
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "integer",
                          "enum": [0, 1, 2, 3, 4, 10]
                        },
                        "description": "Array of event classifications."
                      }
                    ]
                  },
                  "rfidCode": {
                    "description": "RFID code(s) to match.",
                    "anyOf": [
                      { "type": "string" },
                      {
                        "type": "array",
                        "items": { "type": "string" }
                      }
                    ]
                  },
                  "rfidTimeout": {
                    "type": "integer",
                    "description": "Timeout in milliseconds to wait for an RFID code."
                  },
                  "timeRange": {
                    "description": "Time range(s) during which the rule is active (e.g., '08:00-18:00').",
                    "anyOf": [
                      { "type": "string" },
                      {
                        "type": "array",
                        "items": { "type": "string" }
                      }
                    ]
                  }
                },
                "additionalProperties": false
              },
              "action": {
                "type": "object",
                "properties": {
                  "lock": {
                    "type": "boolean",
                    "description": "Determines whether to lock (true) or unlock (false) the device."
                  },
                  "sound": {
                    "type": "string",
                    "description": "Sound to play when the rule matches."
                  }
                },
                "additionalProperties": false
              }
            },
            "required": ["criteria", "action"],
            "additionalProperties": false
          }
        }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}
				
			

Leave a Reply

Your email address will not be published. Required fields are marked *

Stay connected. Feel relieved.

Learn more about the OnlyCat microchip cat flap with prey detection. App enabled, with video notifications, OnlyCat puts you in control and stops the delivery of unwanted gifts.

Subscribe for updates

Enter your email below to keep up to date with all the latest news on our:

  • Production schedule
  • App enhancements
  • Firmware updates

 

Plus more content from our feline friends!