This commit is contained in:
Koen Kanters committed 2020-12-02 20:38:48 +01:00
1 parent 1c634dde60
commit 9ff232fbb2
15 files changed
+14 -37

No files matched your search

+1 -4
View File
@@ -52,6 +52,7 @@ class Controller {
// Initialize extensions.
const args = [this.zigbee, this.mqtt, this.state, this.publishEntityState, this.eventBus];
this.extensions = [
new ExtensionBridge(...args, this.enableDisableExtension),
new ExtensionPublish(...args),
new ExtensionReceive(...args),
new ExtensionDeviceGroupMembership(...args),
@@ -64,10 +65,6 @@ class Controller {
new ExtensionReport(...args),
];
if (settings.get().experimental.new_api) {
this.extensions.push(new ExtensionBridge(...args, this.enableDisableExtension));
}
if (settings.get().frontend) {
this.extensions.push(new ExtensionFrontend(...args));
}
+1 -1
View File
@@ -28,7 +28,7 @@ class Bind extends Extension {
type = topic.split('/')[0];
sourceKey = topic.replace(`${type}/`, '');
targetKey = message;
} else if (settings.get().experimental.new_api && topic.match(topicRegex)) {
} else if (topic.match(topicRegex)) {
type = topic.endsWith('unbind') ? 'unbind' : 'bind';
message = JSON.parse(message);
sourceKey = message.from;
+2 -6
View File
@@ -86,7 +86,6 @@ class HomeAssistant extends Extension {
this.mapping = {};
this.discoveredTriggers = {};
this.legacyApi = settings.get().advanced.legacy_api;
this.newApi = settings.get().experimental.new_api;
if (!settings.get().advanced.cache_state) {
logger.warn('In order for HomeAssistant integration to work properly set `cache_state: true');
@@ -535,7 +534,7 @@ class HomeAssistant extends Extension {
},
{
property: 'update',
condition: supportsOTA && this.newApi,
condition: supportsOTA,
value: {state: 'idle'},
},
{
@@ -595,13 +594,10 @@ class HomeAssistant extends Extension {
let configs = this.mapping[resolvedEntity.definition.model].slice();
if (resolvedEntity.definition.hasOwnProperty('ota')) {
configs.push(cfg.sensor_update_state);
if (this.legacyApi) {
configs.push(cfg.binary_sensor_update_available);
}
if (this.newApi) {
configs.push(cfg.sensor_update_state);
}
}
if (resolvedEntity.settings.hasOwnProperty('legacy') && !resolvedEntity.settings.legacy) {
+1 -1
View File
@@ -42,7 +42,7 @@ class NetworkMap extends Extension {
}
}
if (settings.get().experimental.new_api && topic === this.topic) {
if (topic === this.topic) {
try {
message = utils.parseJSON(message, message);
const type = typeof message === 'object' ? message.type : message;
+3 -8
View File
@@ -90,20 +90,15 @@ class OTAUpdate extends Extension {
}
getEntityPublishPayload(state, progress=null, remaining=null) {
const payload = {};
const payload = {update: {state}};
if (progress !== null) payload.update.progress = progress;
if (remaining !== null) payload.update.remaining = Math.round(remaining);
/* istanbul ignore else */
if (this.legacyApi) {
payload.update_available = state === 'available';
}
/* istanbul ignore else */
if (settings.get().experimental.new_api) {
payload.update = {state};
if (progress !== null) payload.update.progress = progress;
if (remaining !== null) payload.update.remaining = Math.round(remaining);
}
return payload;
}
-1
View File
@@ -50,7 +50,6 @@ const defaults = {
experimental: {
// json or attribute or attribute_and_json
output: 'json',
new_api: false,
},
advanced: {
legacy_api: true,
+1
View File
@@ -174,6 +174,7 @@ function* getExternalConvertersDefinitions(settings) {
function toSnakeCase(value) {
if (typeof value === 'object') {
value = {...value};
for (const key of Object.keys(value)) {
const keySnakeCase = toSnakeCase(key);
if (key !== keySnakeCase) {