Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .homeycompose/capabilities/identify.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"type": "boolean",
"title": {
"en": "Identify",
"nl": "Identificeren"
},
"getable": false,
"setable": true,
"uiComponent": "button",
"insights": false,
"icon": "assets/magnify.svg"
}
19 changes: 18 additions & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,7 @@
"local"
],
"capabilities": [
"identify",
"measure_power",
"meter_gas",
"meter_water",
Expand Down Expand Up @@ -1113,6 +1114,7 @@
"capabilities": [
"onoff",
"dim",
"identify",
"locked",
"measure_power",
"meter_power",
Expand Down Expand Up @@ -1226,6 +1228,7 @@
"local"
],
"capabilities": [
"identify",
"measure_power",
"meter_gas",
"meter_water",
Expand Down Expand Up @@ -1820,6 +1823,7 @@
"local"
],
"capabilities": [
"identify",
"meter_power.import",
"meter_power.export",
"measure_battery",
Expand Down Expand Up @@ -2026,6 +2030,7 @@
"local"
],
"capabilities": [
"identify",
"measure_water",
"meter_water",
"rssi"
Expand Down Expand Up @@ -2270,6 +2275,18 @@
"nl": "cycli"
}
},
"identify": {
"type": "boolean",
"title": {
"en": "Identify",
"nl": "Identificeren"
},
"getable": false,
"setable": true,
"uiComponent": "button",
"insights": false,
"icon": "assets/magnify.svg"
},
"long_power_fail_count": {
"type": "number",
"title": {
Expand Down Expand Up @@ -2587,4 +2604,4 @@
]
}
}
}
}
1 change: 1 addition & 0 deletions assets/magnify.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions drivers/energy/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ module.exports = class HomeWizardEnergyDevice extends Homey.Device {
this._flowTriggerImport = this.homey.flow.getDeviceTriggerCard('import_changed');
this._flowTriggerExport = this.homey.flow.getDeviceTriggerCard('export_changed');

this.registerCapabilityListener('identify', async (value) => {
await this.onIdentify();
});
}

flowTriggerTariff(device, tokens) {
Expand Down Expand Up @@ -54,6 +57,19 @@ module.exports = class HomeWizardEnergyDevice extends Homey.Device {
this.onPoll();
}

async onRequest(body) {
if (!this.url) return;

const res = await fetch(`${this.url}/state`, {
method: 'PUT',
body: JSON.stringify(body),
headers: { 'Content-Type': 'application/json' },
}).catch(this.error);

if (!res.ok)
{ throw new Error(res.statusText); }
}

onPoll() {
if (!this.url) return;

Expand Down Expand Up @@ -101,6 +117,10 @@ module.exports = class HomeWizardEnergyDevice extends Homey.Device {
promises.push(this.addCapability('tariff').catch(this.error));
}

if (!this.hasCapability('identify')) {
await this.addCapability('identify').catch(this.error);
}

// Update values
if (this.getCapabilityValue('measure_power') != data.active_power_w)
{ promises.push(this.setCapabilityValue('measure_power', data.active_power_w).catch(this.error)); }
Expand Down
3 changes: 2 additions & 1 deletion drivers/energy/driver.compose.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"local"
],
"capabilities": [
"identify",
"measure_power",
"meter_gas",
"meter_water",
Expand Down Expand Up @@ -213,4 +214,4 @@
"template": "add_devices"
}
]
}
}
20 changes: 20 additions & 0 deletions drivers/energy_socket/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ module.exports = class HomeWizardEnergySocketDevice extends Homey.Device {
await this.onRequest({ power_on: value });
});

this.registerCapabilityListener('identify', async (value) => {
await this.onIdentify();
});

this.registerCapabilityListener('dim', async (value) => {
await this.onRequest({ brightness: (255 * value) });
});
Expand Down Expand Up @@ -74,6 +78,18 @@ module.exports = class HomeWizardEnergySocketDevice extends Homey.Device {
{ throw new Error(res.statusText); }
}

async onIdentify() {
if (!this.url) return;

const res = await fetch(`${this.url}/identify`, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
}).catch(this.error);

if (!res.ok)
{ throw new Error(res.statusText); }
}

onPoll() {
if (!this.url) return;

Expand Down Expand Up @@ -200,6 +216,10 @@ module.exports = class HomeWizardEnergySocketDevice extends Homey.Device {
await this.addCapability('dim').catch(this.error);
}

if (!this.hasCapability('identify')) {
await this.addCapability('identify').catch(this.error);
}

if (!this.hasCapability('locked')) {
await this.addCapability('locked').catch(this.error);
}
Expand Down
3 changes: 2 additions & 1 deletion drivers/energy_socket/driver.compose.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"capabilities": [
"onoff",
"dim",
"identify",
"locked",
"measure_power",
"meter_power",
Expand Down Expand Up @@ -111,4 +112,4 @@
"template": "add_devices"
}
]
}
}
26 changes: 26 additions & 0 deletions drivers/energy_v2/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ module.exports = class HomeWizardEnergyDeviceV2 extends Homey.Device {
this._flowTriggerImport = this.homey.flow.getDeviceTriggerCard('import_changed');
this._flowTriggerExport = this.homey.flow.getDeviceTriggerCard('export_changed');

this.registerCapabilityListener('identify', async (value) => {
await this.onIdentify();
});
}

flowTriggerTariff(device, tokens) {
Expand Down Expand Up @@ -55,6 +58,24 @@ module.exports = class HomeWizardEnergyDeviceV2 extends Homey.Device {
this.onPoll();
}

async onIdentify() {
if (!this.url) return;

const token = this.getStoreValue('token');

const res = await fetch(`${this.url}/api/system/identify`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`,
},
agent: new (require('https').Agent)({ rejectUnauthorized: false }), // Ignore SSL errors
}).catch(this.error);

if (!res.ok)
{ throw new Error(res.statusText); }
}

onPoll() {

const httpsAgent = new https.Agent({
Expand Down Expand Up @@ -83,6 +104,11 @@ module.exports = class HomeWizardEnergyDeviceV2 extends Homey.Device {

const promises = []; // Capture all await promises

// identify
if (!this.hasCapability('identify')) {
await this.addCapability('identify').catch(this.error);
}

// Save export data check if capabilities are present first
if (!this.hasCapability('measure_power')) {
promises.push(this.addCapability('measure_power').catch(this.error));
Expand Down
3 changes: 2 additions & 1 deletion drivers/energy_v2/driver.compose.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"local"
],
"capabilities": [
"identify",
"measure_power",
"meter_gas",
"meter_water",
Expand Down Expand Up @@ -210,4 +211,4 @@
"template": "add_devices"
}
]
}
}
27 changes: 27 additions & 0 deletions drivers/plugin_battery/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ module.exports = class HomeWizardPluginBattery extends Homey.Device {

async onInit() {
this.onPollInterval = setInterval(this.onPoll.bind(this), POLL_INTERVAL);

this.registerCapabilityListener('identify', async (value) => {
await this.onIdentify();
});
}

onDeleted() {
Expand Down Expand Up @@ -38,6 +42,24 @@ module.exports = class HomeWizardPluginBattery extends Homey.Device {
this.onPoll();
}

async onIdentify() {
if (!this.url) return;

const token = this.getStoreValue('token');

const res = await fetch(`${this.url}/api/system/identify`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`,
},
agent: new (require('https').Agent)({ rejectUnauthorized: false }), // Ignore SSL errors
}).catch(this.error);

if (!res.ok)
{ throw new Error(res.statusText); }
}

onPoll() {

const httpsAgent = new https.Agent({
Expand Down Expand Up @@ -81,6 +103,11 @@ module.exports = class HomeWizardPluginBattery extends Homey.Device {

// Save export data check if capabilities are present first

// identify
if (!this.hasCapability('identify')) {
await this.addCapability('identify').catch(this.error);
}

// energy_import_kwh
if (data.energy_import_kwh !== undefined) {
if (!this.hasCapability('meter_power.import')) {
Expand Down
3 changes: 2 additions & 1 deletion drivers/plugin_battery/driver.compose.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"local"
],
"capabilities": [
"identify",
"meter_power.import",
"meter_power.export",
"measure_battery",
Expand Down Expand Up @@ -89,4 +90,4 @@
"template": "add_devices"
}
]
}
}
20 changes: 20 additions & 0 deletions drivers/watermeter/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ module.exports = class HomeWizardEnergyWatermeterDevice extends Homey.Device {

async onInit() {
this.onPollInterval = setInterval(this.onPoll.bind(this), POLL_INTERVAL);

this.registerCapabilityListener('identify', async (value) => {
await this.onIdentify();
});
}

onDeleted() {
Expand Down Expand Up @@ -37,6 +41,18 @@ module.exports = class HomeWizardEnergyWatermeterDevice extends Homey.Device {
this.onPoll();
}

async onIdentify() {
if (!this.url) return;

const res = await fetch(`${this.url}/identify`, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
}).catch(this.error);

if (!res.ok)
{ throw new Error(res.statusText); }
}

onPoll() {
if (!this.url) return;

Expand Down Expand Up @@ -72,6 +88,10 @@ module.exports = class HomeWizardEnergyWatermeterDevice extends Homey.Device {
await this.addCapability('meter_water').catch(this.error);
}

if (!this.hasCapability('identify')) {
await this.addCapability('identify').catch(this.error);
}

if (!this.hasCapability('rssi')) {
await this.addCapability('rssi').catch(this.error);
}
Expand Down
3 changes: 2 additions & 1 deletion drivers/watermeter/driver.compose.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"local"
],
"capabilities": [
"identify",
"measure_water",
"meter_water",
"rssi"
Expand Down Expand Up @@ -85,4 +86,4 @@
"template": "add_devices"
}
]
}
}
Loading