Skip to content

Commit

Permalink
Add new devices and bump dependencies (#73)
Browse files Browse the repository at this point in the history
Signed-off-by: hxmelab <hxmelab@gmail.com>
  • Loading branch information
hxmelab authored Mar 18, 2024
1 parent 290e05b commit d26ac4e
Show file tree
Hide file tree
Showing 6 changed files with 3,045 additions and 2,870 deletions.
22 changes: 11 additions & 11 deletions nodes/shc-config.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,17 @@
if (state === 'PAIRED') {
RED.notify('Client already paired', 'notice');
} else {
$.get('shc/client', {shcip, clientid,
clientname, password, key, cert})
.done(data => {
if (data === 'PAIRED') {
RED.notify(data, 'notice');
} else {
RED.notify(data, 'error');
}
$.get('shc/client', {
shcip, clientid, clientname, password, key, cert,
}).done(data => {
if (data === 'PAIRED') {
RED.notify(data, 'notice');
} else {
RED.notify(data, 'error');
}

$('#node-config-input-state').val(data);
})
$('#node-config-input-state').val(data);
})
.fail(err => {
RED.notify(err.responseText, 'error');
});
Expand Down Expand Up @@ -171,7 +171,7 @@ <h3>Client Configuration</h3>
</div>

<h3>Pairing</h3>
<div class="form-tips"><b>Hint:</b> Please, first press button on SHC until LEDs flashes before pairing.</div>
<div class="form-tips">Ready to connect? Please activate pairing mode on your SHC first. Then, you can hit the 'Pair' button!</div>
<div style="height:10px;"></div>
<div class="form-row">
<label for="node-config-input-state"><i class="fa fa-handshake-o"></i> State</label>
Expand Down
10 changes: 6 additions & 4 deletions nodes/shc-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,16 @@ module.exports = function (RED) {
if (res && res._parsedResponse && res._parsedResponse && res._parsedResponse.token) {
result.end('PAIRED');
} else {
result.end('ERROR - Please check password');
result.end('Please check your password.');
}
}, err => {
// EPROTO should be SSL alert number 42
if (err.cause && err.cause.code && err.cause.code === 'EPROTO') {
result.end('ERROR - Please longpress button on SHC');
} else if (err.errorType && err.errorType === 2) {
result.end('ERROR - Please check IP of SHC');
result.end('SHC detected, but it’s not ready to connect. Please enable pairing mode on your SHC and try again.');
} else if (err.cause && err.cause.code && err.cause.code === 'EHOSTUNREACH') {
result.end('Unable to reach your device. Please verify the IP address and ensure your device is connected to the network.');
} else if (err.cause && err.cause.code && err.cause.code === 'ECONNREFUSED') {
result.end('Found a device, but it’s not a SHC. Please double-check the IP address and make sure the device is powered on.');
} else {
console.log(err);
result.end('ERROR - Please check logs');
Expand Down
16 changes: 9 additions & 7 deletions nodes/shc-device.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,20 @@
},
paletteLabel: 'device',
oneditprepare() {
const supportedDevices = 'CAMERA_360, CAMERA_EYES, BBL, BSM, '
+ 'INTRUSION_DETECTION_SYSTEM, MD, PSM, PRESENCE_SIMULATION_SERVICE, '
+ 'ROOM_CLIMATE_CONTROL, SD, SWD, TWINGUARD, WRC2, TRV, THB, BWTH, '
+ 'LOGAMATIC_WEB_KM200, HEATING_CIRCUIT, HUE_LIGHT_ROOM_CONTROL,'
+ 'HUE_LIGHT,LEDVANCE_LIGHT,PLUG_COMPACT,SWD2,SWD2_PLUS,WLS';
const supportedDevices = 'CAMERA_360,CAMERA_EYES,BBL,BSM,'
+ 'INTRUSION_DETECTION_SYSTEM,MD,PSM,PRESENCE_SIMULATION_SERVICE,'
+ 'ROOM_CLIMATE_CONTROL,SD,SWD,TWINGUARD,WRC2,TRV,THB,BWTH,'
+ 'LOGAMATIC_WEB_KM200,HEATING_CIRCUIT,HUE_LIGHT_ROOM_CONTROL,'
+ 'HUE_LIGHT,LEDVANCE_LIGHT,PLUG_COMPACT,SWD2,SWD2_PLUS,WLS,TRV_GEN2,'
+ 'SMOKE_DETECTOR2,CAMERA_INDOOR_GEN2,OUTDOOR_SIRENE,RTH2_BAT,RTH2_230';
const supportedServices = 'AirQualityLevel,BatteryLevel,HumidityLevel,'
+ 'IntrusionDetectionControl,Keypad,LatestMotion,'
+ 'PowerMeter,PowerSwitch,PresenceSimulationConfiguration,'
+ 'PrivacyMode,CameraNotification,CameraLight,RoomClimateControl,ShutterContact, '
+ 'PrivacyMode,CameraNotification,CameraLight,RoomClimateControl,ShutterContact,'
+ 'ShutterControl,SmokeDetectorCheck,TemperatureLevel,ValveTappet,'
+ 'MultiLevelSwitch,HSBColorActuator,HueColorTemperature,HueBlinkingActuator,'
+ 'BinarySwitch,VibrationSensor,WaterLeakageSensor,WaterLeakageSensorTilt';
+ 'BinarySwitch,VibrationSensor,WaterLeakageSensor,WaterLeakageSensorTilt,'
+ 'Alarm,CommunicationQuality,ChildProtection,BlindsControl,SilentMode';

const deviceBoxId = '#node-input-device';
const deviceBoxText = '<input type="text" id="node-input-device" placeholder="Select a device" style="width: 100%;">';
Expand Down
2 changes: 1 addition & 1 deletion nodes/shc-device.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ module.exports = function (RED) {
setMsgObject(data) {
const msg = {topic: (this.name || this.deviceName), room: this.roomName};
if (this.serviceId && this.state) {
if (data.state && Object.prototype.hasOwnProperty.call(data.state, this.state)) {
if (data.state && Object.hasOwn(data.state, this.state)) {
msg.payload = this.convertState(data.state[this.state]);
} else {
return null;
Expand Down
Loading

0 comments on commit d26ac4e

Please sign in to comment.