Skip to content

Commit

Permalink
Rename to disambiguate from Ring doorbell module
Browse files Browse the repository at this point in the history
  • Loading branch information
parnic committed Sep 3, 2023
1 parent a4c97c6 commit 61a74c9
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
14 changes: 7 additions & 7 deletions MMM-Ring.js → MMM-RingAlarm.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* Magic Mirror
* Module: MMM-Ring
* Module: MMM-RingAlarm
*
* By parnic https://github.com/parnic/MMM-Ring
* By parnic https://github.com/parnic/MMM-RingAlarm
* MIT Licensed.
*/

Module.register('MMM-Ring',{
Module.register('MMM-RingAlarm',{
defaults: {
refreshToken: undefined,
pins: undefined, // array of arrays, e.g. [[1,2,3,4], [0,0,0,0]],
Expand Down Expand Up @@ -63,7 +63,7 @@ Module.register('MMM-Ring',{
this.showKeypad(true);
return;
} else {
Log.info('MMM-Ring: no PIN required to disarm or no pins specified in config - disarming alarm');
Log.info('MMM-RingAlarm: no PIN required to disarm or no pins specified in config - disarming alarm');
}

this.setAlarmMode(this.desiredMode);
Expand All @@ -75,7 +75,7 @@ Module.register('MMM-Ring',{
this.showKeypad(true);
return;
} else {
Log.info('MMM-Ring: no PIN required to arm or no pins specified in config - arming alarm home');
Log.info('MMM-RingAlarm: no PIN required to arm or no pins specified in config - arming alarm home');
}

this.setAlarmMode(this.desiredMode);
Expand Down Expand Up @@ -160,15 +160,15 @@ Module.register('MMM-Ring',{
const startIdx = this.pressedButtons.length - pin.length;
const endIdx = startIdx + pin.length;
if (this.pressedButtons.slice(startIdx, endIdx).every((val, idx) => val === pin[idx])) {
Log.info(`MMM-Ring: matched PIN, changing alarm mode to ${this.desiredMode}`);
Log.info(`MMM-RingAlarm: matched PIN, changing alarm mode to ${this.desiredMode}`);
this.showKeypad(false);
this.setAlarmMode(this.desiredMode);
this.pressedButtons.length = 0;
return;
}
}

Log.info('MMM-Ring: no PINs matched entered sequence. Doing nothing.');
Log.info('MMM-RingAlarm: no PINs matched entered sequence. Doing nothing.');
},

setAlarmMode: function(mode) {
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# MMM-ScreenLogic
# MMM-RingAlarm

[MagicMirror²](https://github.com/MichMich/MagicMirror) module used to connect to Ring alarms. The current status of the alarm is displayed, and pressing the button allows changing the alarm mode (arming/disarming) optionally protected with a code.

## Installation

1. Navigate into your MagicMirror's `modules` folder and execute `git clone https://github.com/parnic/MMM-Ring.git`
2. `cd MMM-Ring`
1. Navigate into your MagicMirror's `modules` folder and execute `git clone https://github.com/parnic/MMM-RingAlarm.git`
2. `cd MMM-RingAlarm`
3. Execute `npm install --production` to install the node dependencies. Note: Node 18+ is required.
4. Execute `npm run auth` and follow the instructions. Copy the resulting refresh token you receive for the config in the next step.
5. Add the module inside `config.js` placing it where you prefer. Make sure to set the refreshToken property to the one given by the previous step.
Expand All @@ -23,7 +23,7 @@ Here is an example of an entry in config.js

```js
{
module: 'MMM-Ring',
module: 'MMM-RingAlarm',
header: 'Ring alarm',
position: 'top_left',
config: {
Expand Down
16 changes: 8 additions & 8 deletions node_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = NodeHelper.create({
this.config = payload;
if (!this.config || !this.config.refreshToken) {
this.sendSocketNotification('RING_INVALID_CONFIG');
Log.error('MMM-Ring: unable to connect - no refresh token provided');
Log.error('MMM-RingAlarm: unable to connect - no refresh token provided');
return;
}

Expand Down Expand Up @@ -61,7 +61,7 @@ module.exports = NodeHelper.create({
} );
} catch(e) {
this.sendSocketNotification('RING_CONNECT_FAILED', e);
Log.error(`MMM-Ring: unable to connect - error thrown when connecting: ${e}`);
Log.error(`MMM-RingAlarm: unable to connect - error thrown when connecting: ${e}`);
return;
}

Expand All @@ -86,36 +86,36 @@ module.exports = NodeHelper.create({
}

if (this.alarmMode !== data.mode) {
Log.log(`MMM-Ring: mode changed. was ${this.alarmMode}, is ${data.mode}`);
Log.log(`MMM-RingAlarm: mode changed. was ${this.alarmMode}, is ${data.mode}`);
this.alarmMode = data.mode;
this.sendSocketNotification('RING_ALARM_MODE_CHANGED', this.alarmMode);
}
});

this.sendSocketNotification('RING_ALARM_MODE_CHANGED', this.panel.data.mode);
} else {
Log.warn('MMM-Ring: no security panel detected - unable to do anything.');
Log.warn('MMM-RingAlarm: no security panel detected - unable to do anything.');
this.sendSocketNotification('RING_NO_PANEL_DETECTED');
}
}
},

setAlarmMode: function(state) {
if (!this.location) {
Log.error(`MMM-Ring: attempted to set alarm to state ${state} but no location has been retrieved to set it on.`);
Log.error(`MMM-RingAlarm: attempted to set alarm to state ${state} but no location has been retrieved to set it on.`);
return;
}

if (state !== 'all' && state !== 'some' && state !== 'none') {
Log.error(`MMM-Ring: unrecognized alarm mode: ${state}, ignoring.`);
Log.error(`MMM-RingAlarm: unrecognized alarm mode: ${state}, ignoring.`);
return;
}

this.location.setAlarmMode(state);
},

refreshTokenUpdated: async function({newRefreshToken, oldRefreshToken}) {
Log.log('MMM-Ring: Refresh Token Updated: ', newRefreshToken);
Log.log('MMM-RingAlarm: Refresh Token Updated: ', newRefreshToken);

if (!oldRefreshToken) {
return;
Expand All @@ -134,7 +134,7 @@ module.exports = NodeHelper.create({
}

const status = connected ? 'Connected to' : 'Disconnected from';
Log.log(`MMM-Ring: **** ${status} location ${location.name} - ${location.id}`);
Log.log(`MMM-RingAlarm: **** ${status} location ${location.name} - ${location.id}`);

return retval;
}
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "mmm-ring",
"name": "mmm-ringalarm",
"version": "1.0.0",
"description": "Show status from Ring alarms and control armed status",
"main": "MMM-Ring.js",
"main": "MMM-RingAlarm.js",
"author": "parnic",
"repository": "https://github.com/parnic/MMM-Ring.git",
"repository": "https://github.com/parnic/MMM-RingAlarm.git",
"license": "MIT",
"type": "commonjs",
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions ring.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.MMM-Ring .btn {
.MMM-RingAlarm .btn {
min-width: 150px;
}

.MMM-Ring .module-content {
.MMM-RingAlarm .module-content {
margin-left: 20px;
margin-right: 20px;
}
Expand Down

0 comments on commit 61a74c9

Please sign in to comment.