Skip to content

Commit e588266

Browse files
committed
Renamed Contact icon (preparation for custom icon)
Fixed possible counter icon issue
1 parent 5f666c1 commit e588266

File tree

12 files changed

+65
-24
lines changed

12 files changed

+65
-24
lines changed

hardware/plugins/Plugins.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1946,7 +1946,7 @@ namespace Plugins {
19461946
szTypeImage = "doorbell48";
19471947
break;
19481948
case STYPE_Contact:
1949-
szTypeImage = "contact48";
1949+
szTypeImage = "Contact48";
19501950
break;
19511951
case STYPE_Blinds:
19521952
case STYPE_BlindsPercentage:

main/WebServer.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8941,6 +8941,11 @@ namespace http {
89418941
}
89428942
else if (switchtype == STYPE_Contact)
89438943
{
8944+
if (CustomImage == 0)
8945+
{
8946+
root["result"][ii]["Image"] = "Contact";
8947+
}
8948+
89448949
root["result"][ii]["TypeImg"] = "contact";
89458950
bool bIsOn = IsLightSwitchOn(lstatus);
89468951
if (bIsOn) {

notifications/NotificationHelper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ bool CNotificationHelper::CheckAndHandleSwitchNotification(
10181018
break;
10191019
case STYPE_Contact:
10201020
notValue = "Open";
1021-
szExtraData += "Image=contact48_open|";
1021+
szExtraData += "Image=Contact48_On|";
10221022
break;
10231023
case STYPE_DoorContact:
10241024
notValue = "Open";

notifications/NotificationKodi.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ std::string CNotificationKodi::GetIconFile(const std::string &ExtraData)
131131
szTypeImage = "doorbell48";
132132
break;
133133
case STYPE_Contact:
134-
szTypeImage = "contact48";
134+
szTypeImage = "Contact48";
135135
break;
136136
case STYPE_Blinds:
137137
case STYPE_BlindsPercentage:

www/app/DashboardController.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -672,10 +672,10 @@ define(['app'], function (app) {
672672
}
673673
else if (item.SwitchType == "Contact") {
674674
if (item.Status == 'Closed') {
675-
img = '<a href="#/Devices/' + item.idx + '/Log"><img src="images/contact48.png" class="lcursor" height="40" width="40"></a>';
675+
img = '<a href="#/Devices/' + item.idx + '/Log"><img src="images/' + item.Image + '48_Off.png" class="lcursor" height="40" width="40"></a>';
676676
}
677677
else {
678-
img = '<a href="#/Devices/' + item.idx + '/Log"><img src="images/contact48_open.png" class="lcursor" height="40" width="40"></a>';
678+
img = '<a href="#/Devices/' + item.idx + '/Log"><img src="images/' + item.Image + '48_On.png" class="lcursor" height="40" width="40"></a>';
679679
}
680680
}
681681
else if ((item.SwitchType == "Blinds") || (item.SwitchType.indexOf("Venetian Blinds") == 0)) {
@@ -2497,10 +2497,10 @@ define(['app'], function (app) {
24972497
}
24982498
else if (item.SwitchType == "Contact") {
24992499
if (item.Status == 'Closed') {
2500-
xhtm += '\t <td id="img" class="img img1"><a href="#/Devices/' + item.idx + '/Log"><img src="images/contact48.png" class="lcursor" height="40" width="40"></a></td>\n';
2500+
xhtm += '\t <td id="img" class="img img1"><a href="#/Devices/' + item.idx + '/Log"><img src="images/' + item.Image + '48_Off.png" class="lcursor" height="40" width="40"></a></td>\n';
25012501
}
25022502
else {
2503-
xhtm += '\t <td id="img" class="img img1"><a href="#/Devices/' + item.idx + '/Log"><img src="images/contact48_open.png" class="lcursor" height="40" width="40"></a></td>\n';
2503+
xhtm += '\t <td id="img" class="img img1"><a href="#/Devices/' + item.idx + '/Log"><img src="images/' + item.Image + '48_On.png" class="lcursor" height="40" width="40"></a></td>\n';
25042504
}
25052505
}
25062506
else if (item.SwitchType == "Media Player") {
@@ -3742,7 +3742,7 @@ define(['app'], function (app) {
37423742
imagehtml = '<a href="#/Devices/' + item.idx + '/Log"><img src="images/Water48_On.png" class="lcursor" height="40" width="40"></a></td>\n';
37433743
}
37443744
else if (item.SwitchTypeVal == 3) {
3745-
imagehtml = '<a href="#/Devices/' + item.idx + '/Log"><img src="images/Counter48.png.png" class="lcursor" height="40" width="40"></a></td>\n';
3745+
imagehtml = '<a href="#/Devices/' + item.idx + '/Log"><img src="images/Counter48.png" class="lcursor" height="40" width="40"></a></td>\n';
37463746
}
37473747
else if (item.SwitchTypeVal == 4) {
37483748
imagehtml = '<a href="#/Devices/' + item.idx + '/Log"><img src="images/PV48.png" class="lcursor" height="40" width="40"></a></td>\n';

www/app/DeviceLightEdit.js

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ define(['app', 'components/rgbw-picker/RgbwPicker'], function (app) {
77
},
88
controller: function ($element, domoticzApi) {
99
var vm = this;
10-
var icons = [];
11-
10+
var switch_icons = [];
11+
1212
vm.$onInit = function () {
1313
// TODO: Add caching mechanism for this request
1414
domoticzApi.sendRequest({
1515
type: 'custom_light_icons'
1616
}).then(function (data) {
17-
icons = (data.result || []).map(function (item) {
17+
switch_icons = (data.result || []).map(function (item) {
1818
return {
1919
text: item.text,
2020
value: item.idx,
@@ -25,7 +25,7 @@ define(['app', 'components/rgbw-picker/RgbwPicker'], function (app) {
2525
});
2626

2727
$element.find('#icon-select').ddslick({
28-
data: icons,
28+
data: switch_icons,
2929
width: 260,
3030
height: 390,
3131
selectText: 'Select Switch Icon',
@@ -41,7 +41,7 @@ define(['app', 'components/rgbw-picker/RgbwPicker'], function (app) {
4141
vm.ngModelCtrl.$render = function () {
4242
var value = vm.ngModelCtrl.$modelValue;
4343

44-
icons.forEach(function (item, index) {
44+
switch_icons.forEach(function (item, index) {
4545
if (item.value === value) {
4646
$element.find('#icon-select').ddslick('select', { index: index });
4747
}
@@ -468,6 +468,7 @@ define(['app', 'components/rgbw-picker/RgbwPicker'], function (app) {
468468
vm.isOffActionAvailable = isOffActionAvailable;
469469
vm.isColorSettingsAvailable = isColorSettingsAvailable;
470470
vm.isWhiteSettingsAvailable = isWhiteSettingsAvailable;
471+
vm.updateSwitchType = updateSwitchType;
471472

472473
init();
473474

@@ -575,7 +576,7 @@ define(['app', 'components/rgbw-picker/RgbwPicker'], function (app) {
575576
}
576577

577578
function isSwitchIconAvailable() {
578-
return [0, 7, 17, 18].includes(vm.device.SwitchTypeVal);
579+
return [0, 2, 7, 17, 18].includes(vm.device.SwitchTypeVal);
579580
}
580581

581582
function isLevelsAvailable() {
@@ -589,5 +590,41 @@ define(['app', 'components/rgbw-picker/RgbwPicker'], function (app) {
589590
function isWhiteSettingsAvailable() {
590591
return vm.device.SubType === 'White';
591592
}
593+
594+
function updateSwitchType() {
595+
//need to change default icon (with value 0) to the correct icon based on vm.device.SwitchTypeVal
596+
/*
597+
if (switchtype==0) {
598+
//On/Off
599+
} else if (switchtype == 1) {
600+
//Doorbell
601+
} else if (switchtype == 2) {
602+
//Contact
603+
} else if (switchtype == 7) {
604+
//Dimmer
605+
} else if (switchtype == 9) {
606+
//Push On
607+
} else if (switchtype == 10) {
608+
//Push Off
609+
} else if (switchtype == 11) {
610+
//Door Contact
611+
} else if (switchtype == 17) {
612+
//Media
613+
} else if (switchtype == 18) {
614+
//Selector
615+
} else if (switchtype == 19) {
616+
//Door Lock
617+
} else if (switchtype == 20) {
618+
//Door Lock Inverted
619+
}
620+
621+
switch_icons.forEach(function (item, index) {
622+
if (item.value === 0) {
623+
item.imageSrc = 'images/' + imageSrc + '.png';
624+
}
625+
});
626+
627+
*/
628+
}
592629
});
593630
});

www/app/LightsController.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,10 +425,10 @@ define(['app'], function (app) {
425425
}
426426
else if (item.SwitchType == "Contact") {
427427
if (item.Status == 'Closed') {
428-
img = '<img src="images/contact48.png" height="48" width="48">';
428+
img = '<img src="images/' + item.Image + '48_Off.png" height="48" width="48">';
429429
}
430430
else {
431-
img = '<img src="images/contact48_open.png" height="48" width="48">';
431+
img = '<img src="images/' + item.Image + '48_On.png" height="48" width="48">';
432432
}
433433
}
434434
else if ((item.SwitchType == "Blinds") || (item.SwitchType.indexOf("Venetian Blinds") == 0)) {
@@ -998,10 +998,10 @@ define(['app'], function (app) {
998998
}
999999
else if (item.SwitchType == "Contact") {
10001000
if (item.Status == 'Closed') {
1001-
xhtm += '\t <td id="img"><img src="images/contact48.png" height="48" width="48"></td>\n';
1001+
xhtm += '\t <td id="img"><img src="images/' + item.Image + '48_Off.png" height="48" width="48"></td>\n';
10021002
}
10031003
else {
1004-
xhtm += '\t <td id="img"><img src="images/contact48_open.png" height="48" width="48"></td>\n';
1004+
xhtm += '\t <td id="img"><img src="images/' + item.Image + '48_On.png" height="48" width="48"></td>\n';
10051005
}
10061006
bAddTimer = false;
10071007
}

www/html5.appcache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ images/Computer48_Off.png
130130
images/Computer48_On.png
131131
images/contact.png
132132
images/contact_open.png
133-
images/contact48.png
134-
images/contact48_open.png
133+
images/Contact48_Off.png
134+
images/Contact48_On.png
135135
images/copy.png
136136
images/copy_hover.png
137137
images/counter.png
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)