Merge remote-tracking branch 'tbnobody/OpenDTU/master' into development

This commit is contained in:
helgeerbe 2023-03-07 21:17:48 +01:00
commit 6a89ae986e
12 changed files with 173 additions and 24 deletions

1
.gitignore vendored
View File

@ -6,3 +6,4 @@
.vscode/settings.json .vscode/settings.json
platformio-device-monitor*.log platformio-device-monitor*.log
platformio_override.ini platformio_override.ini
.DS_Store

View File

@ -377,7 +377,14 @@ A documentation of the Web API can be found here: [Web-API Documentation](docs/W
* <https://www.thingiverse.com/thing:5661780> * <https://www.thingiverse.com/thing:5661780>
* <https://www.thingiverse.com/thing:5632374> * <https://www.thingiverse.com/thing:5632374>
* <https://www.thingiverse.com/thing:5852233> * <https://www.thingiverse.com/thing:5852233>
* <https://www.printables.com/model/377994-opendtu-pcb-box-for-the-wider-board>
* <https://www.printables.com/model/376840-esp32-ahoy-opendtu-pcb-housing>
## Available layouts for printed circuit boards
* [BreakoutBoard - sample printed circuit board for OpenDTU and Ahoy](https://github.com/dokuhn/openDTU-BreakoutBoard)
* [Board for OpenDTU with Display](https://github.com/SteffMUC/openDTU_wDisplay2)
* [OpenDTU PCB mit Display](https://github.com/turrican944/OpenDTU-PCB)
* [PCB for OpenDTU in Cable Branchbox](https://github.com/plewka/ESP-Solar_OpenDTU)
## Building ## Building
* Building the WebApp * Building the WebApp
@ -411,4 +418,3 @@ A documentation of the Web API can be found here: [Web-API Documentation](docs/W
- [Ahoy](https://github.com/grindylow/ahoy) - [Ahoy](https://github.com/grindylow/ahoy)
- [DTU Simulator](https://github.com/Ziyatoe/DTUsimMI1x00-Hoymiles) - [DTU Simulator](https://github.com/Ziyatoe/DTUsimMI1x00-Hoymiles)
- [OpenDTU extended to talk to Victrons MPPT battery chargers (Ve.Direct)](https://github.com/helgeerbe/OpenDTU_VeDirect) - [OpenDTU extended to talk to Victrons MPPT battery chargers (Ve.Direct)](https://github.com/helgeerbe/OpenDTU_VeDirect)
- [BreakoutBoard - sample printed circuit board for OpenDTU and Ahoy](https://github.com/dokuhn/openDTU-BreakoutBoard)

View File

@ -9,7 +9,9 @@ may be incomplete
| -------- | --- | -- | | -------- | --- | -- |
| Get | yes | /api/config/get | | Get | yes | /api/config/get |
| Post | yes | /api/config/delete | | Post | yes | /api/config/delete |
| Get | yes | /api/config/list |
| Post | yes | /api/config/upload | | Post | yes | /api/config/upload |
| Get+Post | yes | /api/device/config |
| Get | no | /api/devinfo/status | | Get | no | /api/devinfo/status |
| Get+Post | yes | /api/dtu/config | | Get+Post | yes | /api/dtu/config |
| Get | no | /api/eventlog/status?inv=inverter-serialnumber | | Get | no | /api/eventlog/status?inv=inverter-serialnumber |
@ -21,6 +23,7 @@ may be incomplete
| Post | yes | /api/limit/config | | Post | yes | /api/limit/config |
| Get | no | /api/limit/status | | Get | no | /api/limit/status |
| Get | no | /api/livedata/status | | Get | no | /api/livedata/status |
| Post | yes | /api/maintenance/reboot |
| Get+Post | yes | /api/mqtt/config | | Get+Post | yes | /api/mqtt/config |
| Get | no | /api/mqtt/status | | Get | no | /api/mqtt/status |
| Get+Post | yes | /api/network/config | | Get+Post | yes | /api/network/config |
@ -30,7 +33,9 @@ may be incomplete
| Get+Post | yes | /api/ntp/time | | Get+Post | yes | /api/ntp/time |
| Get | no | /api/power/status | | Get | no | /api/power/status |
| Post | yes | /api/power/config | | Post | yes | /api/power/config |
| Get+Post | yes | /api/security/password | | Get | no | /api/prometheus/metrics |
| Get+Post | yes | /api/security/config |
| Get | yes | /api/security/authenticate |
| Get | no | /api/system/status | | Get | no | /api/system/status |
@ -46,6 +51,7 @@ may be incomplete
- Other API calls use e.g. `/api/limit/status` to GET data and a different URL `/api/limit/config` to POST data. - Other API calls use e.g. `/api/limit/status` to GET data and a different URL `/api/limit/config` to POST data.
- If you want to investigate the web api communication, a good tool is [Postman](https://www.postman.com/) - If you want to investigate the web api communication, a good tool is [Postman](https://www.postman.com/)
- Settings API require username and password provided with Basic Authentication credentials - Settings API require username and password provided with Basic Authentication credentials
- If you disable the readonly access to the web API, every endpoint requires authentication
### Get information ### Get information

View File

@ -34,7 +34,7 @@ String ResetReasonClass::get_reset_reason_verbose(uint8_t cpu_id)
case 3: case 3:
reason_str = F("Software reset digital core"); reason_str = F("Software reset digital core");
break; break;
#if !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3) #if !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3) && !defined(CONFIG_IDF_TARGET_ESP32S2)
case 4: case 4:
reason_str = F("Legacy watch dog reset digital core"); reason_str = F("Legacy watch dog reset digital core");
break; break;
@ -42,7 +42,7 @@ String ResetReasonClass::get_reset_reason_verbose(uint8_t cpu_id)
case 5: case 5:
reason_str = F("Deep Sleep reset digital core"); reason_str = F("Deep Sleep reset digital core");
break; break;
#if !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3) #if !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3) && !defined(CONFIG_IDF_TARGET_ESP32S2)
case 6: case 6:
reason_str = F("Reset by SLC module, reset digital core"); reason_str = F("Reset by SLC module, reset digital core");
break; break;
@ -68,7 +68,7 @@ String ResetReasonClass::get_reset_reason_verbose(uint8_t cpu_id)
case 13: case 13:
reason_str = F("RTC Watch dog Reset CPU"); reason_str = F("RTC Watch dog Reset CPU");
break; break;
#if !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3) #if !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3) && !defined(CONFIG_IDF_TARGET_ESP32S2)
case 14: case 14:
reason_str = F("for APP CPU, reset by PRO CPU"); reason_str = F("for APP CPU, reset by PRO CPU");
break; break;
@ -100,7 +100,7 @@ String ResetReasonClass::get_reset_reason_short(uint8_t cpu_id)
case 3: case 3:
reason_str = F("SW_RESET"); reason_str = F("SW_RESET");
break; break;
#if !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3) #if !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3) && !defined(CONFIG_IDF_TARGET_ESP32S2)
case 4: case 4:
reason_str = F("OWDT_RESET"); reason_str = F("OWDT_RESET");
break; break;
@ -108,7 +108,7 @@ String ResetReasonClass::get_reset_reason_short(uint8_t cpu_id)
case 5: case 5:
reason_str = F("DEEPSLEEP_RESET"); reason_str = F("DEEPSLEEP_RESET");
break; break;
#if !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3) #if !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3) && !defined(CONFIG_IDF_TARGET_ESP32S2)
case 6: case 6:
reason_str = F("SDIO_RESET"); reason_str = F("SDIO_RESET");
break; break;
@ -134,7 +134,7 @@ String ResetReasonClass::get_reset_reason_short(uint8_t cpu_id)
case 13: case 13:
reason_str = F("RTCWDT_CPU_RESET"); reason_str = F("RTCWDT_CPU_RESET");
break; break;
#if !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3) #if !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3) && !defined(CONFIG_IDF_TARGET_ESP32S2)
case 14: case 14:
reason_str = F("EXT_CPU_RESET"); reason_str = F("EXT_CPU_RESET");
break; break;

View File

@ -153,3 +153,13 @@ build_flags = ${env.build_flags}
-DHOYMILES_PIN_IRQ=16 -DHOYMILES_PIN_IRQ=16
-DHOYMILES_PIN_CE=17 -DHOYMILES_PIN_CE=17
-DHOYMILES_PIN_CS=5 -DHOYMILES_PIN_CS=5
[env:lolin_s2_mini]
board = lolin_s2_mini
build_flags = ${env.build_flags}
-DHOYMILES_PIN_MISO=13
-DHOYMILES_PIN_MOSI=11
-DHOYMILES_PIN_SCLK=12
-DHOYMILES_PIN_CS=10
-DHOYMILES_PIN_IRQ=4
-DHOYMILES_PIN_CE=5

View File

@ -12,7 +12,7 @@
}, },
"dependencies": { "dependencies": {
"@popperjs/core": "^2.11.6", "@popperjs/core": "^2.11.6",
"bootstrap": "^5.2.3", "bootstrap": "^5.3.0-alpha1",
"bootstrap-icons-vue": "^1.8.1", "bootstrap-icons-vue": "^1.8.1",
"mitt": "^3.0.0", "mitt": "^3.0.0",
"spark-md5": "^3.0.2", "spark-md5": "^3.0.2",
@ -24,7 +24,7 @@
"@intlify/unplugin-vue-i18n": "^0.8.2", "@intlify/unplugin-vue-i18n": "^0.8.2",
"@rushstack/eslint-patch": "^1.2.0", "@rushstack/eslint-patch": "^1.2.0",
"@types/bootstrap": "^5.2.6", "@types/bootstrap": "^5.2.6",
"@types/node": "^18.14.2", "@types/node": "^18.14.6",
"@types/spark-md5": "^3.0.2", "@types/spark-md5": "^3.0.2",
"@vitejs/plugin-vue": "^4.0.0", "@vitejs/plugin-vue": "^4.0.0",
"@vue/eslint-config-typescript": "^11.0.2", "@vue/eslint-config-typescript": "^11.0.2",

View File

@ -1,5 +1,5 @@
<template> <template>
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark"> <nav class="navbar navbar-expand-md fixed-top bg-body-tertiary" data-bs-theme="dark">
<div class="container-fluid"> <div class="container-fluid">
<router-link @click="onClick" class="navbar-brand" to="/"> <router-link @click="onClick" class="navbar-brand" to="/">
<span v-if="isXmas" class="text-success"> <span v-if="isXmas" class="text-success">
@ -107,11 +107,14 @@
<router-link @click="onClick" class="nav-link" to="/about">{{ $t('menu.About') }}</router-link> <router-link @click="onClick" class="nav-link" to="/about">{{ $t('menu.About') }}</router-link>
</li> </li>
</ul> </ul>
<form class="d-flex" role="search"> <ul class="navbar-nav flex-row flex-wrap ms-md-auto">
<LocaleSwitcher class="me-2" /> <ThemeSwitcher class="me-2" />
<button v-if="isLogged" class="btn btn-outline-danger" @click="signout">{{ $t('menu.Logout') }}</button> <form class="d-flex" role="search">
<button v-if="!isLogged" class="btn btn-outline-success" @click="signin">{{ $t('menu.Login') }}</button> <LocaleSwitcher class="me-2" />
</form> <button v-if="isLogged" class="btn btn-outline-danger" @click="signout">{{ $t('menu.Logout') }}</button>
<button v-if="!isLogged" class="btn btn-outline-success" @click="signin">{{ $t('menu.Login') }}</button>
</form>
</ul>
</div> </div>
</div> </div>
</nav> </nav>
@ -122,6 +125,7 @@ import { isLoggedIn, logout } from '@/utils/authentication';
import { BIconEgg, BIconSun, BIconTree } from 'bootstrap-icons-vue'; import { BIconEgg, BIconSun, BIconTree } from 'bootstrap-icons-vue';
import { defineComponent } from 'vue'; import { defineComponent } from 'vue';
import LocaleSwitcher from './LocaleSwitcher.vue'; import LocaleSwitcher from './LocaleSwitcher.vue';
import ThemeSwitcher from './ThemeSwitcher.vue';
export default defineComponent({ export default defineComponent({
components: { components: {
@ -129,6 +133,7 @@ export default defineComponent({
BIconSun, BIconSun,
BIconTree, BIconTree,
LocaleSwitcher, LocaleSwitcher,
ThemeSwitcher,
}, },
data() { data() {
return { return {

View File

@ -0,0 +1,106 @@
<template>
<li class="nav-item dropdown">
<button class="btn btn-link nav-link py-2 px-0 px-lg-2 dropdown-toggle d-flex align-items-center" id="bd-theme"
type="button" aria-expanded="false" data-bs-toggle="dropdown" data-bs-display="static"
aria-label="Toggle theme (auto)">
<BIconCircleHalf class="bi my-1 theme-icon-active" />
</button>
<ul class="dropdown-menu dropdown-menu-end">
<li>
<button type="button" class="dropdown-item d-flex align-items-center" data-bs-theme-value="light"
aria-pressed="false">
<BIconSunFill class="bi me-2 opacity-50 theme-icon" />
{{ $t('localeswitcher.Light') }}
</button>
</li>
<li>
<button type="button" class="dropdown-item d-flex align-items-center" data-bs-theme-value="dark"
aria-pressed="false">
<BIconMoonStarsFill class="bi me-2 opacity-50 theme-icon" />
{{ $t('localeswitcher.Dark') }}
</button>
</li>
<li>
<button type="button" class="dropdown-item d-flex align-items-center active" data-bs-theme-value="auto"
aria-pressed="true">
<BIconCircleHalf class="bi me-2 opacity-50 theme-icon" />
{{ $t('localeswitcher.Auto') }}
</button>
</li>
</ul>
</li>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import {
BIconCircleHalf,
BIconSunFill,
BIconMoonStarsFill,
} from 'bootstrap-icons-vue';
export default defineComponent({
name: "ThemeSwitcher",
components: {
BIconCircleHalf,
BIconSunFill,
BIconMoonStarsFill,
},
data() {
return {
storedTheme: 'auto',
};
},
methods: {
getPreferredTheme() {
if (this.storedTheme) {
return this.storedTheme;
}
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
},
setTheme(theme: string) {
if (theme === 'auto' && window.matchMedia('(prefers-color-scheme: dark)').matches) {
document.documentElement.setAttribute('data-bs-theme', 'dark');
} else {
document.documentElement.setAttribute('data-bs-theme', theme);
}
},
showActiveTheme(theme: string) {
const activeThemeIcon = document.querySelector('.theme-icon-active');
const btnToActive = document.querySelector(`[data-bs-theme-value="${theme}"]`);
const svgOfActiveBtn = btnToActive?.querySelector('.theme-icon');
document.querySelectorAll('[data-bs-theme-value]').forEach(element => {
element.classList.remove('active');
})
btnToActive?.classList.add('active');
if (svgOfActiveBtn) {
activeThemeIcon?.replaceChildren('*', svgOfActiveBtn?.cloneNode(true));
}
},
},
mounted() {
this.storedTheme = localStorage.getItem('theme') || 'auto';
this.setTheme(this.getPreferredTheme());
this.showActiveTheme(this.getPreferredTheme());
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
if (this.storedTheme !== 'light' && this.storedTheme !== 'dark') {
this.setTheme(this.getPreferredTheme());
}
});
document.querySelectorAll('[data-bs-theme-value]')
.forEach(toggle => {
toggle.addEventListener('click', () => {
const theme = toggle.getAttribute('data-bs-theme-value') || 'auto';
localStorage.setItem('theme', theme);
this.setTheme(theme);
this.showActiveTheme(theme);
})
});
},
});
</script>

View File

@ -28,6 +28,11 @@
"base": { "base": {
"Loading": "Lade..." "Loading": "Lade..."
}, },
"localeswitcher": {
"Dark": "Dunkel",
"Light": "Hell",
"Auto": "Automatisch"
},
"apiresponse": { "apiresponse": {
"1001": "Einstellungen gespeichert!", "1001": "Einstellungen gespeichert!",
"1002": "Keine Werte gefunden!", "1002": "Keine Werte gefunden!",

View File

@ -28,6 +28,11 @@
"base": { "base": {
"Loading": "Loading..." "Loading": "Loading..."
}, },
"localeswitcher": {
"Dark": "Dark",
"Light": "Light",
"Auto": "Auto"
},
"apiresponse": { "apiresponse": {
"1001": "Settings saved!", "1001": "Settings saved!",
"1002": "No values found!", "1002": "No values found!",

View File

@ -27,6 +27,11 @@
"base": { "base": {
"Loading": "Chargement..." "Loading": "Chargement..."
}, },
"localeswitcher": {
"Dark": "Dark",
"Light": "Light",
"Auto": "Auto"
},
"apiresponse": { "apiresponse": {
"1001": "Paramètres enregistrés !", "1001": "Paramètres enregistrés !",
"1002": "Aucune valeur trouvée !", "1002": "Aucune valeur trouvée !",

View File

@ -332,10 +332,10 @@
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3"
integrity sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ== integrity sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==
"@types/node@^18.14.2": "@types/node@^18.14.6":
version "18.14.2" version "18.14.6"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.14.2.tgz#c076ed1d7b6095078ad3cf21dfeea951842778b1" resolved "https://registry.yarnpkg.com/@types/node/-/node-18.14.6.tgz#ae1973dd2b1eeb1825695bb11ebfb746d27e3e93"
integrity sha512-1uEQxww3DaghA0RxqHx0O0ppVlo43pJhepY51OxuQIKHpjbnYLA7vcdwioNPzIqmC2u3I/dmylcqjlh0e7AyUA== integrity sha512-93+VvleD3mXwlLI/xASjw0FzKcwzl3OdTCzm1LaRfqgS21gfFtK3zDXM5Op9TeeMsJVOaJ2VRDpT9q4Y3d0AvA==
"@types/spark-md5@^3.0.2": "@types/spark-md5@^3.0.2":
version "3.0.2" version "3.0.2"
@ -701,10 +701,10 @@ bootstrap-icons-vue@^1.8.1:
resolved "https://registry.yarnpkg.com/bootstrap-icons-vue/-/bootstrap-icons-vue-1.8.1.tgz#ce4a0c1f6efe41dabcc1341f2cb191d307fbaf50" resolved "https://registry.yarnpkg.com/bootstrap-icons-vue/-/bootstrap-icons-vue-1.8.1.tgz#ce4a0c1f6efe41dabcc1341f2cb191d307fbaf50"
integrity sha512-uItRULwQz0epETi9x/RBEqfjHmTAmkIIczpH1R6L9T6yyaaijk0826PzTWnWNm15tw66JT/8GNuXjB0HI5PHLw== integrity sha512-uItRULwQz0epETi9x/RBEqfjHmTAmkIIczpH1R6L9T6yyaaijk0826PzTWnWNm15tw66JT/8GNuXjB0HI5PHLw==
bootstrap@^5.2.3: bootstrap@^5.3.0-alpha1:
version "5.2.3" version "5.3.0-alpha1"
resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-5.2.3.tgz#54739f4414de121b9785c5da3c87b37ff008322b" resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-5.3.0-alpha1.tgz#380629c4367893f02f7879a01ea3ae0f94e2e70e"
integrity sha512-cEKPM+fwb3cT8NzQZYEu4HilJ3anCrWqh3CHAok1p9jXqMPsPTBhU25fBckEJHJ/p+tTxTFTsFQGM+gaHpi3QQ== integrity sha512-ABZpKK4ObS3kKlIqH+ZVDqoy5t/bhFG0oHTAzByUdon7YIom0lpCeTqRniDzJmbtcWkNe800VVPBiJgxSYTYew==
brace-expansion@^1.1.7: brace-expansion@^1.1.7:
version "1.1.11" version "1.1.11"