Configuration¶
Configuration of the machine-access-control (MAC) server is accomplished by some JSON configuration files and optional environment variables, as detailed below.
users.json¶
Users are configured via a users.json file in the current directory, or another file name/path specified in the USERS_CONFIG environment variable. This file defines all of the users and their contact information, as well as their RFID fob code(s) and the authorizations/trainings they have. If using the Neon One CRM, this file can be auto-generated from your CRM Accounts via the NeonOne Integration.
Each user may optionally include an oops_override boolean field (defaults to false). When set to true, the user can activate machines that are oopsed or locked out without clearing those states. This is intended for designated repair members who need to test machines without generating confusing Slack notifications. Existing users.json files without this field remain fully compatible.
The schema of this file is as follows:
type |
array |
|||
items |
type |
object |
||
properties |
||||
|
List of fob codes for user. |
|||
type |
array |
|||
items |
type |
string |
||
|
Unique Account ID for user. |
|||
type |
string |
|||
|
Full name of user. |
|||
type |
string |
|||
|
First name of user. |
|||
type |
string |
|||
|
Last name of user. |
|||
type |
string |
|||
|
Preferred name of user. |
|||
type |
string |
|||
|
User email address. |
|||
type |
string |
|||
|
User membership expiration in YYYY-MM-DD format. |
|||
type |
string |
|||
|
List of authorized field names for user. |
|||
type |
array |
|||
items |
type |
string |
||
|
Whether user can perform override logins on oopsed/locked-out machines. |
|||
type |
boolean |
|||
additionalProperties |
False |
|||
machines.json¶
Machines are configured via a machines.json file in the current directory, or another file name/path specified in the MACHINES_CONFIG environment variable. This file lists all of the supported/configured machines and which authorization(s) are required to use them. Note that the names in this file must match the names configured in your ESPHome Hardware. Machine names must be unqiue and can only contain alphanumeric characters, underscores, and dashes. No spaces, no dots.
Each machine configuration supports an optional alias field, which provides a human-friendly name for the machine. When present, the alias will be used in Slack messages and log output instead of the machine name. Both the machine name and alias can be used in incoming Slack commands.
The schema of this file is as follows:
type |
object |
||||
patternProperties |
|||||
|
Unique machine name, alphanumeric _ and - only. |
||||
type |
object |
||||
properties |
|||||
|
List of authorizations required to operate machine, any one of which is sufficient. |
||||
type |
array |
||||
items |
type |
string |
|||
|
If set, allow anyone to operate machine but log and display a warning if the operator is not authorized. |
||||
type |
boolean |
||||
|
If set, machine is always enabled and does not require RFID authentication. Displays ‘Always On’ and relay is always on unless Oopsed or Locked. |
||||
type |
boolean |
||||
|
Optional human-friendly alias for the machine. Used in Slack messages and logs instead of the machine name. |
||||
type |
string |
||||
|
type |
object |
|||
properties |
|||||
|
List of authorizations any one of which is sufficient to energize the second relay. Must be non-empty. |
||||
type |
array |
||||
items |
type |
string |
|||
minItems |
1 |
||||
|
If true, the second relay energizes for primary-authorized operators lacking secondary auth, with a warning emitted to logs and Slack. |
||||
type |
boolean |
||||
|
If true, the second relay tracks the primary relay’s energized state regardless of operator’s secondary authorization. |
||||
type |
boolean |
||||
|
Human-readable name for the accessory governed by the second relay. |
||||
type |
string |
||||
minLength |
1 |
||||
additionalProperties |
False |
||||
additionalProperties |
False |
||||
Second Relay (second_relay) — Optional¶
Each machine entry may optionally include a second_relay block to enable an additional output relay (driven by GPIO14 / V1 connector pin 6) gated on a separate authorization. This is useful for machines that have an accessory (for example a laser cutter rotary attachment) that requires its own training.
The second relay only energizes when (a) the primary relay is already energized for the current operator AND (b) the operator additionally satisfies the second_relay rules.
The block accepts the following options:
authorizations_or(required, non-empty list of strings) — operator must hold any one of these to energize the second relayunauthorized_warn_only(optional bool, defaultfalse) — energize the second relay even for primary-authorized operators lacking the secondary auth, but emit a warning log + Slack messagealways_enabled(optional bool, defaultfalse) — second relay tracks the primary relay’s energized state regardless of operator’s secondary authorizationalias(optional string) — human-readable name for the accessory governed by the second relay; used in Slack/log lines that refer specifically to second-relay events
The LCD content is intentionally not modified by second_relay configuration; operators learn the accessory state from the physical accessory itself.
Example:
{
"laser_cutter": {
"authorizations_or": ["laser_basic"],
"alias": "Laser Cutter",
"second_relay": {
"authorizations_or": ["laser_rotary"],
"alias": "Rotary Attachment"
}
}
}
Adding, removing, or modifying a second_relay block requires a server restart, same as other machines.json changes.
Environment Variables¶
Variable |
Required? |
Description |
|---|---|---|
|
no |
path to users configuration file; default |
|
no |
path to machines configuration file; default |
|
no |
path to machine state directory; default |
|
no |
If using the Slack integration, the Bot User OAuth Token for your installation of the app. |
|
no |
If using the Slack integration, the Socket OAuth Token for your installation of the app. |
|
no |
If using the Slack integration, the Signing Secret for your installation of the app. |
|
no |
If using the Slack integration, the Channel ID of of the private channel for admins to control MAC. |
|
no |
If using the Slack integration, the Channel ID of of the public channel where Oops and maintenance notices will be posted, and where machine status can be checked. |
Machine State Directory¶
During operation, the state of each machine is cached on disk every time it’s updated; this is done to ensure that a restart of the server will not affect running machines. As of this time, state is saved to a separate file for each machine. By default, these are saved in a machine_state subdirectory of the current directory, which is created if it does not exist. An alternate directory to save machine state to can be specified via the MACHINE_STATE_DIR environment variable.