mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
Workaround for better Domoticz MQTT intergration? #904
This commit is contained in:
54
interface/package-lock.json
generated
54
interface/package-lock.json
generated
@@ -13,7 +13,7 @@
|
|||||||
"@msgpack/msgpack": "^2.8.0",
|
"@msgpack/msgpack": "^2.8.0",
|
||||||
"@mui/icons-material": "^5.11.0",
|
"@mui/icons-material": "^5.11.0",
|
||||||
"@mui/material": "^5.11.8",
|
"@mui/material": "^5.11.8",
|
||||||
"@table-library/react-table-library": "4.0.24",
|
"@table-library/react-table-library": "4.0.25",
|
||||||
"@types/lodash-es": "^4.17.6",
|
"@types/lodash-es": "^4.17.6",
|
||||||
"@types/node": "^18.13.0",
|
"@types/node": "^18.13.0",
|
||||||
"@types/react": "^18.0.28",
|
"@types/react": "^18.0.28",
|
||||||
@@ -1761,12 +1761,12 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/@table-library/react-table-library": {
|
"node_modules/@table-library/react-table-library": {
|
||||||
"version": "4.0.24",
|
"version": "4.0.25",
|
||||||
"resolved": "https://registry.npmjs.org/@table-library/react-table-library/-/react-table-library-4.0.24.tgz",
|
"resolved": "https://registry.npmjs.org/@table-library/react-table-library/-/react-table-library-4.0.25.tgz",
|
||||||
"integrity": "sha512-tOeKermNhSDKGVvzBlF8gtLVWl+lWbCHk0XH/7s1ybZ9XI8TXpogzXavyRfObGFAIyeazr7Qy5bWGWnE4uueUg==",
|
"integrity": "sha512-3XQg+5R+TmVxXwy4knVfqnk9Jv8sCmZVo9M3Lj7cXYsWi3eGsUqXOpio29m1JU1H6QIcZ32C+ZOr+SJXXS+MMA==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"clsx": "1.1.1",
|
"clsx": "1.1.1",
|
||||||
"react-virtualized-auto-sizer": "1.0.6",
|
"react-virtualized-auto-sizer": "1.0.7",
|
||||||
"react-window": "1.8.7"
|
"react-window": "1.8.7"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
@@ -1783,18 +1783,6 @@
|
|||||||
"node": ">=6"
|
"node": ">=6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@table-library/react-table-library/node_modules/react-virtualized-auto-sizer": {
|
|
||||||
"version": "1.0.6",
|
|
||||||
"resolved": "https://registry.npmjs.org/react-virtualized-auto-sizer/-/react-virtualized-auto-sizer-1.0.6.tgz",
|
|
||||||
"integrity": "sha512-7tQ0BmZqfVF6YYEWcIGuoR3OdYe8I/ZFbNclFlGOC3pMqunkYF/oL30NCjSGl9sMEb17AnzixDz98Kqc3N76HQ==",
|
|
||||||
"engines": {
|
|
||||||
"node": ">8.0.0"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"react": "^15.3.0 || ^16.0.0-alpha || ^17.0.0",
|
|
||||||
"react-dom": "^15.3.0 || ^16.0.0-alpha || ^17.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@types/estree": {
|
"node_modules/@types/estree": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.0.tgz",
|
||||||
@@ -5611,6 +5599,18 @@
|
|||||||
"react-dom": ">=16.6.0"
|
"react-dom": ">=16.6.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/react-virtualized-auto-sizer": {
|
||||||
|
"version": "1.0.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/react-virtualized-auto-sizer/-/react-virtualized-auto-sizer-1.0.7.tgz",
|
||||||
|
"integrity": "sha512-Mxi6lwOmjwIjC1X4gABXMJcKHsOo0xWl3E3ugOgufB8GJU+MqrtY35aBuvCYv/razQ1Vbp7h1gWJjGjoNN5pmA==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">8.0.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": "^15.3.0 || ^16.0.0-alpha || ^17.0.0 || ^18.0.0-rc",
|
||||||
|
"react-dom": "^15.3.0 || ^16.0.0-alpha || ^17.0.0 || ^18.0.0-rc"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/react-window": {
|
"node_modules/react-window": {
|
||||||
"version": "1.8.7",
|
"version": "1.8.7",
|
||||||
"resolved": "https://registry.npmjs.org/react-window/-/react-window-1.8.7.tgz",
|
"resolved": "https://registry.npmjs.org/react-window/-/react-window-1.8.7.tgz",
|
||||||
@@ -7709,12 +7709,12 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@table-library/react-table-library": {
|
"@table-library/react-table-library": {
|
||||||
"version": "4.0.24",
|
"version": "4.0.25",
|
||||||
"resolved": "https://registry.npmjs.org/@table-library/react-table-library/-/react-table-library-4.0.24.tgz",
|
"resolved": "https://registry.npmjs.org/@table-library/react-table-library/-/react-table-library-4.0.25.tgz",
|
||||||
"integrity": "sha512-tOeKermNhSDKGVvzBlF8gtLVWl+lWbCHk0XH/7s1ybZ9XI8TXpogzXavyRfObGFAIyeazr7Qy5bWGWnE4uueUg==",
|
"integrity": "sha512-3XQg+5R+TmVxXwy4knVfqnk9Jv8sCmZVo9M3Lj7cXYsWi3eGsUqXOpio29m1JU1H6QIcZ32C+ZOr+SJXXS+MMA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"clsx": "1.1.1",
|
"clsx": "1.1.1",
|
||||||
"react-virtualized-auto-sizer": "1.0.6",
|
"react-virtualized-auto-sizer": "1.0.7",
|
||||||
"react-window": "1.8.7"
|
"react-window": "1.8.7"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -7722,12 +7722,6 @@
|
|||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/clsx/-/clsx-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/clsx/-/clsx-1.1.1.tgz",
|
||||||
"integrity": "sha512-6/bPho624p3S2pMyvP5kKBPXnI3ufHLObBFCfgx+LkeR5lg2XYy2hqZqUf45ypD8COn2bhgGJSUE+l5dhNBieA=="
|
"integrity": "sha512-6/bPho624p3S2pMyvP5kKBPXnI3ufHLObBFCfgx+LkeR5lg2XYy2hqZqUf45ypD8COn2bhgGJSUE+l5dhNBieA=="
|
||||||
},
|
|
||||||
"react-virtualized-auto-sizer": {
|
|
||||||
"version": "1.0.6",
|
|
||||||
"resolved": "https://registry.npmjs.org/react-virtualized-auto-sizer/-/react-virtualized-auto-sizer-1.0.6.tgz",
|
|
||||||
"integrity": "sha512-7tQ0BmZqfVF6YYEWcIGuoR3OdYe8I/ZFbNclFlGOC3pMqunkYF/oL30NCjSGl9sMEb17AnzixDz98Kqc3N76HQ==",
|
|
||||||
"requires": {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -10535,6 +10529,12 @@
|
|||||||
"prop-types": "^15.6.2"
|
"prop-types": "^15.6.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"react-virtualized-auto-sizer": {
|
||||||
|
"version": "1.0.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/react-virtualized-auto-sizer/-/react-virtualized-auto-sizer-1.0.7.tgz",
|
||||||
|
"integrity": "sha512-Mxi6lwOmjwIjC1X4gABXMJcKHsOo0xWl3E3ugOgufB8GJU+MqrtY35aBuvCYv/razQ1Vbp7h1gWJjGjoNN5pmA==",
|
||||||
|
"requires": {}
|
||||||
|
},
|
||||||
"react-window": {
|
"react-window": {
|
||||||
"version": "1.8.7",
|
"version": "1.8.7",
|
||||||
"resolved": "https://registry.npmjs.org/react-window/-/react-window-1.8.7.tgz",
|
"resolved": "https://registry.npmjs.org/react-window/-/react-window-1.8.7.tgz",
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
"@msgpack/msgpack": "^2.8.0",
|
"@msgpack/msgpack": "^2.8.0",
|
||||||
"@mui/icons-material": "^5.11.0",
|
"@mui/icons-material": "^5.11.0",
|
||||||
"@mui/material": "^5.11.8",
|
"@mui/material": "^5.11.8",
|
||||||
"@table-library/react-table-library": "4.0.24",
|
"@table-library/react-table-library": "4.0.25",
|
||||||
"@types/lodash-es": "^4.17.6",
|
"@types/lodash-es": "^4.17.6",
|
||||||
"@types/node": "^18.13.0",
|
"@types/node": "^18.13.0",
|
||||||
"@types/react": "^18.0.28",
|
"@types/react": "^18.0.28",
|
||||||
|
|||||||
@@ -227,6 +227,21 @@ const MqttSettingsForm: FC = () => {
|
|||||||
{data.ha_enabled && (
|
{data.ha_enabled && (
|
||||||
<>
|
<>
|
||||||
<Grid container spacing={1} direction="row" justifyContent="flex-start" alignItems="flex-start">
|
<Grid container spacing={1} direction="row" justifyContent="flex-start" alignItems="flex-start">
|
||||||
|
<Grid item>
|
||||||
|
<ValidatedTextField
|
||||||
|
name="entity_format"
|
||||||
|
label={LL.MQTT_PUBLISH_TEXT_5()}
|
||||||
|
value={data.discovery_type}
|
||||||
|
fullWidth
|
||||||
|
variant="outlined"
|
||||||
|
onChange={updateFormValue}
|
||||||
|
margin="normal"
|
||||||
|
select
|
||||||
|
>
|
||||||
|
<MenuItem value={0}>Home Assistant</MenuItem>
|
||||||
|
<MenuItem value={1}>Domoticz</MenuItem>
|
||||||
|
</ValidatedTextField>
|
||||||
|
</Grid>
|
||||||
<Grid item>
|
<Grid item>
|
||||||
<ValidatedTextField
|
<ValidatedTextField
|
||||||
name="discovery_prefix"
|
name="discovery_prefix"
|
||||||
|
|||||||
@@ -239,8 +239,9 @@ const de: Translation = {
|
|||||||
MQTT_RESPONSE: 'Veröffentliche die Kommandoantwort als `response` Topic',
|
MQTT_RESPONSE: 'Veröffentliche die Kommandoantwort als `response` Topic',
|
||||||
MQTT_PUBLISH_TEXT_1: 'Veröffentliche einzelne Werte bei Veränderung als eigene Topics',
|
MQTT_PUBLISH_TEXT_1: 'Veröffentliche einzelne Werte bei Veränderung als eigene Topics',
|
||||||
MQTT_PUBLISH_TEXT_2: 'Veröffentliche als Kommando-Topic (ioBroker)',
|
MQTT_PUBLISH_TEXT_2: 'Veröffentliche als Kommando-Topic (ioBroker)',
|
||||||
MQTT_PUBLISH_TEXT_3: 'Aktiviere `MQTT Discovery` (Home Assistant, Domoticz)',
|
MQTT_PUBLISH_TEXT_3: 'Aktiviere `MQTT Discovery`',
|
||||||
MQTT_PUBLISH_TEXT_4: 'Prefix für die `Discovery`-Topics',
|
MQTT_PUBLISH_TEXT_4: 'Prefix für die `Discovery`-Topics',
|
||||||
|
MQTT_PUBLISH_TEXT_5: 'Discovery type', // TODO translate
|
||||||
MQTT_PUBLISH_INTERVALS: 'Veröffentlichungs-Intervalle',
|
MQTT_PUBLISH_INTERVALS: 'Veröffentlichungs-Intervalle',
|
||||||
MQTT_INT_BOILER: 'Boiler und Wärmepumpen',
|
MQTT_INT_BOILER: 'Boiler und Wärmepumpen',
|
||||||
MQTT_INT_THERMOSTATS: 'Thermostate',
|
MQTT_INT_THERMOSTATS: 'Thermostate',
|
||||||
|
|||||||
@@ -239,8 +239,9 @@ const en: Translation = {
|
|||||||
MQTT_RESPONSE: 'Publish command output to a `response` topic',
|
MQTT_RESPONSE: 'Publish command output to a `response` topic',
|
||||||
MQTT_PUBLISH_TEXT_1: 'Publish single value topics on change',
|
MQTT_PUBLISH_TEXT_1: 'Publish single value topics on change',
|
||||||
MQTT_PUBLISH_TEXT_2: 'Publish to command topics (ioBroker)',
|
MQTT_PUBLISH_TEXT_2: 'Publish to command topics (ioBroker)',
|
||||||
MQTT_PUBLISH_TEXT_3: 'Enable MQTT Discovery (Home Assistant, Domoticz)',
|
MQTT_PUBLISH_TEXT_3: 'Enable MQTT Discovery',
|
||||||
MQTT_PUBLISH_TEXT_4: 'Prefix for the Discovery topics',
|
MQTT_PUBLISH_TEXT_4: 'Prefix for the Discovery topics',
|
||||||
|
MQTT_PUBLISH_TEXT_5: 'Discovery type',
|
||||||
MQTT_PUBLISH_INTERVALS: 'Publish Intervals',
|
MQTT_PUBLISH_INTERVALS: 'Publish Intervals',
|
||||||
MQTT_INT_BOILER: 'Boilers and Heat Pumps',
|
MQTT_INT_BOILER: 'Boilers and Heat Pumps',
|
||||||
MQTT_INT_THERMOSTATS: 'Thermostats',
|
MQTT_INT_THERMOSTATS: 'Thermostats',
|
||||||
|
|||||||
@@ -239,8 +239,9 @@ const fr: Translation = {
|
|||||||
MQTT_RESPONSE: 'Publier le résultat des commandes dans un topic `response`',
|
MQTT_RESPONSE: 'Publier le résultat des commandes dans un topic `response`',
|
||||||
MQTT_PUBLISH_TEXT_1: 'Publier des topics à valeur unique sur changement',
|
MQTT_PUBLISH_TEXT_1: 'Publier des topics à valeur unique sur changement',
|
||||||
MQTT_PUBLISH_TEXT_2: 'Publier vers des topics de commande (ioBroker)',
|
MQTT_PUBLISH_TEXT_2: 'Publier vers des topics de commande (ioBroker)',
|
||||||
MQTT_PUBLISH_TEXT_3: 'Activer la découverte MQTT (Home Assistant, Domoticz)',
|
MQTT_PUBLISH_TEXT_3: 'Activer la découverte MQTT',
|
||||||
MQTT_PUBLISH_TEXT_4: 'Préfixe pour les topics découverte',
|
MQTT_PUBLISH_TEXT_4: 'Préfixe pour les topics découverte',
|
||||||
|
MQTT_PUBLISH_TEXT_5: 'Discovery type', // TODO translate
|
||||||
MQTT_PUBLISH_INTERVALS: 'Intervalles de publication',
|
MQTT_PUBLISH_INTERVALS: 'Intervalles de publication',
|
||||||
MQTT_INT_BOILER: 'Chaudières et pompes à chaleur',
|
MQTT_INT_BOILER: 'Chaudières et pompes à chaleur',
|
||||||
MQTT_INT_THERMOSTATS: 'Thermostats',
|
MQTT_INT_THERMOSTATS: 'Thermostats',
|
||||||
|
|||||||
@@ -239,8 +239,9 @@ const nl: Translation = {
|
|||||||
MQTT_RESPONSE: 'Publiceer commando output naar een `response` topic',
|
MQTT_RESPONSE: 'Publiceer commando output naar een `response` topic',
|
||||||
MQTT_PUBLISH_TEXT_1: 'Publiceer enkele waarde topics on change',
|
MQTT_PUBLISH_TEXT_1: 'Publiceer enkele waarde topics on change',
|
||||||
MQTT_PUBLISH_TEXT_2: 'Publiceer naar commando topics (ioBroker)',
|
MQTT_PUBLISH_TEXT_2: 'Publiceer naar commando topics (ioBroker)',
|
||||||
MQTT_PUBLISH_TEXT_3: 'Activeer MQTT Discovery (Home Assistant, Domoticz)',
|
MQTT_PUBLISH_TEXT_3: 'Activeer MQTT Discovery',
|
||||||
MQTT_PUBLISH_TEXT_4: 'Prefix voor de Discovery topics',
|
MQTT_PUBLISH_TEXT_4: 'Prefix voor de Discovery topics',
|
||||||
|
MQTT_PUBLISH_TEXT_5: 'Discovery type', // TODO translate
|
||||||
MQTT_PUBLISH_INTERVALS: 'Publicatie intervallen',
|
MQTT_PUBLISH_INTERVALS: 'Publicatie intervallen',
|
||||||
MQTT_INT_BOILER: 'CV ketels en warmtepompen',
|
MQTT_INT_BOILER: 'CV ketels en warmtepompen',
|
||||||
MQTT_INT_THERMOSTATS: 'Thermostaten',
|
MQTT_INT_THERMOSTATS: 'Thermostaten',
|
||||||
|
|||||||
@@ -239,8 +239,9 @@ const no: Translation = {
|
|||||||
MQTT_RESPONSE: 'Publiser kommandoer til en `response` topic',
|
MQTT_RESPONSE: 'Publiser kommandoer til en `response` topic',
|
||||||
MQTT_PUBLISH_TEXT_1: 'Publiser singel verdi topics ved endringer',
|
MQTT_PUBLISH_TEXT_1: 'Publiser singel verdi topics ved endringer',
|
||||||
MQTT_PUBLISH_TEXT_2: 'Publiser til kommando topics (ioBroker)',
|
MQTT_PUBLISH_TEXT_2: 'Publiser til kommando topics (ioBroker)',
|
||||||
MQTT_PUBLISH_TEXT_3: 'Aktiver MQTT Discovery (Home Assistant, Domoticz)',
|
MQTT_PUBLISH_TEXT_3: 'Aktiver MQTT Discovery',
|
||||||
MQTT_PUBLISH_TEXT_4: 'Prefiks for Discovery topics',
|
MQTT_PUBLISH_TEXT_4: 'Prefiks for Discovery topics',
|
||||||
|
MQTT_PUBLISH_TEXT_5: 'Discovery type', // TODO translate
|
||||||
MQTT_PUBLISH_INTERVALS: 'Publiseringsintervall',
|
MQTT_PUBLISH_INTERVALS: 'Publiseringsintervall',
|
||||||
MQTT_INT_BOILER: 'Fyr/Varmepumpe',
|
MQTT_INT_BOILER: 'Fyr/Varmepumpe',
|
||||||
MQTT_INT_THERMOSTATS: 'Termostat',
|
MQTT_INT_THERMOSTATS: 'Termostat',
|
||||||
|
|||||||
@@ -239,8 +239,9 @@ const pl: BaseTranslation = {
|
|||||||
MQTT_RESPONSE: 'Rezultat wykonania komendy publikuj w temacie "response"',
|
MQTT_RESPONSE: 'Rezultat wykonania komendy publikuj w temacie "response"',
|
||||||
MQTT_PUBLISH_TEXT_1: 'Tematy z pojedynczą wartością publikuj po jej zmianie',
|
MQTT_PUBLISH_TEXT_1: 'Tematy z pojedynczą wartością publikuj po jej zmianie',
|
||||||
MQTT_PUBLISH_TEXT_2: 'Publikuj w tematach "command" (ioBroker)',
|
MQTT_PUBLISH_TEXT_2: 'Publikuj w tematach "command" (ioBroker)',
|
||||||
MQTT_PUBLISH_TEXT_3: 'Włącz opcję "MQTT discovery" (Home Assistant, Domoticz)',
|
MQTT_PUBLISH_TEXT_3: 'Włącz opcję "MQTT discovery',
|
||||||
MQTT_PUBLISH_TEXT_4: 'Prefiks dla "MQTT discovery"',
|
MQTT_PUBLISH_TEXT_4: 'Prefiks dla "MQTT discovery"',
|
||||||
|
MQTT_PUBLISH_TEXT_5: 'Discovery type', // TODO translate
|
||||||
MQTT_PUBLISH_INTERVALS: 'Interwały publikowania',
|
MQTT_PUBLISH_INTERVALS: 'Interwały publikowania',
|
||||||
MQTT_INT_BOILER: 'Kotły i pompy ciepła',
|
MQTT_INT_BOILER: 'Kotły i pompy ciepła',
|
||||||
MQTT_INT_THERMOSTATS: 'Termostaty',
|
MQTT_INT_THERMOSTATS: 'Termostaty',
|
||||||
|
|||||||
@@ -239,8 +239,9 @@ const sv: Translation = {
|
|||||||
MQTT_RESPONSE: 'Publish-kommando som ett `response` topic',
|
MQTT_RESPONSE: 'Publish-kommando som ett `response` topic',
|
||||||
MQTT_PUBLISH_TEXT_1: 'Publicera single value topics vid värdeförändring',
|
MQTT_PUBLISH_TEXT_1: 'Publicera single value topics vid värdeförändring',
|
||||||
MQTT_PUBLISH_TEXT_2: 'Publicera till kommando-topics (ioBroker)',
|
MQTT_PUBLISH_TEXT_2: 'Publicera till kommando-topics (ioBroker)',
|
||||||
MQTT_PUBLISH_TEXT_3: 'Aktivera MQTT Discovery (Home Assistant, Domoticz)',
|
MQTT_PUBLISH_TEXT_3: 'Aktivera MQTT Discovery',
|
||||||
MQTT_PUBLISH_TEXT_4: 'Prefix för Discovery topics',
|
MQTT_PUBLISH_TEXT_4: 'Prefix för Discovery topics',
|
||||||
|
MQTT_PUBLISH_TEXT_5: 'Discovery type', // TODO translate
|
||||||
MQTT_PUBLISH_INTERVALS: 'Publiceringsintervall',
|
MQTT_PUBLISH_INTERVALS: 'Publiceringsintervall',
|
||||||
MQTT_INT_BOILER: 'Värmepump/panna',
|
MQTT_INT_BOILER: 'Värmepump/panna',
|
||||||
MQTT_INT_THERMOSTATS: 'Termostater',
|
MQTT_INT_THERMOSTATS: 'Termostater',
|
||||||
|
|||||||
@@ -45,4 +45,5 @@ export interface MqttSettings {
|
|||||||
publish_single: boolean;
|
publish_single: boolean;
|
||||||
publish_single2cmd: boolean;
|
publish_single2cmd: boolean;
|
||||||
discovery_prefix: string;
|
discovery_prefix: string;
|
||||||
|
discovery_type: number;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -169,6 +169,7 @@ void MqttSettings::read(MqttSettings & settings, JsonObject & root) {
|
|||||||
root["ha_enabled"] = settings.ha_enabled;
|
root["ha_enabled"] = settings.ha_enabled;
|
||||||
root["nested_format"] = settings.nested_format;
|
root["nested_format"] = settings.nested_format;
|
||||||
root["discovery_prefix"] = settings.discovery_prefix;
|
root["discovery_prefix"] = settings.discovery_prefix;
|
||||||
|
root["discovery_type"] = settings.discovery_type;
|
||||||
root["publish_single"] = settings.publish_single;
|
root["publish_single"] = settings.publish_single;
|
||||||
root["publish_single2cmd"] = settings.publish_single2cmd;
|
root["publish_single2cmd"] = settings.publish_single2cmd;
|
||||||
root["send_response"] = settings.send_response;
|
root["send_response"] = settings.send_response;
|
||||||
@@ -201,6 +202,7 @@ StateUpdateResult MqttSettings::update(JsonObject & root, MqttSettings & setting
|
|||||||
newSettings.ha_enabled = root["ha_enabled"] | EMSESP_DEFAULT_HA_ENABLED;
|
newSettings.ha_enabled = root["ha_enabled"] | EMSESP_DEFAULT_HA_ENABLED;
|
||||||
newSettings.nested_format = root["nested_format"] | EMSESP_DEFAULT_NESTED_FORMAT;
|
newSettings.nested_format = root["nested_format"] | EMSESP_DEFAULT_NESTED_FORMAT;
|
||||||
newSettings.discovery_prefix = root["discovery_prefix"] | EMSESP_DEFAULT_DISCOVERY_PREFIX;
|
newSettings.discovery_prefix = root["discovery_prefix"] | EMSESP_DEFAULT_DISCOVERY_PREFIX;
|
||||||
|
newSettings.discovery_type = root["discovery_type"] | EMSESP_DEFAULT_DISCOVERY_TYPE;
|
||||||
newSettings.publish_single = root["publish_single"] | EMSESP_DEFAULT_PUBLISH_SINGLE;
|
newSettings.publish_single = root["publish_single"] | EMSESP_DEFAULT_PUBLISH_SINGLE;
|
||||||
newSettings.publish_single2cmd = root["publish_single2cmd"] | EMSESP_DEFAULT_PUBLISH_SINGLE2CMD;
|
newSettings.publish_single2cmd = root["publish_single2cmd"] | EMSESP_DEFAULT_PUBLISH_SINGLE2CMD;
|
||||||
newSettings.send_response = root["send_response"] | EMSESP_DEFAULT_SEND_RESPONSE;
|
newSettings.send_response = root["send_response"] | EMSESP_DEFAULT_SEND_RESPONSE;
|
||||||
@@ -223,6 +225,10 @@ StateUpdateResult MqttSettings::update(JsonObject & root, MqttSettings & setting
|
|||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (newSettings.discovery_type != settings.discovery_type) {
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (newSettings.entity_format != settings.entity_format) {
|
if (newSettings.entity_format != settings.entity_format) {
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ class MqttSettings {
|
|||||||
bool ha_enabled;
|
bool ha_enabled;
|
||||||
uint8_t nested_format;
|
uint8_t nested_format;
|
||||||
String discovery_prefix;
|
String discovery_prefix;
|
||||||
|
uint8_t discovery_type;
|
||||||
bool publish_single;
|
bool publish_single;
|
||||||
bool publish_single2cmd;
|
bool publish_single2cmd;
|
||||||
bool send_response;
|
bool send_response;
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ class DummySettings {
|
|||||||
bool enabled = true;
|
bool enabled = true;
|
||||||
uint8_t nested_format = 1; // 1=nested 2=single
|
uint8_t nested_format = 1; // 1=nested 2=single
|
||||||
String discovery_prefix = "homeassistant";
|
String discovery_prefix = "homeassistant";
|
||||||
|
uint8_t discovery_type = 0; // HA
|
||||||
bool ha_enabled = true;
|
bool ha_enabled = true;
|
||||||
String base = "ems-esp";
|
String base = "ems-esp";
|
||||||
bool publish_single = false;
|
bool publish_single = false;
|
||||||
|
|||||||
@@ -241,6 +241,7 @@ mqtt_settings = {
|
|||||||
mqtt_retain: false,
|
mqtt_retain: false,
|
||||||
ha_enabled: true,
|
ha_enabled: true,
|
||||||
nested_format: 1,
|
nested_format: 1,
|
||||||
|
discovery_type: 0,
|
||||||
discovery_prefix: 'homeassistant',
|
discovery_prefix: 'homeassistant',
|
||||||
send_response: true,
|
send_response: true,
|
||||||
publish_single: false
|
publish_single: false
|
||||||
|
|||||||
@@ -169,6 +169,10 @@
|
|||||||
#define EMSESP_DEFAULT_DISCOVERY_PREFIX "homeassistant"
|
#define EMSESP_DEFAULT_DISCOVERY_PREFIX "homeassistant"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef EMSESP_DEFAULT_DISCOVERY_TYPE
|
||||||
|
#define EMSESP_DEFAULT_DISCOVERY_TYPE 0 // HA
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef EMSESP_DEFAULT_PUBLISH_SINGLE
|
#ifndef EMSESP_DEFAULT_PUBLISH_SINGLE
|
||||||
#define EMSESP_DEFAULT_PUBLISH_SINGLE false
|
#define EMSESP_DEFAULT_PUBLISH_SINGLE false
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
10
src/mqtt.cpp
10
src/mqtt.cpp
@@ -42,6 +42,7 @@ uint8_t Mqtt::entity_format_;
|
|||||||
bool Mqtt::ha_enabled_;
|
bool Mqtt::ha_enabled_;
|
||||||
uint8_t Mqtt::nested_format_;
|
uint8_t Mqtt::nested_format_;
|
||||||
std::string Mqtt::discovery_prefix_;
|
std::string Mqtt::discovery_prefix_;
|
||||||
|
uint8_t Mqtt::discovery_type_;
|
||||||
bool Mqtt::send_response_;
|
bool Mqtt::send_response_;
|
||||||
bool Mqtt::publish_single_;
|
bool Mqtt::publish_single_;
|
||||||
bool Mqtt::publish_single2cmd_;
|
bool Mqtt::publish_single2cmd_;
|
||||||
@@ -1024,7 +1025,6 @@ void Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev
|
|||||||
}
|
}
|
||||||
|
|
||||||
// build a config topic that will be prefix onto a HA type (e.g. number, switch)
|
// build a config topic that will be prefix onto a HA type (e.g. number, switch)
|
||||||
// e.g. homeassistant/number/ems-esp/thermostat_hc1_manualtemp
|
|
||||||
char config_topic[70];
|
char config_topic[70];
|
||||||
snprintf(config_topic, sizeof(config_topic), "%s/%s_%s/config", mqtt_basename_.c_str(), device_name, entity_with_tag);
|
snprintf(config_topic, sizeof(config_topic), "%s/%s_%s/config", mqtt_basename_.c_str(), device_name, entity_with_tag);
|
||||||
|
|
||||||
@@ -1041,9 +1041,15 @@ void Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev
|
|||||||
case DeviceValueType::SHORT:
|
case DeviceValueType::SHORT:
|
||||||
case DeviceValueType::USHORT:
|
case DeviceValueType::USHORT:
|
||||||
case DeviceValueType::ULONG:
|
case DeviceValueType::ULONG:
|
||||||
|
if (discovery_type() == 0) {
|
||||||
|
// Home Assistant
|
||||||
// number - https://www.home-assistant.io/integrations/number.mqtt
|
// number - https://www.home-assistant.io/integrations/number.mqtt
|
||||||
// https://developers.home-assistant.io/docs/core/entity/number
|
|
||||||
snprintf(topic, sizeof(topic), "number/%s", config_topic);
|
snprintf(topic, sizeof(topic), "number/%s", config_topic);
|
||||||
|
} else {
|
||||||
|
// Domoticz
|
||||||
|
// Does not support number, use sensor
|
||||||
|
snprintf(topic, sizeof(topic), "sensor/%s", config_topic);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case DeviceValueType::BOOL:
|
case DeviceValueType::BOOL:
|
||||||
// switch - https://www.home-assistant.io/integrations/switch.mqtt
|
// switch - https://www.home-assistant.io/integrations/switch.mqtt
|
||||||
|
|||||||
@@ -185,6 +185,10 @@ class Mqtt {
|
|||||||
return entity_format_;
|
return entity_format_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint8_t discovery_type() {
|
||||||
|
return discovery_type_;
|
||||||
|
}
|
||||||
|
|
||||||
static void nested_format(uint8_t nested_format) {
|
static void nested_format(uint8_t nested_format) {
|
||||||
nested_format_ = nested_format;
|
nested_format_ = nested_format;
|
||||||
}
|
}
|
||||||
@@ -326,6 +330,7 @@ class Mqtt {
|
|||||||
static uint8_t nested_format_;
|
static uint8_t nested_format_;
|
||||||
static uint8_t entity_format_;
|
static uint8_t entity_format_;
|
||||||
static std::string discovery_prefix_;
|
static std::string discovery_prefix_;
|
||||||
|
static uint8_t discovery_type_;
|
||||||
static bool publish_single_;
|
static bool publish_single_;
|
||||||
static bool publish_single2cmd_;
|
static bool publish_single2cmd_;
|
||||||
static bool send_response_;
|
static bool send_response_;
|
||||||
|
|||||||
@@ -1244,6 +1244,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject & outp
|
|||||||
node["entity format"] = settings.entity_format;
|
node["entity format"] = settings.entity_format;
|
||||||
node["base"] = settings.base;
|
node["base"] = settings.base;
|
||||||
node["discovery prefix"] = settings.discovery_prefix;
|
node["discovery prefix"] = settings.discovery_prefix;
|
||||||
|
node["discovery type"] = settings.discovery_type;
|
||||||
node["nested format"] = settings.nested_format;
|
node["nested format"] = settings.nested_format;
|
||||||
node["ha enabled"] = settings.ha_enabled;
|
node["ha enabled"] = settings.ha_enabled;
|
||||||
node["mqtt qos"] = settings.mqtt_qos;
|
node["mqtt qos"] = settings.mqtt_qos;
|
||||||
|
|||||||
Reference in New Issue
Block a user