Skip to content

Commit

Permalink
Merge remote-tracking branch 'tbnobody/OpenDTU/master' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
helgeerbe committed Mar 7, 2023
2 parents 6dd34a8 + cbbbc21 commit 6a89ae9
Show file tree
Hide file tree
Showing 12 changed files with 173 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
.vscode/settings.json
platformio-device-monitor*.log
platformio_override.ini
.DS_Store
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:5632374>
* <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 the WebApp
Expand Down Expand Up @@ -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)
- [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)
- [BreakoutBoard - sample printed circuit board for OpenDTU and Ahoy](https://github.com/dokuhn/openDTU-BreakoutBoard)
8 changes: 7 additions & 1 deletion docs/Web-API.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ may be incomplete
| -------- | --- | -- |
| Get | yes | /api/config/get |
| Post | yes | /api/config/delete |
| Get | yes | /api/config/list |
| Post | yes | /api/config/upload |
| Get+Post | yes | /api/device/config |
| Get | no | /api/devinfo/status |
| Get+Post | yes | /api/dtu/config |
| Get | no | /api/eventlog/status?inv=inverter-serialnumber |
Expand All @@ -21,6 +23,7 @@ may be incomplete
| Post | yes | /api/limit/config |
| Get | no | /api/limit/status |
| Get | no | /api/livedata/status |
| Post | yes | /api/maintenance/reboot |
| Get+Post | yes | /api/mqtt/config |
| Get | no | /api/mqtt/status |
| Get+Post | yes | /api/network/config |
Expand All @@ -30,7 +33,9 @@ may be incomplete
| Get+Post | yes | /api/ntp/time |
| Get | no | /api/power/status |
| 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 |


Expand All @@ -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.
- 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
- If you disable the readonly access to the web API, every endpoint requires authentication


### Get information
Expand Down
12 changes: 6 additions & 6 deletions lib/ResetReason/src/ResetReason.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ String ResetReasonClass::get_reset_reason_verbose(uint8_t cpu_id)
case 3:
reason_str = F("Software reset digital core");
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:
reason_str = F("Legacy watch dog reset digital core");
break;
#endif
case 5:
reason_str = F("Deep Sleep reset digital core");
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:
reason_str = F("Reset by SLC module, reset digital core");
break;
Expand All @@ -68,7 +68,7 @@ String ResetReasonClass::get_reset_reason_verbose(uint8_t cpu_id)
case 13:
reason_str = F("RTC Watch dog Reset CPU");
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:
reason_str = F("for APP CPU, reset by PRO CPU");
break;
Expand Down Expand Up @@ -100,15 +100,15 @@ String ResetReasonClass::get_reset_reason_short(uint8_t cpu_id)
case 3:
reason_str = F("SW_RESET");
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:
reason_str = F("OWDT_RESET");
break;
#endif
case 5:
reason_str = F("DEEPSLEEP_RESET");
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:
reason_str = F("SDIO_RESET");
break;
Expand All @@ -134,7 +134,7 @@ String ResetReasonClass::get_reset_reason_short(uint8_t cpu_id)
case 13:
reason_str = F("RTCWDT_CPU_RESET");
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:
reason_str = F("EXT_CPU_RESET");
break;
Expand Down
10 changes: 10 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,13 @@ build_flags = ${env.build_flags}
-DHOYMILES_PIN_IRQ=16
-DHOYMILES_PIN_CE=17
-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
4 changes: 2 additions & 2 deletions webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"dependencies": {
"@popperjs/core": "^2.11.6",
"bootstrap": "^5.2.3",
"bootstrap": "^5.3.0-alpha1",
"bootstrap-icons-vue": "^1.8.1",
"mitt": "^3.0.0",
"spark-md5": "^3.0.2",
Expand All @@ -24,7 +24,7 @@
"@intlify/unplugin-vue-i18n": "^0.8.2",
"@rushstack/eslint-patch": "^1.2.0",
"@types/bootstrap": "^5.2.6",
"@types/node": "^18.14.2",
"@types/node": "^18.14.6",
"@types/spark-md5": "^3.0.2",
"@vitejs/plugin-vue": "^4.0.0",
"@vue/eslint-config-typescript": "^11.0.2",
Expand Down
17 changes: 11 additions & 6 deletions webapp/src/components/NavBar.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<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">
<router-link @click="onClick" class="navbar-brand" to="/">
<span v-if="isXmas" class="text-success">
Expand Down Expand Up @@ -107,11 +107,14 @@
<router-link @click="onClick" class="nav-link" to="/about">{{ $t('menu.About') }}</router-link>
</li>
</ul>
<form class="d-flex" role="search">
<LocaleSwitcher class="me-2" />
<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 class="navbar-nav flex-row flex-wrap ms-md-auto">
<ThemeSwitcher class="me-2" />
<form class="d-flex" role="search">
<LocaleSwitcher class="me-2" />
<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>
</nav>
Expand All @@ -122,13 +125,15 @@ import { isLoggedIn, logout } from '@/utils/authentication';
import { BIconEgg, BIconSun, BIconTree } from 'bootstrap-icons-vue';
import { defineComponent } from 'vue';
import LocaleSwitcher from './LocaleSwitcher.vue';
import ThemeSwitcher from './ThemeSwitcher.vue';
export default defineComponent({
components: {
BIconEgg,
BIconSun,
BIconTree,
LocaleSwitcher,
ThemeSwitcher,
},
data() {
return {
Expand Down
106 changes: 106 additions & 0 deletions webapp/src/components/ThemeSwitcher.vue
Original file line number Diff line number Diff line change
@@ -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>
5 changes: 5 additions & 0 deletions webapp/src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
"base": {
"Loading": "Lade..."
},
"localeswitcher": {
"Dark": "Dunkel",
"Light": "Hell",
"Auto": "Automatisch"
},
"apiresponse": {
"1001": "Einstellungen gespeichert!",
"1002": "Keine Werte gefunden!",
Expand Down
5 changes: 5 additions & 0 deletions webapp/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
"base": {
"Loading": "Loading..."
},
"localeswitcher": {
"Dark": "Dark",
"Light": "Light",
"Auto": "Auto"
},
"apiresponse": {
"1001": "Settings saved!",
"1002": "No values found!",
Expand Down
5 changes: 5 additions & 0 deletions webapp/src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
"base": {
"Loading": "Chargement..."
},
"localeswitcher": {
"Dark": "Dark",
"Light": "Light",
"Auto": "Auto"
},
"apiresponse": {
"1001": "Paramètres enregistrés !",
"1002": "Aucune valeur trouvée !",
Expand Down
16 changes: 8 additions & 8 deletions webapp/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,10 @@
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3"
integrity sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==

"@types/node@^18.14.2":
version "18.14.2"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.14.2.tgz#c076ed1d7b6095078ad3cf21dfeea951842778b1"
integrity sha512-1uEQxww3DaghA0RxqHx0O0ppVlo43pJhepY51OxuQIKHpjbnYLA7vcdwioNPzIqmC2u3I/dmylcqjlh0e7AyUA==
"@types/node@^18.14.6":
version "18.14.6"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.14.6.tgz#ae1973dd2b1eeb1825695bb11ebfb746d27e3e93"
integrity sha512-93+VvleD3mXwlLI/xASjw0FzKcwzl3OdTCzm1LaRfqgS21gfFtK3zDXM5Op9TeeMsJVOaJ2VRDpT9q4Y3d0AvA==

"@types/spark-md5@^3.0.2":
version "3.0.2"
Expand Down Expand Up @@ -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"
integrity sha512-uItRULwQz0epETi9x/RBEqfjHmTAmkIIczpH1R6L9T6yyaaijk0826PzTWnWNm15tw66JT/8GNuXjB0HI5PHLw==

bootstrap@^5.2.3:
version "5.2.3"
resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-5.2.3.tgz#54739f4414de121b9785c5da3c87b37ff008322b"
integrity sha512-cEKPM+fwb3cT8NzQZYEu4HilJ3anCrWqh3CHAok1p9jXqMPsPTBhU25fBckEJHJ/p+tTxTFTsFQGM+gaHpi3QQ==
bootstrap@^5.3.0-alpha1:
version "5.3.0-alpha1"
resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-5.3.0-alpha1.tgz#380629c4367893f02f7879a01ea3ae0f94e2e70e"
integrity sha512-ABZpKK4ObS3kKlIqH+ZVDqoy5t/bhFG0oHTAzByUdon7YIom0lpCeTqRniDzJmbtcWkNe800VVPBiJgxSYTYew==

brace-expansion@^1.1.7:
version "1.1.11"
Expand Down

0 comments on commit 6a89ae9

Please sign in to comment.