Skip to content

Commit 27c7a08

Browse files
committed
First SDKv3 version
1 parent d0bfc6f commit 27c7a08

File tree

18 files changed

+145
-151
lines changed

18 files changed

+145
-151
lines changed

.homeychangelog.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,8 @@
3131
},
3232
"0.0.13": {
3333
"en": "Fixed bug with smartmeter and 3-phase (#10)"
34+
},
35+
"0.1.0": {
36+
"en": "Update to SDKv3"
3437
}
3538
}

.homeycompose/app.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
{
22
"id": "com.thomashoussin.fronius",
3-
"version": "0.0.13",
4-
"compatibility": ">=3.1.0",
5-
"sdk": 2,
3+
"version": "0.1.0",
4+
"compatibility": ">=5.0.0",
5+
"sdk": 3,
66
"name": {
77
"en": "Fronius"
88
},
99
"description": {
1010
"en": "Taking your energy supply in your own hands"
1111
},
12+
"brandColor": "#ED1C24",
1213
"tags": {
1314
"en": [
1415
"fronius",

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Feel free to donate to support the project !
1616
[<img src="https://www.paypalobjects.com/en_GB/i/btn/btn_donate_SM.gif">](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=RVBS24SPLU922&currency_code=EUR)
1717

1818
# Version History
19+
### 0.1.0:
20+
- Update to SDKv3
1921
### 0.0.13:
2022
- Fixed bug for 3-phase SmartMeter
2123
### 0.0.12:

app.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
{
22
"_comment": "This file is generated. Please edit .homeycompose/app.json instead.",
33
"id": "com.thomashoussin.fronius",
4-
"version": "0.0.13",
5-
"compatibility": ">=3.1.0",
6-
"sdk": 2,
4+
"version": "0.1.0",
5+
"compatibility": ">=5.0.0",
6+
"sdk": 3,
77
"name": {
88
"en": "Fronius"
99
},
1010
"description": {
1111
"en": "Taking your energy supply in your own hands"
1212
},
13+
"brandColor": "#ED1C24",
1314
"tags": {
1415
"en": [
1516
"fronius",

drivers/fronius-powerflow/device.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class PowerFlow extends FroniusDevice {
3535
this.setCapabilityValue('measure_power', pgrid + pakku);
3636
}
3737

38-
async onSettings(oldSettings, newSettings, changedKeys) {
38+
async onSettings({ oldSettings, newSettings, changedKeys }) {
3939
this.log('PowerFlow settings where changed');
4040
this.setEnergy({ cumulative: newSettings.cumulative });
4141
}

drivers/fronius-powerflow/driver.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,21 @@ class FroniusPowerFlow extends Homey.Driver {
1313
this.log('FroniusPowerFlow has been initialized');
1414
}
1515

16-
onPair(socket) {
17-
var devices;
18-
19-
socket.on('validate', function (data, callback) {
16+
onPair(session) {
17+
session.setHandler('validate', async function (data) {
2018
console.log("Validate new connection settings");
2119
let ip = data.host;
2220

2321
const validationUrl = `http://${ip}${checkPath}`;
2422
console.log(validationUrl);
2523

26-
fetch(validationUrl)
24+
return fetch(validationUrl)
2725
.then(checkResponseStatus)
2826
.then(res => {
29-
callback(false, 'ok')
27+
return 'ok';
3028
})
3129
.catch(error => {
32-
callback(new Error(Homey.__('ip_error')));
30+
return error;
3331
});
3432
});
3533
}
@@ -39,9 +37,9 @@ module.exports = FroniusPowerFlow;
3937

4038
function checkResponseStatus(res) {
4139
if (res.ok) {
42-
return res;
40+
return res
4341
} else {
4442
console.log(`Wrong response status : ${res.status} (${res.statusText})`);
45-
callback(new Error(Homey.__('ip_error')));
43+
throw new Error(`Wrong response status : ${res.status} (${res.statusText})`);
4644
}
4745
}

drivers/fronius-powerflow/pair/enter_values.html

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,30 @@
99
Homey.alert('Please fill in all fields');
1010
}
1111
else {
12+
Homey.emit('validate', { "host": hostname })
13+
.then(result => {
14+
if (result == 'ok') {
15+
let deviceDefinition = {
16+
name,
17+
data: {},
18+
settings: { ip: hostname }
19+
};
1220

13-
Homey.emit('validate', {
14-
"host": hostname
15-
}, (err, result) => {
16-
if (!err) {
17-
let deviceDefinition = {
18-
name,
19-
data: {},
20-
settings: { ip: hostname }
21-
};
22-
23-
Homey.createDevice(deviceDefinition, (error, result) => {
24-
if (error) {
25-
Homey.alert(error);
26-
} else {
27-
Homey.done();
28-
}
29-
});
30-
31-
} else {
32-
Homey.alert(err);
33-
}
34-
});
21+
Homey.createDevice(deviceDefinition)
22+
.then(function (result) {
23+
Homey.done();
24+
})
25+
.catch(error => {
26+
Homey.alert(error);
27+
});
28+
}
29+
else {
30+
Homey.alert('Error : unable to connect');
31+
}
32+
})
33+
.catch(error => {
34+
Homey.alert(error);
35+
});
3536
}
3637
}
3738

drivers/inverter/pair/enter_ip.html

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,19 @@
55
let hostname = document.getElementById('hostname').value;
66
if(!hostname){
77
Homey.alert('Please fill in all fields');
8-
}else {
9-
10-
Homey.emit('validate', {
11-
"host": hostname,
12-
}, (err, result) => {
13-
if (!err) {
14-
Homey.nextView();
15-
} else {
16-
Homey.alert(err);
17-
}
18-
});
8+
}
9+
else {
10+
Homey.emit('validate', {"host": hostname })
11+
.then(result => {
12+
if (result == 'ok' ) {
13+
Homey.nextView();
14+
} else {
15+
Homey.alert('Unable to connect');
16+
}
17+
})
18+
.catch(error => {
19+
Homey.alert(error);
20+
});
1921
}
2022
}
2123

drivers/ohmpilot/pair/enter_ip.html

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,24 @@
55
let hostname = document.getElementById('hostname').value;
66
if(!hostname){
77
Homey.alert('Please fill in all fields');
8-
}else {
9-
10-
Homey.emit('validate', {
11-
"host": hostname,
12-
}, (err, result) => {
13-
if (!err) {
14-
Homey.nextView();
15-
} else {
16-
Homey.alert(err);
17-
}
18-
});
8+
}
9+
else {
10+
Homey.emit('validate', {"host": hostname })
11+
.then(result => {
12+
if (result == 'ok' ) {
13+
Homey.nextView();
14+
} else {
15+
Homey.alert('Unable to connect');
16+
}
17+
})
18+
.catch(error => {
19+
Homey.alert(error);
20+
});
1921
}
2022
}
2123

2224
</script>
2325

2426
<label for="hostname">Hostname/IP address</label>
2527
<input type="text" id="hostname" name="hostname" placeholder="IP/hostname" required/><br />
26-
<button type="button" onclick="doSubmit()">Save</button>
28+
<button type="button" onclick="doSubmit()">Save</button>

drivers/reporting/device.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ class Reporting extends Homey.Device {
257257
* @param {string[]} event.changedKeys An array of keys changed since the previous version
258258
* @returns {Promise<string|void>} return a custom message that will be displayed
259259
*/
260-
async onSettings(oldSettings, newSettings, changedKeys) {
260+
async onSettings({ oldSettings, newSettings, changedKeys }) {
261261
this.log('Reporting settings where changed');
262262
this.emit('updateCapabilities');
263263
}

0 commit comments

Comments
 (0)