Skip to content

Commit

Permalink
Merge pull request #1649 from openWB/master
Browse files Browse the repository at this point in the history
Merge master into Release
  • Loading branch information
LKuemmel authored Jun 4, 2024
2 parents a6b6486 + 85f981c commit 417a306
Show file tree
Hide file tree
Showing 605 changed files with 6,673 additions and 5,885 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
.DS_Store
.ftp*
.vite
.vimrc
.vscode/*
__pycache__/
node_modules/
Expand Down
16 changes: 16 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Security Policy

## Supported Versions

The following versions are maintained and supported:

| Version | Supported |
| ------- | ------------------ |
| 2.1.x | :white_check_mark: |
| 2.0.x | :x: |
| <2.0 | :x: |

## Reporting a Vulnerability

Please use the contact form at openwb.de for reporting a found vulnerability:
https://openwb.de/main/?page_id=484
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions data/config/mosquitto/mosquitto.acl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# openwb-version:2
# allow publishing set topics
topic write openWB/set/#
# allow clearing system messages
topic write openWB/system/messages/#
# allow clearing client messages
pattern write openWB/command/%c/messages/#
# allow global read access
topic read openWB/#
# allow read access for remote support topics
topic read openWB-remote/#
# allow brach "others" for devices other than openWB
topic readwrite others/#
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# openwb-version:1
# openwb-version:2
persistence true
persistence_location /var/lib/mosquitto/
log_type error
log_type warning
log_dest file /var/log/mosquitto/mosquitto.log
# timestamp format currently not supported in stretch or buster with mosquitto 1.5
# only enable on bullseye and newer
# log_timestamp_format %Y-%m-%dT%H:%M:%S
log_timestamp_format %Y-%m-%dT%H:%M:%S

include_dir /etc/mosquitto/conf.d
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# openwb-version:1
# openwb-version:2
persistence true
persistence_location /var/lib/mosquitto_local/

Expand All @@ -7,6 +7,6 @@ log_type warning
log_dest file /var/log/mosquitto/mosquitto_local.log
# timestamp format currently not supported in stretch or buster with mosquitto 1.5
# only enable on bullseye and newer
# log_timestamp_format %Y-%m-%dT%H:%M:%S
log_timestamp_format %Y-%m-%dT%H:%M:%S

include_dir /etc/mosquitto/conf_local.d
File renamed without changes.
32 changes: 24 additions & 8 deletions data/config/openwb.conf → data/config/mosquitto/openwb.conf
Original file line number Diff line number Diff line change
@@ -1,28 +1,44 @@
# openwb-version:2
listener 9001
# openwb-version:3

# required to restrict access per listener
per_listener_settings true

# prevent too many inactive connections from buggy clients
# closes inactive connections after 4 hours
persistent_client_expiration 4h

# this websocket is used by local apache
# todo: restrict access:
# listener 9001 localhost
listener 9001
protocol websockets
allow_anonymous true
acl_file /etc/mosquitto/mosquitto.acl

# public secure websocket listener
listener 9002
protocol websockets
allow_anonymous true
certfile /etc/mosquitto/certs/openwb.pem
keyfile /etc/mosquitto/certs/openwb.key
acl_file /etc/mosquitto/mosquitto.acl

# local bridge listener
listener 1884 localhost
protocol mqtt
allow_anonymous true

# public unsecure mqtt listener
# todo: remove unsecure listeners
listener 1883
# todo: restrict access:
# listener 1883 localhost
protocol mqtt
allow_anonymous true
acl_file /etc/mosquitto/mosquitto.acl

# public secure mqtt listener
listener 8883
protocol mqtt
allow_anonymous true
certfile /etc/mosquitto/certs/openwb.pem
keyfile /etc/mosquitto/certs/openwb.key

# prevent too many inactive connections from buggy clients
# closes inactive connections after 4 hours
persistent_client_expiration 4h
acl_file /etc/mosquitto/mosquitto.acl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# openwb-version:12
# openwb-version:13
listener 1886 localhost
allow_anonymous true

connection bridge-01
address localhost:1883
address localhost:1884
topic openWB/set/# both 2

topic openWB/LegacySmartHome/# out 2
Expand Down
16 changes: 16 additions & 0 deletions docs/NextCloud als Sicherungs-Cloud einrichten.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,19 @@ Zunächst einen neuen Ordner erstellen/auswählen, in den die Sicherungen hochge
3. Link kopieren

![NextCloud Ordner freigeben](NextCloud.png)

Diesen Link in das Feld Cloud-URL in der openWB unter System -> Datenverwaltung -> Automatische Sicherung in einen Cloud-Dienst eintragen und Benutzername sowie Passwort freilassen (speichern drücken nicht vergessen)!

Alternativ:
Falls es Probleme gibt kann der Link auch folgendermaßen eingetragen werden:
Freigabelink z.B.: https://kim.nl.tab.digital/s/tUbHHrEdGltSRgx

Wahl: BackupCloud: NextCloud
Unterpunkt: Einstellungen für Backup-Cloud Modul "NextCloud"
Cloud-URL: https://mydomain.de z.B.: https://kim.nl.tab.digital OHNE /s/ oder /
Benutzername: dein shared token, also z.B.: tUbHHrEdGltSRgx
Passwort: kann leergelassen oder irgendetwas eingetragen werden, spielt keine Rolle

Beide Varianten wurden getestet und funktionieren.

Stand 10. April 2024
77 changes: 74 additions & 3 deletions docs/Samba als Sicherung einrichten.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,88 @@
Zunächst einen neuen Ordner erstellen/auswählen, in den die Sicherungen hochgeladen werden sollen.

Nachfolgende Schritte müssen auf dem Bereitstellenden system geamcht werden
Nachfolgende Schritte müssen auf dem Bereitstellenden system gemacht werden
1. SMB Freigabe erstellen (Auf NAS etc.)
2. User einrichten und berechtigen - R/W

Nachfolgende Schritte müssen in openwb gemachte werden.
Nachfolgende Schritte müssen in openWB gemacht werden.

1. IP Adresse oder Name (Am besten FQDN) im Feld Server hinterlegen
* IP: z.B 192.168.178.1
* Name z.B. mein-server
* FQDN z.B mein-server.fritz.box
2. Share angeben in dem das Backup gespeicher werden soll
2. Share angeben in dem das Backup gespeichert werden soll
3. Optional können ein bis n Unterordner angegeben werden. Diese müssen immer mit / getrennt werden und auch am Ende muss ein / stehen
* Beispiel: test/ oder aber test1/test2/test/
4. Benutzer und Passwort in die jeweilegen Felder eintragen

![Samba nutzen](Samba.png)

Ergänzungen:
Bei manchen Systemen kann es notwendig sein das Mindest-SMB-Protokoll auf SMB2 zu setzen.

Anleitung für Samba Server auf einem Raspberry Pi (z.B.: Stand alone)

1. Installieren von Samba
sudo apt-get update
sudo apt-get install samba samba-common smbclient
2. Prüfen ob Samba läuft
sudo service smbd status
sudo service nmbd status
3. Samba User anlegen
sudo useradd testsmb
Optional:
4. Falls users nicht vorhanden: sudo groupadd users
check mit getent group
5. Hinzufügen des Samba Users zur Gruppe users
sudo usermod -aG users testsmb
6. Ordner anlegen in /home
sudo mkdir smb
sudo mkdir smb/testsmb
sudo mkdir smb/testsmb/test
7. Besitzer ändern
sudo chown testsmb /home/smb/testsmb
sudo chown testsmb /home/smb/testsmb/test
8. Konfigurationsdatei von Samba sichern
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf_backup
Konfigurationsdatei smb.conf anpassen
sudo nano /etc/samba/smb.conf
[global]
workgroup = WORKGROUP
security = user
encrypt passwords = yes
client min protocol = SMB2
client max protocol = SMB3
bis zum Ende der Datei scrollen und folgende Eintragungen vornehmen:
[testsmb]
comment = Samba-Test-Share
valid users = testsmb
path = /home/smb/testsmb
read only = no

9. Testen ob die smb.conf noch funktioniert
testparm
10. Benutzer aktivieren
sudo smbpasswd -a testsmb
New SMB password: testSMB
Retype new SMB password: testSMB
Optional
11. Sichergehen, dass Benutzer aktiviert ist
sudo smbpasswd -e testsmb
12. IP-Adresse des Raspberry Pis notieren
ifconfig -> z.B.: 192.168.43.81
13. Neustart von Samba nach Änderung der Konfiguration
sudo service smbd restart
sudo service nmbd restart

Der Samba Dienst ist nun eingerichtet und konfiguriert. Alternativ können auch andere Benutzergruppen mit anderen Berechtigungen konfiguriert werden.

In openWB unter System -> Datenverwaltung -> Sicherung / Wiederherstellung unter Automatische Sicherung in einen Cloud-Dienst als Backup-Cloud Samba auswählen und folgende Einstellungen für Backup-Cloud Modul "Samba" eintragen:
Server: IP_Adresse des Raspberry Pis z.B.: 192.168.43.81
Freigabe: testsmb
Unterordner: test/
Benutzer: testsmb
Kennwort: testSMB

Speichern drücken und testen durch klicken auf Sicherung erstellen und hochladen

Stand 08. April 2024
4 changes: 2 additions & 2 deletions docs/samples/samples_gui/bat.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export default {
emits: ["update:configuration"],
props: {
configuration: { type: Object, required: true },
deviceId: { default: undefined },
componentId: { required: true },
deviceId: { type: Number, default: undefined },
componentId: { type: Number, required: true },
},
methods: {
updateConfiguration(event, path = undefined) {
Expand Down
4 changes: 2 additions & 2 deletions docs/samples/samples_gui/counter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export default {
emits: ["update:configuration"],
props: {
configuration: { type: Object, required: true },
deviceId: { default: undefined },
componentId: { required: true },
deviceId: { type: Number, default: undefined },
componentId: { type: Number, required: true },
},
methods: {
updateConfiguration(event, path = undefined) {
Expand Down
2 changes: 1 addition & 1 deletion docs/samples/samples_gui/device.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default {
emits: ["update:configuration"],
props: {
configuration: { type: Object, required: true },
deviceId: { default: undefined },
deviceId: { type: Number, default: undefined },
},
methods: {
updateConfiguration(event, path = undefined) {
Expand Down
4 changes: 2 additions & 2 deletions docs/samples/samples_gui/inverter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export default {
emits: ["update:configuration"],
props: {
configuration: { type: Object, required: true },
deviceId: { default: undefined },
componentId: { required: true },
deviceId: { type: Number, default: undefined },
componentId: { type: Number, required: true },
},
methods: {
updateConfiguration(event, path = undefined) {
Expand Down
14 changes: 8 additions & 6 deletions openwb-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ fi
echo "updating mosquitto config file"
systemctl stop mosquitto
sleep 2
cp -a "${OPENWBBASEDIR}/data/config/mosquitto.conf" /etc/mosquitto/mosquitto.conf
cp "${OPENWBBASEDIR}/data/config/openwb.conf" /etc/mosquitto/conf.d/openwb.conf
cp -a "${OPENWBBASEDIR}/data/config/mosquitto/mosquitto.conf" /etc/mosquitto/mosquitto.conf
cp "${OPENWBBASEDIR}/data/config/mosquitto/openwb.conf" /etc/mosquitto/conf.d/openwb.conf
cp "${OPENWBBASEDIR}/data/config/mosquitto/mosquitto.acl" /etc/mosquitto/mosquitto.acl
sudo cp /etc/ssl/certs/ssl-cert-snakeoil.pem /etc/mosquitto/certs/openwb.pem
sudo cp /etc/ssl/private/ssl-cert-snakeoil.key /etc/mosquitto/certs/openwb.key
sudo chgrp mosquitto /etc/mosquitto/certs/openwb.key
Expand All @@ -73,7 +74,7 @@ if [ ! -f /etc/init.d/mosquitto_local ]; then
echo "setting up mosquitto local instance"
install -d -m 0755 -o root -g root /etc/mosquitto/conf_local.d/
install -d -m 0755 -o mosquitto -g root /var/lib/mosquitto_local
cp "${OPENWBBASEDIR}/data/config/mosquitto_local_init" /etc/init.d/mosquitto_local
cp "${OPENWBBASEDIR}/data/config/mosquitto/mosquitto_local_init" /etc/init.d/mosquitto_local
chown root:root /etc/init.d/mosquitto_local
chmod 755 /etc/init.d/mosquitto_local
systemctl daemon-reload
Expand All @@ -82,13 +83,14 @@ else
systemctl stop mosquitto_local
sleep 2
fi
cp -a "${OPENWBBASEDIR}/data/config/mosquitto_local.conf" /etc/mosquitto/mosquitto_local.conf
cp -a "${OPENWBBASEDIR}/data/config/openwb_local.conf" /etc/mosquitto/conf_local.d/
cp -a "${OPENWBBASEDIR}/data/config/mosquitto/mosquitto_local.conf" /etc/mosquitto/mosquitto_local.conf
cp -a "${OPENWBBASEDIR}/data/config/mosquitto/openwb_local.conf" /etc/mosquitto/conf_local.d/
systemctl start mosquitto_local
echo "mosquitto done"

# apache
echo -n "replacing apache default page..."
cp "${OPENWBBASEDIR}/data/config/apache/000-default.conf" "/etc/apache2/sites-available/"
cp "${OPENWBBASEDIR}/index.html" /var/www/html/index.html
echo "done"
echo -n "fix upload limit..."
Expand All @@ -105,7 +107,7 @@ echo -n "enabling apache ssl module..."
a2enmod ssl
a2enmod proxy_wstunnel
sudo a2dissite default-ssl
sudo cp "${OPENWBBASEDIR}/data/config/apache-openwb-ssl.conf" /etc/apache2/sites-available/
sudo cp "${OPENWBBASEDIR}/data/config/apache/apache-openwb-ssl.conf" /etc/apache2/sites-available/
sudo a2ensite apache-openwb-ssl
echo "done"
echo -n "restarting apache..."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def test_surplus(params: ParamsSurplus, all_cp_pv_charging_3p, all_cp_charging_3
expected_current_cp5=6,
expected_raw_power_left=37520.0,
expected_surplus_power_left=10575.0,
expected_reserved_surplus=460,
expected_reserved_surplus=0,
expected_released_surplus=0)
]

Expand Down
12 changes: 6 additions & 6 deletions packages/control/auto_phase_switch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def __init__(self,
Params("1to3, enough power, start timer", max_current_single_phase=16, timestamp_auto_phase_switch=None,
phases_to_use=1, required_current=6, evu_surplus=-800, reserved_evu_overhang=0, get_currents=[15.6, 0, 0],
get_power=3450, state=ChargepointState.CHARGING_ALLOWED, expected_phases_to_use=1, expected_current=6,
expected_message="Umschaltverzögerung von 1 auf 3 Phasen für 7.0 Min aktiv.",
expected_message=Ev.PHASE_SWITCH_DELAY_TEXT.format("Umschaltung von 1 auf 3", "7 Min. 0 Sek."),
expected_timestamp_auto_phase_switch=1652683252.0,
expected_state=ChargepointState.PHASE_SWITCH_DELAY),
Params("1to3, not enough power, start timer", max_current_single_phase=16, timestamp_auto_phase_switch=None,
Expand All @@ -76,14 +76,14 @@ def __init__(self,
timestamp_auto_phase_switch=1652682952.0, phases_to_use=1, required_current=6,
evu_surplus=-1200, reserved_evu_overhang=460, get_currents=[15.6, 0, 0], get_power=3450,
state=ChargepointState.PHASE_SWITCH_DELAY, expected_phases_to_use=1, expected_current=6,
expected_message="Umschaltverzögerung von 1 auf 3 Phasen für 7.0 Min aktiv.",
expected_message=Ev.PHASE_SWITCH_DELAY_TEXT.format("Umschaltung von 1 auf 3", "2 Min. 0 Sek."),
expected_timestamp_auto_phase_switch=1652683252.0,
expected_state=ChargepointState.PHASE_SWITCH_DELAY),
Params("1to3, not enough power, timer not expired", max_current_single_phase=16,
timestamp_auto_phase_switch=1652682952.0, phases_to_use=1, required_current=6,
evu_surplus=0, reserved_evu_overhang=460, get_currents=[15.6, 0, 0], get_power=3450,
state=ChargepointState.PHASE_SWITCH_DELAY, expected_phases_to_use=1, expected_current=6,
expected_message=f"Umschaltverzögerung von 1 auf 3 Phasen abgebrochen{Ev.NOT_ENOUGH_POWER}",
expected_message=f"Verzögerung für die Umschaltung von 1 auf 3 Phasen abgebrochen{Ev.NOT_ENOUGH_POWER}",
expected_timestamp_auto_phase_switch=1652683252.0,
expected_state=ChargepointState.CHARGING_ALLOWED),
Params("1to3, enough power, timer expired", max_current_single_phase=16,
Expand All @@ -96,22 +96,22 @@ def __init__(self,
phases_to_use=3, required_current=6, evu_surplus=0, reserved_evu_overhang=0,
get_currents=[4.5, 4.4, 5.8], get_power=3381, state=ChargepointState.CHARGING_ALLOWED,
expected_phases_to_use=3, expected_current=6,
expected_message="Umschaltverzögerung von 3 auf 1 Phasen für 9.0 Min aktiv.",
expected_message="Umschaltung von 3 auf 1 Phasen in 9 Min. 0 Sek..",
expected_timestamp_auto_phase_switch=1652683252.0,
expected_state=ChargepointState.PHASE_SWITCH_DELAY),
Params("3to1, not enough power, timer not expired", max_current_single_phase=16,
timestamp_auto_phase_switch=1652682952.0,
phases_to_use=3, required_current=6, evu_surplus=0, reserved_evu_overhang=-460,
get_currents=[4.5, 4.4, 5.8], get_power=3381, state=ChargepointState.PHASE_SWITCH_DELAY,
expected_phases_to_use=3, expected_current=6,
expected_message="Umschaltverzögerung von 3 auf 1 Phasen für 9.0 Min aktiv.",
expected_message="Umschaltung von 3 auf 1 Phasen in 4 Min. 0 Sek..",
expected_timestamp_auto_phase_switch=1652683252.0,
expected_state=ChargepointState.PHASE_SWITCH_DELAY),
Params("3to1, enough power, timer not expired", max_current_single_phase=16,
timestamp_auto_phase_switch=1652682952.0, phases_to_use=3, required_current=6,
evu_surplus=-860, reserved_evu_overhang=0, get_currents=[4.5, 4.4, 5.8],
get_power=3381, state=ChargepointState.PHASE_SWITCH_DELAY, expected_phases_to_use=3, expected_current=6,
expected_message=f"Umschaltverzögerung von 3 auf 1 Phasen abgebrochen{Ev.ENOUGH_POWER}",
expected_message=f"Verzögerung für die Umschaltung von 3 auf 1 Phasen abgebrochen{Ev.ENOUGH_POWER}",
expected_timestamp_auto_phase_switch=1652683252.0,
expected_state=ChargepointState.CHARGING_ALLOWED),
Params("3to1, not enough power, timer expired", max_current_single_phase=16,
Expand Down
Loading

0 comments on commit 417a306

Please sign in to comment.