Skip to content

Commit

Permalink
Merge pull request #27 from burnacid/feature/heating
Browse files Browse the repository at this point in the history
Feature/heating
  • Loading branch information
burnacid authored Dec 25, 2020
2 parents 381b6f2 + d17043e commit c8f03b2
Show file tree
Hide file tree
Showing 12 changed files with 837 additions and 52 deletions.
10 changes: 9 additions & 1 deletion .homeychangelog.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{
"0.4.1": {
"en": "Adding sensor for heating",
"nl": "Sensor toegevoegd voor verwarming"
},
"0.4.0": {
"en": "Adding sensor for heating",
"nl": "Sensor toegevoegd voor verwarming"
},
"0.3.3": {
"en": "Corrected unit on daily water usage",
"nl": "Correcte meetwaarde weergeven voor dagelijks water gebruik"
Expand Down Expand Up @@ -31,4 +39,4 @@
"en": "First beta release.",
"nl": "Eerste beta versie."
}
}
}
231 changes: 191 additions & 40 deletions app.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "com.burnacid.ztatz",
"version": "0.3.3",
"version": "0.4.1",
"compatibility": ">=3.2.0",
"sdk": 2,
"brandColor": "#384042",
Expand Down Expand Up @@ -33,11 +33,11 @@
},
"contributors": {
"developers": [
{
"name": "FalkeMichel"
}
{
"name": "FalkeMichel"
}
]
},
},
"capabilities": {
"money": {
"type": "number",
Expand All @@ -58,54 +58,54 @@
"tariff_high": {
"type": "boolean",
"title": {
"en": "High Tariff",
"nl": "Piektarief"
"en": "High Tariff",
"nl": "Piektarief"
},
"desc": {
"en": "True when in high tariff period. False when in low tariff period",
"nl": "Gaat aan wanneer in piektarief en uit wanneer in daltarief"
"en": "True when in high tariff period. False when in low tariff period",
"nl": "Gaat aan wanneer in piektarief en uit wanneer in daltarief"
},
"insights": true,
"insightsTitleTrue": {
"en": "In high tariff period",
"nl": "In piektarief periode"
"en": "In high tariff period",
"nl": "In piektarief periode"
},
"insightsTitleFalse": {
"en": "In low tariff period",
"nl": "In daltarief periode"
"en": "In low tariff period",
"nl": "In daltarief periode"
},
"getable": true,
"setable": false,
"icon": "/assets/highlow.svg",
"uiComponent": "sensor",
"$flow": {
"triggers": [
{
"id": "tariff_high_true",
"title": {
"en": "The high tariff period has started",
"nl": "Het piektarief is begonnen"
}
},
{
"id": "tariff_high_false",
"title": {
"en": "The low tariff period has started",
"nl": "Het daltarief is begonnen"
}
}
],
"conditions": [
{
"id": "tariff_high",
"title": {
"en": "!{{High|Low}} tariff period",
"nl": "!{{Piek|Dal}}tarief periode"
}
}
]
"triggers": [
{
"id": "tariff_high_true",
"title": {
"en": "The high tariff period has started",
"nl": "Het piektarief is begonnen"
}
},
{
"id": "tariff_high_false",
"title": {
"en": "The low tariff period has started",
"nl": "Het daltarief is begonnen"
}
}
],
"conditions": [
{
"id": "tariff_high",
"title": {
"en": "!{{High|Low}} tariff period",
"nl": "!{{Piek|Dal}}tarief periode"
}
}
]
}
}
}
},
"drivers": [
{
Expand Down Expand Up @@ -606,6 +606,85 @@
"large": "/drivers/ztatz_p1_FinancialMonth/assets/images/large.jpg",
"small": "/drivers/ztatz_p1_FinancialMonth/assets/images/small.jpg"
}
},
{
"id": "ztatz_p1_Heating",
"name": {
"en": "P1 Heating",
"nl": "P1 Verwarming"
},
"class": "other",
"capabilities": [
"measure_temperature.in",
"measure_temperature.out",
"measure_temperature.delta"
],
"capabilitiesOptions": {
"measure_temperature.in": {
"title": {
"nl": "Verwarming temperatuur IN",
"en": "Heating temperature IN"
},
"decimals": 3,
"color": "#e8cf40"
},
"measure_temperature.out": {
"title": {
"nl": "Verwarming temperatuur OUT",
"en": "Heating temperature OUT"
},
"decimals": 3,
"color": "#c2ad38"
},
"measure_temperature.delta": {
"title": {
"nl": "Delta temperatuur",
"en": "Delta temperature"
},
"decimals": 3,
"color": "#c2ad38"
}
},
"settings": [
{
"type": "group",
"label": {
"en": "General Info",
"nl": "Algemene Info"
},
"children": [
{
"id": "url",
"type": "label",
"label": {
"en": "URL",
"nl": "URL"
},
"value": ""
}
]
}
],
"pair": [
{
"id": "start"
},
{
"id": "list_devices",
"template": "list_devices",
"navigation": {
"next": "add_devices"
}
},
{
"id": "add_devices",
"template": "add_devices"
}
],
"images": {
"large": "/drivers/ztatz_p1_Heating/assets/images/large.jpg",
"small": "/drivers/ztatz_p1_Heating/assets/images/small.jpg"
}
}
],
"flow": {
Expand Down Expand Up @@ -873,7 +952,79 @@
"filter": "driver_id=ztatz_p1_Usage"
}
]
},
{
"id": "measure_temperature.in.changed",
"title": {
"nl": "Verwarming temperatuur IN is veranderd",
"en": "Heating temperature IN has changed"
},
"tokens": [
{
"name": "measure_temperature.in.temperature",
"type": "number",
"title": {
"en": "Temperature",
"nl": "Temperatuur"
}
}
],
"args": [
{
"name": "ChangedTempIn",
"type": "device",
"filter": "driver_id=ztatz_p1_Heating"
}
]
},
{
"id": "measure_temperature.out.changed",
"title": {
"nl": "Verwarming temperatuur OUT is veranderd",
"en": "Heating temperature OUT has changed"
},
"tokens": [
{
"name": "measure_temperature.out.temperature",
"type": "number",
"title": {
"en": "Temperature",
"nl": "Temperatuur"
}
}
],
"args": [
{
"name": "ChangedTempOut",
"type": "device",
"filter": "driver_id=ztatz_p1_Heating"
}
]
},
{
"id": "measure_temperature.delta.changed",
"title": {
"nl": "Delta temperatuur is veranderd",
"en": "Delta temperature has changed"
},
"tokens": [
{
"name": "measure_temperature.delta.temperature",
"type": "number",
"title": {
"en": "Temperature",
"nl": "Temperatuur"
}
}
],
"args": [
{
"name": "ChangedTempDelta",
"type": "device",
"filter": "driver_id=ztatz_p1_Heating"
}
]
}
]
}
}
}
7 changes: 7 additions & 0 deletions drivers/ztatz_p1_Heating/assets/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added drivers/ztatz_p1_Heating/assets/images/large.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added drivers/ztatz_p1_Heating/assets/images/small.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
80 changes: 80 additions & 0 deletions drivers/ztatz_p1_Heating/device.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
'use strict';

const Homey = require('homey');
const Device = require('../../lib/Device.js');
const boolean = require('boolean');

const refreshTimeout = 1000 * 30; // 30 sec

module.exports = class ztatzP1HeatingDevice extends Device {

// this method is called when the Device is inited
async _initDevice() {
this.log('_initDevice');
const device = this.getData();

this.setUnavailable('Please remove this device and add the new device types.');

// Register flowcard triggers
//this._registerFlowCardTriggers();

// Update server data
//this._syncDevice();

// Set update timer
this.intervalId = setInterval(this._syncDevice.bind(this), refreshTimeout);
this.setSettings({
url: device.url,
});

console.log("register flow triggers");
// register Flow triggers
this._flowTriggerHeatingInChanged = new Homey.FlowCardTriggerDevice('measure_temperature.in.changed').register();
this._flowTriggerHeatingOutChanged = new Homey.FlowCardTriggerDevice('measure_temperature.out.changed').register();
this._flowTriggerHeatingDeltaChanged = new Homey.FlowCardTriggerDevice('measure_temperature.delta.changed').register();
}

async _deleteDevice() {
this.log('_deleteDevice');

clearInterval(this.intervalId);
}

// Update server data
async _syncDevice() {
try {
let status = await this.api.getHeating();

if (status.length != 0) {
this.setAvailable();

let heatingIn = status[0]["ROOM_TEMPERATURE_IN"]
let heatingOut = status[0]["ROOM_TEMPERATURE_OUT"]
let heatingDelta = (heatingIn - heatingOut).toFixed(2);

this.changeCapabilityValue('measure_temperature.in', Number(heatingIn), this._flowTriggerHeatingInChanged, {'measure_temperature.in.temperature': Number(heatingIn)});
this.changeCapabilityValue('measure_temperature.out', Number(heatingOut), this._flowTriggerHeatingOutChanged, {'measure_temperature.out.temperature': Number(heatingOut)});
this.changeCapabilityValue('measure_temperature.delta', Number(heatingDelta), this._flowTriggerHeatingDeltaChanged, {'measure_temperature.delta.temperature': Number(heatingDelta)});

} else {
this.setUnavailable('Cannot refresh / Connect');
}


} catch (error) {
this.error(error);
this.setUnavailable(error.message);
}
}

// this method is called when the Device has requested a state change (turned on or off)
//async p1_kwh_used( value, opts ) {

// ... set value to real device, e.g.
// await setMyDeviceState({ on: value });

// or, throw an error
// throw new Error('Switching the device failed!');
//}

}
Loading

0 comments on commit c8f03b2

Please sign in to comment.