Skip to content

Commit

Permalink
Bugfix & Improvements
Browse files Browse the repository at this point in the history
- Added "Dummy Switch" option to Central Switch
- Added new accessory type option (LightSensor) to Solar Intensity Accessory
- Added new mode (CUSTOM) to HOT_WATER devices
- Fixed current state of HeaterCooler if temperature is reached
- Fixed AUTO mode for HOT_WATER devices
- Bugfixes
  • Loading branch information
seydx authored Mar 22, 2021
1 parent ac28ff4 commit 8a4d552
Show file tree
Hide file tree
Showing 8 changed files with 241 additions and 82 deletions.
46 changes: 42 additions & 4 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,28 @@
"type": "boolean",
"description": "If enabled, a lightbulb accessory for the solar intensity will be exposed to HomeKit."
},
"accTypeSolarIntensity": {
"title": "Solar Intensity Accessory Type",
"type": "string",
"condition": {
"functionBody": "try { return model.homes[arrayIndices[0]].weather.solarIntensity } catch(e){ return false }"
},
"oneOf": [
{
"title": "Lightbulb",
"enum": [
"LIGHTBULB"
]
},
{
"title": "Sensor",
"enum": [
"SENSOR"
]
}
],
"description": "The accessory type of the device."
},
"airQuality": {
"title": "Air Quality",
"type": "boolean",
Expand Down Expand Up @@ -249,6 +271,14 @@
},
"description": "If enabled, a turn off heat switch will be added to the central switch."
},
"dummySwitch": {
"title": "Dummy Switch",
"type": "boolean",
"condition": {
"functionBody": "try { return model.homes[arrayIndices[0]].extras.centralSwitch } catch(e){ return false }"
},
"description": "If enabled, a dummy switch (for eg automation purposes) will be added to the central switch."
},
"childLockSwitches": {
"title": "Child Lock Switches",
"type": "array",
Expand Down Expand Up @@ -382,11 +412,17 @@
"title": "Timer",
"enum": [
"TIMER"
]
},
{
"title": "Custom",
"enum": [
"CUSTOM"
]
}
],
"description": "Mode for the commands to be sent with. can be 'MANUAL' for manual control until ended by the user, 'AUTO' for manual control until next schedule change in tado° app OR 'TIMER' for manual control until timer ends."
},
],
"description": "Mode for the commands to be sent with. can be 'MANUAL' for manual control until ended by the user, 'AUTO' for manual control until next schedule change in tado° app, 'TIMER' for manual control until timer ends or 'CUSTOM' for a mixed use of MANUAL (off) and AUTO (on). (CUSTOM is only for HEATING types with easyMode enabled and HOT_WATER types with temperature support)."
},
"modeTimer": {
"title": "Timer",
"description": "Timer for the manual mode in minutes.",
Expand Down Expand Up @@ -714,6 +750,7 @@
"items": [
"homes[].weather.temperatureSensor",
"homes[].weather.solarIntensity",
"homes[].weather.accTypeSolarIntensity",
"homes[].weather.airQuality",
{
"title": "Location",
Expand Down Expand Up @@ -747,7 +784,8 @@
"homes[].extras.runningInformation",
"homes[].extras.boostSwitch",
"homes[].extras.sheduleSwitch",
"homes[].extras.turnoffSwitch"
"homes[].extras.turnoffSwitch",
"homes[].extras.dummySwitch"
]
},
{
Expand Down
12 changes: 8 additions & 4 deletions homebridge-ui/public/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ function goBack(index) {

async function createCustomSchema(home){

//schema.layout.homes.forEach()

customSchemaActive = homebridge.createForm(schema, {
name: pluginConfig[0].name,
debug: pluginConfig[0].debug,
Expand All @@ -137,11 +139,11 @@ async function createCustomSchema(home){

pluginConfig[0].name = config.name;
pluginConfig[0].debug = config.debug;
pluginConfig[0].homes = pluginConfig[0].homes.map(home => {
if(home.name === config.homes.name){
home = config.homes;
pluginConfig[0].homes = pluginConfig[0].homes.map(myHome => {
if(myHome.name === config.homes.name){
myHome = config.homes;
}
return home;
return myHome;
});

try {
Expand Down Expand Up @@ -995,6 +997,7 @@ async function fetchDevices(credentials, refresh, resync){
weather: {
temperatureSensor: false,
solarIntensity: false,
accTypeSolarIntensity: 'LIGHTBULB',
airQuality: false
},
extras: {
Expand Down Expand Up @@ -1129,6 +1132,7 @@ async function fetchDevices(credentials, refresh, resync){
weather: {
temperatureSensor: false,
solarIntensity: false,
accTypeSolarIntensity: 'LIGHTBULB',
airQuality: false
},
extras: {
Expand Down
46 changes: 42 additions & 4 deletions homebridge-ui/public/js/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,28 @@ const schema = {
'type': 'boolean',
'description': 'If enabled, a lightbulb accessory for the solar intensity will be exposed to HomeKit.'
},
'accTypeSolarIntensity': {
'title': 'Solar Intensity Accessory Type',
'type': 'string',
'condition': {
'functionBody': 'try { return model.homes.weather.solarIntensity } catch(e){ return false }'
},
'oneOf': [
{
'title': 'Lightbulb',
'enum': [
'LIGHTBULB'
]
},
{
'title': 'Sensor',
'enum': [
'SENSOR'
]
}
],
'description': 'The accessory type of the device.'
},
'airQuality': {
'title': 'Air Quality',
'type': 'boolean',
Expand Down Expand Up @@ -244,6 +266,14 @@ const schema = {
},
'description': 'If enabled, a turn off heat switch will be added to the central switch.'
},
'dummySwitch': {
'title': 'Dummy Switch',
'type': 'boolean',
'condition': {
'functionBody': 'try { return model.homes.extras.centralSwitch } catch(e){ return false }'
},
'description': 'If enabled, a dummy switch (for eg automation purposes) will be added to the central switch.'
},
'childLockSwitches': {
'title': 'Child Lock Switches',
'type': 'array',
Expand Down Expand Up @@ -355,7 +385,7 @@ const schema = {
'title': 'Maximum Temperature',
'type': 'integer',
'description': 'Maximum adjustable temperature value (in celsius/fahrenheit). HEATING devices also this plugin, supports a maxValue of 25° Celsius / 77° Fahrenheit by default. HOT WATER devices, also this plugin, supports a maxValue of of 65° Celsius / 149° Fahrenheit by default. If your device has a different maxValue, you can set it up here. (Incorrect maxValue may cause problems!)'
},
},
'mode': {
'title': 'Termination Mode',
'type': 'string',
Expand All @@ -378,10 +408,16 @@ const schema = {
'enum': [
'TIMER'
]
},
{
'title': 'Custom',
'enum': [
'CUSTOM'
]
}
],
'description': 'Mode for the commands to be sent with. can be \'MANUAL\' for manual control until ended by the user, \'AUTO\' for manual control until next schedule change in tado° app OR \'TIMER\' for manual control until timer ends.'
},
'description': 'Mode for the commands to be sent with. can be \'MANUAL\' for manual control until ended by the user, \'AUTO\' for manual control until next schedule change in tado° app, \'TIMER\' for manual control until timer ends or \'CUSTOM\' for a mixed use of MANUAL (off) and AUTO (on). (CUSTOM is only for HEATING types with easyMode enabled and HOT_WATER types with temperature support).'
},
'modeTimer': {
'title': 'Timer',
'description': 'Timer for the manual mode in minutes.',
Expand Down Expand Up @@ -702,6 +738,7 @@ const schema = {
'items': [
'homes.weather.temperatureSensor',
'homes.weather.solarIntensity',
'homes.weather.accTypeSolarIntensity',
'homes.weather.airQuality',
{
'title': 'Location',
Expand Down Expand Up @@ -735,7 +772,8 @@ const schema = {
'homes.extras.runningInformation',
'homes.extras.boostSwitch',
'homes.extras.sheduleSwitch',
'homes.extras.turnoffSwitch'
'homes.extras.turnoffSwitch',
'homes.extras.dummySwitch'
]
},
{
Expand Down
10 changes: 8 additions & 2 deletions src/accessories/lightbulb.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const Logger = require('../helper/logger.js');

class SolarlightAccessory {
class SolarLightbulbAccessory {

constructor (api, accessory, accessories, tado) {

Expand All @@ -23,6 +23,12 @@ class SolarlightAccessory {
getService () {

let service = this.accessory.getService(this.api.hap.Service.Lightbulb);
let serviceOld = this.accessory.getService(this.api.hap.Service.LightSensor);

if(serviceOld){
Logger.info('Removing LightSensor service', this.accessory.displayName);
this.accessory.removeService(serviceOld);
}

if(!service){
Logger.info('Adding Lightbulb service', this.accessory.displayName);
Expand Down Expand Up @@ -52,4 +58,4 @@ class SolarlightAccessory {

}

module.exports = SolarlightAccessory;
module.exports = SolarLightbulbAccessory;
42 changes: 42 additions & 0 deletions src/accessories/lightsensor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
'use strict';

const Logger = require('../helper/logger.js');

class SolarLightsensorAccessory {

constructor (api, accessory, accessories, tado) {

this.api = api;
this.accessory = accessory;
this.accessories = accessories;

this.tado = tado;

this.getService();

}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// Services
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//

getService () {

let service = this.accessory.getService(this.api.hap.Service.LightSensor);
let serviceOld = this.accessory.getService(this.api.hap.Service.Lightbulb);

if(serviceOld){
Logger.info('Removing Lightbulb service', this.accessory.displayName);
this.accessory.removeService(serviceOld);
}

if(!service){
Logger.info('Adding LightSensor service', this.accessory.displayName);
service = this.accessory.addService(this.api.hap.Service.LightSensor, this.accessory.displayName, this.accessory.context.config.subtype);
}

}

}

module.exports = SolarLightsensorAccessory;
Loading

0 comments on commit 8a4d552

Please sign in to comment.