Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

idm Anpassungen & MQTT Anlauferkennung ermöglichen... #2802

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion packages/modules/smarthome/idm/smartidm.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,27 @@ def __init__(self) -> None:
super().__init__()
self._device_idmnav = '2'
self.device_nummer = 0
self._device_idmueb = 'UZ'
self._device_maxueb = 0

def updatepar(self, input_param: Dict[str, str]) -> None:
super().updatepar(input_param)
self._smart_paramadd = input_param.copy()
self.device_nummer = int(self._smart_paramadd.get('device_nummer',
'0'))
for key, value in self._smart_paramadd.items():
try:
valueint = int(value)
except Exception:
valueint = 0
if (key == 'device_nummer'):
pass
elif (key == 'device_idmnav'):
self._device_idmnav = value
elif (key == 'device_idmueb'):
self._device_idmueb = value
elif (key == 'device_maxueb'):
self._device_maxueb = valueint
else:
log.info("(" + str(self.device_nummer) + ") " +
" IDM überlesen " + key +
Expand All @@ -33,7 +43,10 @@ def getwatt(self, uberschuss: int, uberschussoffset: int) -> None:
argumentList = ['python3', self._prefixpy + 'idm/watt.py',
str(self.device_nummer), str(self._device_ip),
str(self.devuberschuss), str(self._device_idmnav),
str(self.pvwatt), str(forcesend)]
str(self.pvwatt),
str(self._device_idmueb),
str(self._device_maxueb),
str(forcesend)]
try:
self.callpro(argumentList)
self.answer = self.readret()
Expand Down
29 changes: 22 additions & 7 deletions packages/modules/smarthome/idm/watt.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
uberschuss = int(sys.argv[3])
navvers = str(sys.argv[4])
pvwatt = int(sys.argv[5])
forcesend = int(sys.argv[6])
uberschussvz = str(sys.argv[6])
maxpower = int(sys.argv[7])
forcesend = int(sys.argv[8])
# forcesend = 0 default time period applies
# forcesend = 1 default overwritten send now
# forcesend = 9 default overwritten no send
Expand Down Expand Up @@ -72,12 +74,25 @@
# logik nur schicken bei pvmodus
if pvmodus == 1:
modbuswrite = 1
# Nur positiven Uberschuss schicken, nicht aktuelle Leistung
neupower = uberschuss
if neupower < 0:
neupower = 0
if neupower > 40000:
neupower = 40000
# uberschuss begrenzung ?
if (maxpower > 0):
neupower = maxpower - aktpower
# maximaler überschuss berechnet ?
if (neupower > uberschuss):
neupower = uberschuss
if (uberschussvz == 'UZ'):
# <option value="UP" data-option="UP">Überschuss als positive Zahl übertragen, Bezug negativ</option>
# <option value="UZ" data-option="UZ">Überschuss als positive Zahl übertragen, Bezug als 0</option>
if neupower < 0:
neupower = 0
if neupower > 65535:
neupower = 65535
else:
if neupower < -32767:
neupower = -32767
if neupower > 32767:
neupower = 32767
# wurde IDM gerade ausgeschaltet ? (pvmodus == 99 ?)
# dann 0 schicken wenn kein pvmodus mehr
# und pv modus ausschalten
Expand Down Expand Up @@ -105,7 +120,7 @@
if count1 < 3:
log.info(" %d ipadr %s ueberschuss %6d Akt Leistung %6d Pv %6d"
% (devicenumber, ipadr, uberschuss, aktpower, pvwatt))
log.info(" %d ipadr %s ueberschuss %6d pvmodus %1d modbusw %1d"
log.info(" %d ipadr %s ueberschuss send %6d pvmodus %1d modbusw %1d"
% (devicenumber, ipadr, neupower, pvmodus, modbuswrite))
# modbus write
if modbuswrite == 1:
Expand Down
2 changes: 2 additions & 0 deletions runs/mqttsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ def map_run(message: str, device_number: int, option: str):
"device_shusername": create_topic_handler(),
"device_shpassword": create_topic_handler(),
"device_manwatt": create_topic_handler(int_range_validator(0, 30000)),
"device_maxueb": create_topic_handler(int_range_validator(0, 30000)),
"device_measureshusername": create_topic_handler(),
"device_measureshpassword": create_topic_handler(),
"device_actor": create_topic_handler(),
Expand All @@ -198,6 +199,7 @@ def map_run(message: str, device_number: int, option: str):
"device_measureavmactor": create_topic_handler(),
"device_acthortype": create_topic_handler(equals_one_of_validator("M1", "M3", "9s", "9s18")),
"device_lambdaueb": create_topic_handler(equals_one_of_validator("UP", "UN", "UZ")),
"device_idmueb": create_topic_handler(equals_one_of_validator("UP", "UZ")),
"device_acthorpower": create_topic_handler(int_range_validator(0, 18000)),
"device_finishTime": create_topic_handler(regex_match_validator(r"^([01]{0,1}\d|2[0-3]):[0-5]\d$")),
"device_onTime": create_topic_handler(regex_match_validator(r"^([01]{0,1}\d|2[0-3]):[0-5]\d$")),
Expand Down
41 changes: 40 additions & 1 deletion web/settings/smarthomeconfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,26 @@
</div>
</div>
</div>
<div class="device<?php echo $devicenum; ?>-option device<?php echo $devicenum; ?>-option-idm hide">
<hr class="border-secondary">
<div class="form-group">
<div class="form-row mb-1">
<label for="device_maxuebDevices<?php echo $devicenum; ?>" class="col-md-4 col-form-label">Maximale Leistungsaufnahme/Überschuss bei PV Betrieb</label>
<div class="col">
<input id="device_maxuebDevices<?php echo $devicenum; ?>" name="device_maxueb" class="form-control" type="number" min="0" max="30000" step="1" required="required" data-default="0" value="0" data-topicprefix="openWB/config/get/SmartHome/" data-topicsubgroup="Devices/<?php echo $devicenum; ?>/">
<span class="form-text small">
Hier ist die maximale Leistungsaufnahme anzugeben, die idm bei PV Betrieb nicht überschreiten soll. Bei 0 gibt es keine Limitierung bezüglich dem maximal zu übergebenen Überschuss. <br>
Sonst wird der zu übergebene Überschuss wie folgt gerechnet:
maximal zu übergeber Überschuss = maximale Leistungsaufnahme - aktuelle Leistungsaufnahme
<br>
Sofern die aktuelle Leistungsaufnahme bereits grösser als die maximale Leistungsaufnahme ist, wird gar kein Überschuss mehr übergeben im PV Betrieb.

</span>
</div>
</div>
</div>
</div>

<div class="device<?php echo $devicenum; ?>-option device<?php echo $devicenum; ?>-option-acthor hide">
<hr class="border-secondary">
<div class="form-group">
Expand Down Expand Up @@ -428,6 +448,25 @@
</div>
</div>
</div>
<div class="device<?php echo $devicenum; ?>-option device<?php echo $devicenum; ?>-option-idm hide">
<hr class="border-secondary">
<div class="form-group">
<div class="form-row mb-1">
<label for="device_idmuebDevices<?php echo $devicenum; ?>" class="col-md-4 col-form-label">Überschuss...</label>
<div class="col">
<select class="form-control" name="device_idmueb" id="device_idmuebDevices<?php echo $devicenum; ?>" data-default="UZ" data-topicprefix="openWB/config/get/SmartHome/" data-topicsubgroup="Devices/<?php echo $devicenum; ?>/">
<option value="UP" data-option="UP">Überschuss als positive Zahl übertragen, Bezug negativ</option>
<option value="UZ" data-option="UZ">Überschuss als positive Zahl übertragen, Bezug als 0</option>
</select>
<span class="form-text small">
Bezieht sich auf die Modbusadresse 74, wie ist Überschuss zu übertragen.<br>
Neue Möglichkeit -> Überschuss als positive Zahl übertragen, Bezug negativ <br>
bisheriges Verhalten -> Überschuss als positive Zahl übertragen, Bezug als 0<br>
</span>
</div>
</div>
</div>
</div>
<div class="device<?php echo $devicenum; ?>-option device<?php echo $devicenum; ?>-option-shelly device<?php echo $devicenum; ?>-option-tasmota device<?php echo $devicenum; ?>-option-acthor device<?php echo $devicenum; ?>-option-lambda device<?php echo $devicenum; ?>-option-elwa device<?php echo $devicenum; ?>-option-idm device<?php echo $devicenum; ?>-option-stiebel device<?php echo $devicenum; ?>-option-vampair device<?php echo $devicenum; ?>-option-avm device<?php echo $devicenum; ?>-option-mystrom device<?php echo $devicenum; ?>-option-http device<?php echo $devicenum; ?>-option-mqtt device<?php echo $devicenum; ?>-option-askoheat device<?php echo $devicenum; ?>-option-ratiotherm device<?php echo $devicenum; ?>-option-NXDACXX device<?php echo $devicenum; ?>-option-viessmann hide">
<hr class="border-secondary">
<div class="form-group">
Expand Down Expand Up @@ -538,7 +577,7 @@
</div>
</div>
</div>
<div class="device<?php echo $devicenum; ?>-option device<?php echo $devicenum; ?>-option-shelly device<?php echo $devicenum; ?>-option-tasmota device<?php echo $devicenum; ?>-option-http device<?php echo $devicenum; ?>-option-avm device<?php echo $devicenum; ?>-option-mystrom hide">
<div class="device<?php echo $devicenum; ?>-option device<?php echo $devicenum; ?>-option-shelly device<?php echo $devicenum; ?>-option-mqtt device<?php echo $devicenum; ?>-option-tasmota device<?php echo $devicenum; ?>-option-http device<?php echo $devicenum; ?>-option-avm device<?php echo $devicenum; ?>-option-mystrom hide">
<hr class="border-secondary">
<div class="form-group">
<div class="form-row mb-1">
Expand Down
4 changes: 3 additions & 1 deletion web/settings/topicsToSubscribe_smarthomeconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ var topicsToSubscribe = [
["openWB/config/get/SmartHome/Devices/+/device_shauth", 0],
["openWB/config/get/SmartHome/Devices/+/device_measureshauth", 0],
["openWB/config/get/SmartHome/Devices/+/device_mindayeinschaltdauer", 0],
["openWB/config/get/SmartHome/Devices/+/device_measuresmaage", 0]
["openWB/config/get/SmartHome/Devices/+/device_measuresmaage", 0],
["openWB/config/get/SmartHome/Devices/+/device_idmueb", 0],
["openWB/config/get/SmartHome/Devices/+/device_maxueb", 0]

];
Loading