Skip to content

Commit ad14abe

Browse files
committed
### 1.2.0 (2020-02-10)
* (MK-2001) Sending of FS20 cmdRAW possible or via sendTo as described in the readme * (Bluefox) Refactoring
1 parent 4f55b63 commit ad14abe

File tree

9 files changed

+3655
-1816
lines changed

9 files changed

+3655
-1816
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ ioBroker adapter to control FS20, Max!, HMS and other devices via [CUL](http://b
2626
This command uses the CUL Library of this adapter to send the command to a FS20 Device.
2727

2828
## Changelog
29-
### 1.1.1 (2020-02-10)
29+
### 1.2.0 (2020-02-10)
3030
* (MK-2001) Sending of FS20 cmdRAW possible or via sendTo as described in the readme
31+
* (Bluefox) Refactoring
3132

3233
### 1.1.0 (2020-01-04)
3334
* (foxriver76) removed usage of adapter.objects

admin/index.html

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,14 @@
88
<link rel="stylesheet" type="text/css" href="../../css/adapter.css"/>
99
<script type="text/javascript" src="../../js/translate.js"></script>
1010
<script type="text/javascript" src="../../js/adapter-settings.js"></script>
11+
<script type="text/javascript" src="words.js"></script>
1112

1213
<style>
1314
.value {
1415
width: 250px;
1516
}
1617
</style>
1718
<script type="text/javascript">
18-
systemDictionary = {
19-
"CUL adapter settings": {
20-
"en": "CUL adapter settings",
21-
"de": "CUL Adapter Einstellungen",
22-
"ru": "Настройки CUL Драйвера"
23-
},
24-
"Serial port:": {"en": "Serial port:", "de": "Serialport:", "ru": "Порт:"},
25-
"Baud rate": {"en": "Baud rate:", "de": "Baud rate:", "ru": "Скорость:"},
26-
"Mode": {"en": "Mode", "de": "Modus:", "ru": "Режим:"},
27-
"Type:": {"en": "Type:", "de": "Typ:", "ru": "Тип:"},
28-
"Select port": {"en": "Select port", "de": "Port auswählen", "ru": "Select port"},
29-
"IP/Hostname:": {"en": "IP/Hostname:", "de": "IP/Hostname:", "ru": "IP/Hostname:"},
30-
"Port": {"en": "Port:", "de": "Port:", "ru": "Port:"},
31-
"Experimental:": {"en": "Experimental:", "de": "Experimentiermodus:","ru": "экспериментальный:"},
32-
};
33-
3419
var timeout;
3520

3621
function getComPorts(actualValue) {
@@ -104,10 +89,7 @@
10489
onChange(false);
10590
}
10691

107-
// ... and the function save has to exist.
108-
// you have to make sure the callback is called with the settings object as first param!
10992
function save(callback) {
110-
// example: select elements with class=value and build settings object
11193
var obj = {};
11294
$('.value').each(function () {
11395
var $this = $(this);
@@ -180,11 +162,11 @@
180162

181163
<tr>
182164
<td><label for="ip" class="translate">IP/Hostname:</label></td>
183-
<td><input id="ip" class="value" value="127.0.0.1"></input></td>
165+
<td><input id="ip" class="value" value="127.0.0.1"/></td>
184166
</tr>
185167
<tr>
186168
<td><label for="port" class="translate">Port:</label></td>
187-
<td><input id="port" class="value" value="23"></input></td>
169+
<td><input id="port" class="value" value="23"/></td>
188170
</tr>
189171
<tr>
190172
<td><label for="experimental" class="translate">Experimental:</label></td>

admin/index_m.html

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
<html>
2+
<head>
3+
<!-- Materialze style -->
4+
<link rel="stylesheet" type="text/css" href="../../css/adapter.css"/>
5+
<link rel="stylesheet" type="text/css" href="../../lib/css/materialize.css">
6+
7+
<script type="text/javascript" src="../../lib/js/jquery-3.2.1.min.js"></script>
8+
<script type="text/javascript" src="../../socket.io/socket.io.js"></script>
9+
10+
<script type="text/javascript" src="../../js/translate.js"></script>
11+
<script type="text/javascript" src="../../lib/js/materialize.js"></script>
12+
<script type="text/javascript" src="../../js/adapter-settings.js"></script>
13+
<script type="text/javascript" src="words.js"></script>
14+
15+
<script type="text/javascript">
16+
var timeout;
17+
var count;
18+
var gOnChange;
19+
20+
function getComPorts(actualValue) {
21+
count++;
22+
if (count < 10) {
23+
timeout = setTimeout(function () {
24+
getComPorts(actualValue);
25+
}, 2000);
26+
}
27+
28+
sendTo(null, 'listUart', null, function (list) {
29+
if (timeout) {
30+
clearTimeout(timeout);
31+
timeout = null;
32+
}
33+
if ((!list || !list.length) && count < 10) {
34+
setTimeout(function () {
35+
getComPorts(actualValue);
36+
}, 1000);
37+
return;
38+
}
39+
if (!list || !list.length) {
40+
$('#_serialport').html('<input id="serialport" type="text" class="value" value="' + actualValue + '" placeholder="' + _('Not ports found') + '"/><label class="translate" for="serialport">Serial port</label>');
41+
$('#serialport').change(gOnChange).on('keyup', gOnChange);
42+
M.updateTextFields();
43+
} else {
44+
var text = '<option value="">' + _('Select port') + '</option>';
45+
var $serialport = $('#serialport');
46+
47+
for (var j = 0; j < list.length; j++) {
48+
if (list[j].comName === 'Not available') {
49+
text += '<option value="" selected>' + _('Not available') + '</option>';
50+
$serialport.prop('disabled', true);
51+
break;
52+
} else {
53+
text += '<option value="' + list[j].comName + '" ' + ((actualValue === list[j].comName) ? 'selected' : '') + '>' + list[j].comName + '</option>';
54+
}
55+
}
56+
$serialport.html(text).select();
57+
}
58+
});
59+
}
60+
61+
function load(settings, onChange) {
62+
settings.type = settings.type || 'cul';
63+
gOnChange = onChange;
64+
65+
for (var key in settings) {
66+
if (!settings.hasOwnProperty(key)) continue;
67+
var $value = $('#' + key + '.value');
68+
// example: select elements with id=key and class=value and insert value
69+
if ($value.attr('type') === 'checkbox') {
70+
$value.prop('checked', settings[key]).on('change', function () {
71+
onChange();
72+
});
73+
} else {
74+
$value.val(settings[key]).on('change', function () {
75+
var id = $(this).attr('id');
76+
if (id === 'type') {
77+
if ($(this).val() === 'cul') {
78+
$('#baudrate').val('9600');
79+
} else {
80+
$('#baudrate').val('38400');
81+
}
82+
}
83+
onChange();
84+
}).on('keyup', onChange);
85+
}
86+
}
87+
88+
getIsAdapterAlive(function (isAlive) {
89+
if (isAlive || common.enabled) {
90+
getComPorts(settings.serialport);
91+
} else {
92+
$('#_serialport').html('<input id="serialport" type="text" class="value" value="' + settings.serialport + '"/><label class="translate" for="serialport">Serial port</label>');
93+
$('#serialport').change(onChange).on('keyup', onChange);
94+
M.updateTextFields();
95+
}
96+
});
97+
98+
// Signal to admin, that no changes yet
99+
onChange(false);
100+
}
101+
102+
function save(callback) {
103+
var obj = {};
104+
$('.value').each(function () {
105+
var $this = $(this);
106+
if ($this.attr('type') === 'checkbox') {
107+
obj[$this.attr('id')] = $this.prop('checked');
108+
} else {
109+
obj[$this.attr('id')] = $this.val();
110+
}
111+
});
112+
callback(obj);
113+
}
114+
</script>
115+
</head>
116+
<body>
117+
<div class="m adapter-container">
118+
<div class="row">
119+
<div class="row">
120+
<div class="col s12 m4 l2">
121+
<img src="busware.jpg" alt="logo" class="logo"/>
122+
</div>
123+
</div>
124+
<div class="row">
125+
<div class="input-field col s10 m4" id="_serialport">
126+
<select id="serialport" class="value"></select>
127+
<label class="translate" for="serialport">Serial port</label>
128+
</div>
129+
<div class="input-field col s10 m2">
130+
<select id="baudrate" class="value">
131+
<option value="110">110</option>
132+
<option value="150">150</option>
133+
<option value="300">300</option>
134+
<option value="600">600</option>
135+
<option value="1200">1200</option>
136+
<option value="2400">2400</option>
137+
<option value="4800">4800</option>
138+
<option value="9600">9600</option>
139+
<option value="19200">19200</option>
140+
<option value="38400">38400</option>
141+
<option value="56000">56000</option>
142+
<option value="57600">57600</option>
143+
<option value="115200">115200</option>
144+
</select>
145+
<label class="translate" for="baudrate">Baud rate</label>
146+
</div>
147+
</div>
148+
<div class="row">
149+
<div class="input-field col s10 m4">
150+
<select id="mode" class="value">
151+
<option value="SlowRF">SlowRF - (FS20, HMS, FHT, EM, ESA, ...)</option>
152+
<option value="MORITZ">MORITZ - (MAX! devices)</option>
153+
<option value="AskSin">AskSin - (HomeMatic devices)</option>
154+
</select>
155+
<label class="translate" for="mode">Mode</label>
156+
</div>
157+
<div class="input-field col s10 m2">
158+
<select id="type" class="value">
159+
<option value="cul">CUL</option>
160+
<option value="coc">COC</option>
161+
<option value="scc">SCC</option>
162+
<option value="cuno">CUNO</option>
163+
</select>
164+
<label class="translate" for="type">Type</label>
165+
</div>
166+
</div>
167+
<div class="row">
168+
<div class="input-field col s6 m4">
169+
<input id="ip" class="value" value="127.0.0.1" type="text"/>
170+
<label class="translate" for="ip">IP/Hostname</label>
171+
</div>
172+
<div class="input-field col s4 m2">
173+
<input id="port" class="value" value="23" type="number" min="1" max="65536"/>
174+
<label class="translate" for="port">Port</label>
175+
</div>
176+
</div>
177+
<div class="row">
178+
<div class="input-field col s10 m4">
179+
<input id="experimental" class="value" type="checkbox"/>
180+
<span class="translate" for="experimental">Experimental</span>
181+
</div>
182+
</div>
183+
</div>
184+
</div>
185+
</body>
186+
</html>

admin/words.js

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

io-package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"common": {
33
"name": "cul",
4-
"version": "1.1.1",
4+
"version": "1.2.0",
55
"news": {
6-
"1.1.1": {
6+
"1.2.0": {
77
"en": "Sending of FS20 cmdRAW possible or via sendTo as described in the readme.",
88
"de": "Senden von FS20 cmdRAW möglich oder über sendTo wie in der Readme beschrieben.",
99
"ru": "Отправка FS20 cmdRAW возможна или через sendTo, как описано в файле readme.",
@@ -79,6 +79,8 @@
7979
"license": "GPL-2.0",
8080
"enabled": true,
8181
"messagebox": true,
82+
"materialize": true,
83+
"compact": true,
8284
"icon": "busware.jpg",
8385
"extIcon": "https://raw.githubusercontent.com/ioBroker/ioBroker.cul/master/admin/busware.jpg",
8486
"keywords": [

0 commit comments

Comments
 (0)