Skip to content

Commit

Permalink
Revert "smarthome parameter 2.0"
Browse files Browse the repository at this point in the history
This reverts commit 15580f9.
  • Loading branch information
okaegi committed Jul 8, 2024
1 parent 15580f9 commit 8d4dbae
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 48 deletions.
3 changes: 1 addition & 2 deletions packages/helpermodules/update_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,7 @@ class UpdateConfig:
"^openWB/LegacySmartHome/config/get/Devices/[0-9]+/device_type$",
"^openWB/LegacySmartHome/config/get/Devices/[0-9]+/device_updatesec$",
"^openWB/LegacySmartHome/config/get/Devices/[0-9]+/device_username$",
"^openWB/LegacySmartHome/Devices/[0-9]+/device_manual_control$",
"^openWB/LegacySmartHome/Devices/[0-9]+/mode$",
"^openWB/LegacySmartHome/config/set/Devices/[0-9]+/mode$",
"^openWB/LegacySmartHome/Devices/[0-9]+/WHImported_temp$",
"^openWB/LegacySmartHome/Devices/[0-9]+/RunningTimeToday$",
"^openWB/LegacySmartHome/Devices/[0-9]+/oncountnor$",
Expand Down
68 changes: 22 additions & 46 deletions packages/smarthome/smartcommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@
from modules.smarthome.acthor.smartacthor import Sacthor
from modules.smarthome.avmhomeautomation.smartavm import Savm
from smarthome.smartbase import Sbase
from typing import Dict, Tuple, Any
from typing import Dict, Tuple
import paho.mqtt.client as mqtt
import re
import time
import os
import math
import logging
log = logging.getLogger(__name__)
mydevices = [] # type: [mydevice]
mydevices = []
mqtt_cache = {} # type: Dict[str, str]
parammqtt = [] # type: [str, str, str]
parammqtt = []
# will be populated with open 1.9 / openwb 2.0 specifc param
mqttcg = 'none'
mqttcs = 'none'
Expand All @@ -42,7 +42,7 @@
firststart = True


def on_connect(client: mqtt.Client, userdata: Any, flags: Dict, rc: int) -> None:
def on_connect(client: mqtt.Client, userdata, flags: Dict, rc: int) -> None:
global mqttcg
global mqttsdevstat
# mqttcg = 'openWB/config/get/SmartHome/'
Expand Down Expand Up @@ -79,7 +79,7 @@ def logmqgl(keyword: str, value: str) -> None:
'" -r -m "' + str(value) + '"'), file=f)


def on_message(client: mqtt.Client, userdata: Any, msg: mqtt.MQTTMessage) -> None:
def on_message(client: mqtt.Client, userdata, msg: mqtt.MQTTMessage) -> None:
# wenn exception hier wird mit nächster msg weitergemacht
# macht paho unter phyton 3 immer so
# für neuer python 3.7 version gibt es absturz
Expand Down Expand Up @@ -150,10 +150,6 @@ def getdevicevalues(uberschuss: int, uberschussoffset: int, pvwatt: int, charges
for keyread, value in mydevice.mqtt_param.items():
key = mqttsdevstat + keyread
mqtt_all[key] = value
topic = mqttsdevstat + '/' + str(mydevice.device_nummer) + '/mode'
mqtt_all[topic] = str(mydevice.device_manual)
topic = mqttsdevstat + '/' + str(mydevice.device_nummer) + '/device_manual_control'
mqtt_all[topic] = str(mydevice.device_manual_control)
# device_total_watt is needed for calculation the proper überschuss
# (including switchable smarthomedevices)
if ramdiskwrite:
Expand Down Expand Up @@ -407,7 +403,6 @@ def loadregelvars(wattbezug: int, speicherleistung: int, speichersoc: int,
pvwatt: int, chargestatus: bool) -> Tuple[int, int]:
global maxspeicher
global mydevices
global firststart
uberschuss = wattbezug + speicherleistung
uberschussoffset = wattbezug + speicherleistung - maxspeicher
log.info("EVU Bezug(-)/Einspeisung(+): " + str(wattbezug) +
Expand All @@ -426,26 +421,23 @@ def loadregelvars(wattbezug: int, speicherleistung: int, speichersoc: int,
with open(bp+'/ramdisk/rereadsmarthomedevices', 'w') as f:
f.write(str(0))
readmq()
if firststart:
pass
else:
for i in range(1, (numberOfSupportedDevices+1)):
try:
with open(bp+'/ramdisk/smarthome_device_manual_'
+ str(i), 'r') as value:
for mydevice in mydevices:
if (str(i) == str(mydevice.device_nummer)):
mydevice.device_manual = int(value.read())
except Exception:
pass
try:
with open(bp+'/ramdisk/smarthome_device_manual_control_'
+ str(i), 'r') as value:
for mydevice in mydevices:
if (str(i) == str(mydevice.device_nummer)):
mydevice.device_manual_control = int(value.read())
except Exception:
pass
for i in range(1, (numberOfSupportedDevices+1)):
try:
with open(bp+'/ramdisk/smarthome_device_manual_'
+ str(i), 'r') as value:
for mydevice in mydevices:
if (str(i) == str(mydevice.device_nummer)):
mydevice.device_manual = int(value.read())
except Exception:
pass
try:
with open(bp+'/ramdisk/smarthome_device_manual_control_'
+ str(i), 'r') as value:
for mydevice in mydevices:
if (str(i) == str(mydevice.device_nummer)):
mydevice.device_manual_control = int(value.read())
except Exception:
pass
return uberschuss, uberschussoffset


Expand Down Expand Up @@ -473,22 +465,6 @@ def mainloop(wattbezug: int, speicherleistung: int, speichersoc: int, pvwatt: in
if firststart:
readmq()
firststart = False
for i in range(1, (numberOfSupportedDevices+1)):
# restore manual mode from mqtt
for mydevice in mydevices:
if (str(i) == str(mydevice.device_nummer)):
fname = bp+'/ramdisk/smarthome_device_manual_'+str(i)
if not os.path.isfile(fname):
with open(fname, 'w') as f:
f.write(str(mydevice.device_manual))
os.chmod(fname, 0o777)
log.info("File: " + str(fname) + " created. Content: " + str(mydevice.device_manual))
fname = bp+'/ramdisk/smarthome_device_manual_control_'+str(i)
if not os.path.isfile(fname):
with open(fname, 'w') as f:
f.write(str(mydevice.device_manual_control))
log.info("File: " + str(fname) + " created. Content: " + str(mydevice.device_manual_control))
os.chmod(fname, 0o777)
mqtt_man = {}
sendmess = 0
uberschuss, uberschussoffset = loadregelvars(wattbezug, speicherleistung, speichersoc, pvwatt, chargestatus)
Expand Down

0 comments on commit 8d4dbae

Please sign in to comment.