Skip to content

Commit

Permalink
Merge pull request #108 from OrigamiDream/v1.4.4-beta
Browse files Browse the repository at this point in the history
PR v1.4.4-beta to main branch
  • Loading branch information
OrigamiDream authored Aug 29, 2024
2 parents 8dd0264 + 6a73262 commit f821f40
Show file tree
Hide file tree
Showing 13 changed files with 315 additions and 931 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/fetch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Use Node.js 17
- name: Use Node.js 20
uses: actions/setup-node@v3
with:
node-version: '17'
node-version: '20'

- name: Install Packages
run: npm install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: '16.x'
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
- run: npm ci

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16.x'
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- name: Publish on npm.js
Expand Down
26 changes: 15 additions & 11 deletions core/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {Errors, LoginSubTypes, PushSubTypes, PushTypes, SettingSubTypes, SubType
import {Complex} from "./interfaces/complex";
import {setInterval} from "timers";
import Timeout = NodeJS.Timeout;
import fcm, {Credentials} from "push-receiver";
import {MenuItem} from "./interfaces/menu";
import PushReceiver from "@eneris/push-receiver";

export interface PushData {
readonly from: string
Expand Down Expand Up @@ -54,7 +54,7 @@ export class Client {

constructor(private readonly log: Logging,
private readonly config: DaelimConfig,
private readonly credentials: Credentials) {
private readonly push: PushReceiver) {
this.config = config;
this.authorization = {
certification: '00000000',
Expand Down Expand Up @@ -192,7 +192,7 @@ export class Client {
this.sendUnreliableRequest({
dong: this.address.complex,
ho: this.address.room,
pushID: this.credentials.fcm.token,
pushID: this.push.fcmToken,
phoneType: "android"
}, Types.LOGIN, LoginSubTypes.PUSH_REQUEST);

Expand Down Expand Up @@ -269,22 +269,26 @@ export class Client {
}

async prepareService() {
fcm.listen({ ...this.credentials, persistentIds: [] }, (data: any) => {
const orig = data.notification;
this.push.onNotification((notification) => {
const orig = notification.message;
if(!orig || !orig.data) {
return;
}
const pushData: PushData = {
from: orig.from,
priority: orig.priority,
title: orig.data.title,
message: orig.data.message,
reserved: orig.data.data3
from: orig.from!,
priority: orig.priority!,
title: orig.data['title'] as string,
message: orig.data['message'] as string,
reserved: orig.data['data3'] as string,
};
this.log.debug(`<=== PUSH(Type: ${orig.data.data1}, Sub Type: ${orig.data.data2}) :: ${JSON.stringify(pushData)}`);
for(const eventListener of this.pushEventListeners) {
if(eventListener.type === parseInt(orig.data.data1) && eventListener.subType == parseInt(orig.data.data2)) {
if(eventListener.type === parseInt(orig.data['data1'] as string) && eventListener.subType == parseInt(orig.data['data2'] as string)) {
eventListener.callback(pushData);
}
}
});
await this.push.connect();

this.log('Looking for complex info...');
this.complex = await Utils.findMatchedComplex(this.config.region, this.config.complex);
Expand Down
43 changes: 0 additions & 43 deletions core/modules/push-receiver.d.ts

This file was deleted.

3 changes: 3 additions & 0 deletions core/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ export class Utils {
public static PLATFORM_NAME = "DaelimSmartHomePlatform";
public static MANUFACTURER_NAME = "DL E&C Co.,Ltd.";
public static FCM_SENDER_ID = "251248256994";
public static FCM_PROJECT_ID = "daelim-smarthome";
public static FCM_APP_ID = "1:251248256994:android:4f4ccc5221a7b689";
public static FCM_API_KEY = "AIzaSyAm__JwMJS8utB54p36cDxl8lsKu2wHKNI";

public static COMPLEX_URL = "https://raw.githubusercontent.com/OrigamiDream/homebridge-daelim-smarthome/master/complexes/complexes.json";
public static HOMEKIT_SECURE_VIDEO_IDLE_URL = "https://raw.githubusercontent.com/OrigamiDream/homebridge-daelim-smarthome/master/assets/hksv_camera_idle.png";
Expand Down
3 changes: 1 addition & 2 deletions homebridge/accessories/fan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
CharacteristicGetCallback,
CharacteristicSetCallback,
CharacteristicValue,
Formats,
Logging,
PlatformAccessory,
Service
Expand Down Expand Up @@ -84,7 +83,7 @@ export class FanAccessories extends Accessories<FanAccessoryInterface> {
if(this.client?.doesComplexMatch(FAN_SPEED_SUPPORTED_COMPLEXES)) {
service.getCharacteristic(this.api.hap.Characteristic.RotationSpeed)
.setProps({
format: Formats.FLOAT,
format: this.api.hap.Formats.FLOAT,
minValue: 0,
maxValue: 100, // Up to level 3
minStep: FAN_ROTATION_SPEED_UNIT
Expand Down
4 changes: 2 additions & 2 deletions homebridge/accessories/lightbulb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
CharacteristicEventTypes,
CharacteristicGetCallback,
CharacteristicSetCallback,
CharacteristicValue, Formats,
CharacteristicValue,
Logging,
PlatformAccessory,
Service
Expand Down Expand Up @@ -166,7 +166,7 @@ export class LightbulbAccessories extends Accessories<LightbulbAccessoryInterfac
if(accessory.context.brightnessAdjustable) {
service.getCharacteristic(this.api.hap.Characteristic.Brightness)
.setProps({
format: Formats.FLOAT,
format: this.api.hap.Formats.FLOAT,
minValue: 0,
maxValue: 100,
minStep: accessory.context.minSteps
Expand Down
16 changes: 13 additions & 3 deletions homebridge/daelim-smarthome-platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {ElevatorAccessories} from "./accessories/elevator";
import {DoorAccessories} from "./accessories/door";
import {VehicleAccessories} from "./accessories/vehicle";
import {CameraAccessories} from "./accessories/camera";
import fcm, {Credentials} from "push-receiver";
import PushReceiver from "@eneris/push-receiver";

export = (api: API) => {
api.registerPlatform(Utils.PLATFORM_NAME, DaelimSmartHomePlatform);
Expand Down Expand Up @@ -93,8 +93,18 @@ class DaelimSmartHomePlatform implements DynamicPlatformPlugin {
}

// firebase cloud messaging
const credentials = await fcm.register(Utils.FCM_SENDER_ID);
this.client = new Client(this.log, this.config, credentials as Credentials);
const push = new PushReceiver({
debug: false,
persistentIds: [],
firebase: {
apiKey: Utils.FCM_API_KEY,
appId: Utils.FCM_APP_ID,
projectId: Utils.FCM_PROJECT_ID,
messagingSenderId: Utils.FCM_SENDER_ID,
},
credentials: undefined,
})
this.client = new Client(this.log, this.config, push);
await this.client.prepareService();

this.client.registerListeners();
Expand Down
7 changes: 7 additions & 0 deletions logs/v1.4.4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
v1.4.4 — FCM API, Homebridge 2
# CHANGELOGS

### Google의 푸시 시스템 종료로 인한 오동작 수정 버전입니다. 반드시 업데이트 하시기 바랍니다.

- Homebridge 2 대비 변경사항 반영
- 2024년 6월 24일자 GCM API 종료에 따른 신규 API 마이그레이션
Loading

0 comments on commit f821f40

Please sign in to comment.