A module for parsing and generating messages for the Elk M1 security system.
Fully* implements the Elk M1 RS232 ASCII protocol revision 1.84 (Feb 26, 2016).
*Section 4.3 describes a message called "Send ASCII String To IP Address", with the command "AP". Upper-case commands are supposed to be responses from the M1, but the documentation for this makes it sound like this is a command that can be sent to the M1. I've decided to include it as a response, but haven't fully implemented it because of the unclear documentation.
Install with NPM or Yarn
npm install elk-message
// or
yarn add elk-message
import {
Arm,
ArmingLevel,
EthernetModuleTest,
UnknownElkResponse,
parse,
} from 'elk-message';
// Parse a message
const message = parse('16XK2636115020605110006F\r\n');
if (message instanceof EthernetModuleTest) {
// EthernetModuleTest is sent every 30 seconds by the M1
console.log(`M1 ping @ ${message.date}`);
} else if (message instanceof UnknownElkResponse) {
console.warn(`Recieved unknown command "${message.command}" from M1!`);
}
// Create a message to arm area 1 using code "3456"
const arm = new Arm(ArmingLevel.ArmedAway, 1, '3456');
The base interface for all messages sent to or received from the Elk M1 implement ElkMessage.
Messages are either "commands" (ElkCommand) sent to the control panel, or "responses"
(ElkResponse) received from it.
See the API documentation for more details on each type of message. Each message in the documentation also includes the section in the protocol specification document where it is officially documented.
Commands are instantiated directly with specific parameters depending on the type of command. Some commands expect the control panel to return a response, others do not.
AlarmByZoneRequestAlarmReportAcknowledgeAlarmReportTestAcknowledgeArmArmingStatusRequestAudioCommandIncomingAudioDataRequestControlOutputOffControlOutputOnControlOutputStatusRequestControlOutputToggleCounterValueReadCounterValueWriteCustomValueReadCustomValueWriteCustomValuesReadAllDisplayTextOnScreenElkCommandEthernetModuleTestAcknowledgeInsteonLightingDeviceProgramRequestInsteonLightingDeviceStatusRequestKeypadAreaAssigmentsRequestKeypadFunctionKeyPressRequestKeypadFunctionKeyStatusRequestLightingDeviceStatusRequestOmnistat2RequestPlcDeviceControlPlcDeviceOffPlcDeviceOnPlcDeviceStatusRequestPlcDeviceToggleRealTimeClockDataRequestRealTimeClockDataWriteSpeakPhraseSpeakWordSystemLogDataReadRequestSystemLogDataWriteRequestSystemTroubleStatusRequestTaskActivationTemperatureDataRequestTemperatureRequestTextDescriptionRequestThermostatDataRequestThermostatSetThermostatSetCoolSetPointThermostatSetFanThermostatSetHeatSetPointThermostatSetHoldThermostatSetModeUserCodeAreasRequestUserCodeChangeRequestVersionNumberRequestZoneBypassRequestZoneDefinitionRequestZonePartitionRequestZoneStatusRequestZoneTriggerZoneVoltageRequestResponses are parsed from their raw packet data (as described in section 4 of the specification document.
A parse function is exported that will parse a packet and return it's associated response.
import { parse } from 'elk-message';
const dataPacket = '16XK2636115020605110006F';
// parse will return an instance of `EthernetModuleTest`
const ethernetModuleTest = parse(dataPacket);
assert(ethernetModuleTest instanceof EthernetModuleTest);
The parse function will return a UnknownElkResponse if the response type was unknown or could not
be determined for some reason (malformed packet, undocumented response, etc...)
AlarmByZoneReportAlarmMemoryUpdateAlarmReportAlarmReportTestArmingStatusReportAudioCommandOutgoingAudioDataReplyControlOutputStatusReportCounterValueReplyCustomValueReplyElkResponseElkRPConnectedEmailSendTriggerEntryExitTimerEthernetModuleResetEthernetModuleTestInstallerModeExitedInsteonLightingDeviceProgrammedInsteonLightingDeviceStatusReplyKeypadAreaAssignmentsKeypadFunctionKeyPressReplyKeypadKeyChangeLightingDeviceDataReplyOmnistat2ReplyOutputChangeUpdatePlcChangeUpdatePlcDeviceStatusReplyRealTimeClockDataReplySendASCIIStringToIPAddressSystemLogDataUpdateSystemTroubleStatusReplyTaskChangeUpdateTemperatureDataTemperatureReplyTextDescriptionReplyThermostatDataUnknownElkResponseUserCodeAreasReplyUserCodeChangeReplyUserCodeEntryVersionNumberReplyZoneBypassReplyZoneChangeUpdateZoneDefinitionDataZonePartitionReportZoneStatusReportZoneVoltageDataThe number of characters used to represent the packet length in a message packet.
A regex expression that parses a raw message packet and captures:
The default reserved characters for a message packet.
The number of characters used to represent the reserved portion of a message packet.
The message termination characters
Matches on a user-entered code.
Calculates the checksum for an elk message.
Encodes selected area numbers.
Two ASCII Hex characters, 0-9,A-F, using the Hex value of each character as the mask for 4 areas. Right most character is areas 1 to 4 with bit 0 equal to Area 1.
An array of area numbers to encode
The area numbers encoded as hex.
Converts a number to it's hexadecimal notation equivalent.
The number to convert.
The number of characters to pad the result to.
A hexidecimal string representing the number provided.
Returns the two's complement of a value between 0 and 255.
The value to calculate the two's compliment for.
The two's complement of the value.
Generated using TypeDoc
The number of characters used to represent the checksum in a message packet.
4.1.6