Skip to content

Commit

Permalink
preparation for http devices
Browse files Browse the repository at this point in the history
  • Loading branch information
benderl committed Dec 10, 2020
1 parent 3ce7d63 commit 2d1be43
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 16 deletions.
24 changes: 24 additions & 0 deletions runs/mqttsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,30 @@ def on_message(client, userdata, msg):
f = open('/var/www/html/openWB/ramdisk/smarthome_device_manual_'+str(devicenumb), 'w')
f.write(msg.payload.decode("utf-8"))
f.close()
if (( "openWB/config/set/SmartHome/Device" in msg.topic) and ("device_einschalturl" in msg.topic)):
devicenumb=re.sub(r'\D', '', msg.topic)
if ( 1 <= int(devicenumb) <= 10 ):
writetoconfig(shconfigfile,'smarthomedevices','device_einschalturl'+str(devicenumb), msg.payload.decode("utf-8"))
client.publish("openWB/config/get/SmartHome/Devices/"+str(devicenumb)+"/device_einschalturl", msg.payload.decode("utf-8"), qos=0, retain=True)
client.publish("openWB/config/set/SmartHome/Devices/"+str(devicenumb)+"/device_einschalturl", "", qos=0, retain=True)
if (( "openWB/config/set/SmartHome/Device" in msg.topic) and ("device_ausschalturl" in msg.topic)):
devicenumb=re.sub(r'\D', '', msg.topic)
if ( 1 <= int(devicenumb) <= 10 ):
writetoconfig(shconfigfile,'smarthomedevices','device_ausschalturl'+str(devicenumb), msg.payload.decode("utf-8"))
client.publish("openWB/config/get/SmartHome/Devices/"+str(devicenumb)+"/device_ausschalturl", msg.payload.decode("utf-8"), qos=0, retain=True)
client.publish("openWB/config/set/SmartHome/Devices/"+str(devicenumb)+"/device_ausschalturl", "", qos=0, retain=True)
if (( "openWB/config/set/SmartHome/Device" in msg.topic) and ("device_leistungurl" in msg.topic)):
devicenumb=re.sub(r'\D', '', msg.topic)
if ( 1 <= int(devicenumb) <= 10 ):
writetoconfig(shconfigfile,'smarthomedevices','device_leistungurl'+str(devicenumb), msg.payload.decode("utf-8"))
client.publish("openWB/config/get/SmartHome/Devices/"+str(devicenumb)+"/device_leistungurl", msg.payload.decode("utf-8"), qos=0, retain=True)
client.publish("openWB/config/set/SmartHome/Devices/"+str(devicenumb)+"/device_leistungurl", "", qos=0, retain=True)
if (( "openWB/config/set/SmartHome/Device" in msg.topic) and ("device_measureurl" in msg.topic)):
devicenumb=re.sub(r'\D', '', msg.topic)
if ( 1 <= int(devicenumb) <= 10 ):
writetoconfig(shconfigfile,'smarthomedevices','device_measureurl'+str(devicenumb), msg.payload.decode("utf-8"))
client.publish("openWB/config/get/SmartHome/Devices/"+str(devicenumb)+"/device_measureurl", msg.payload.decode("utf-8"), qos=0, retain=True)
client.publish("openWB/config/set/SmartHome/Devices/"+str(devicenumb)+"/device_measureurl", "", qos=0, retain=True)
if (msg.topic == "openWB/config/set/SmartHome/logLevel"):
if (int(msg.payload) >= 0 and int(msg.payload) <= 2):
f = open('/var/www/html/openWB/ramdisk/smarthomehandlerloglevel', 'w')
Expand Down
68 changes: 53 additions & 15 deletions web/settings/smarthomeconfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,14 @@ function getCookie(cname) {
<label class="col-md-4 col-form-label">Gerätetyp</label>
<div class="col">
<select class="form-control" name="device_type" id="device_typeDevices<?php echo $devicenum; ?>" data-default="shelly" value="shelly" data-topicprefix="openWB/config/get/SmartHome/" data-topicsubgroup="Devices/<?php echo $devicenum; ?>/">
<option value = "shelly" data-option="shelly">Shelly</option>
<option value = "tasmota" data-option="tasmota">Tasmota</option>
<option value = "acthor" data-option="acthor">Acthor</option>
<option value = "elwa" data-option="elwa">Elwa</option>
<option value = "idm" data-option="idm">Idm</option>
<option value = "stiebel" data-option="stiebel">Stiebel</option>
<option value = "pyt" data-option="pyt" disabled="disabled">Pyt (veraltet, bitte andere Option wählen)</option>
<option value="shelly" data-option="shelly">Shelly</option>
<option value="tasmota" data-option="tasmota">Tasmota</option>
<option value="acthor" data-option="acthor">Acthor</option>
<option value="elwa" data-option="elwa">Elwa</option>
<option value="idm" data-option="idm">Idm</option>
<option value="stiebel" data-option="stiebel">Stiebel</option>
<option disabled="disabled" value="http" data-option="http">Http</option>
<option value="pyt" data-option="pyt" disabled="disabled">Pyt (veraltet, bitte andere Option wählen)</option>
</select>
<span class="form-text small device<?php echo $devicenum; ?>-option device<?php echo $devicenum; ?>-option-acthor hide">
Heizstab Acthor der Firma my-PV<br>
Expand Down Expand Up @@ -182,6 +183,32 @@ function getCookie(cname) {
</div>
</div>
</div>
<div class="device<?php echo $devicenum; ?>-option device<?php echo $devicenum; ?>-option-http hide">
<hr class="border-secondary">
<div class="form-group">
<div class="form-row mb-1">
<label for="device_einschalturlDevices<?php echo $devicenum; ?>" class="col-md-4 col-form-label">Einschalt-URL</label>
<div class="col">
<input id="device_einschalturlDevices<?php echo $devicenum; ?>" name="device_einschalturl" class="form-control" type="text" required data-default="" value="" data-topicprefix="openWB/config/get/SmartHome/" data-topicsubgroup="Devices/<?php echo $devicenum; ?>/">
<span class="form-text small">Die hier angegebene URL wird aufgerufen, um das Gerät einzuschalten.</span>
</div>
</div>
<div class="form-row mb-1">
<label for="device_ausschalturlDevices<?php echo $devicenum; ?>" class="col-md-4 col-form-label">Ausschalt-URL</label>
<div class="col">
<input id="device_ausschalturlDevices<?php echo $devicenum; ?>" name="device_ausschalturl" class="form-control" type="text" required data-default="" value="" data-topicprefix="openWB/config/get/SmartHome/" data-topicsubgroup="Devices/<?php echo $devicenum; ?>/">
<span class="form-text small">Die hier angegebene URL wird aufgerufen, um das Gerät auszuschalten.</span>
</div>
</div>
<div class="form-row mb-1 device<?php echo $devicenum; ?>noDifferentMeasurement">
<label for="device_leistungurlDevices<?php echo $devicenum; ?>" class="col-md-4 col-form-label">Leistungs-URL</label>
<div class="col">
<input id="device_leistungurlDevices<?php echo $devicenum; ?>" name="device_leistungurl" class="form-control" type="text" required data-default="" value="" data-topicprefix="openWB/config/get/SmartHome/" data-topicsubgroup="Devices/<?php echo $devicenum; ?>/">
<span class="form-text small">Die hier angegebene URL wird aufgerufen, um die aktuelle Leistung des Geräts zu erhalten.</span>
</div>
</div>
</div>
</div>
<hr class="border-secondary">
<div class="form-group">
<div class="form-row mb-1">
Expand Down Expand Up @@ -343,17 +370,19 @@ function getCookie(cname) {
</div>
</div>
</div>
<div id="device<?php echo $devicenum; ?>differentMeasurement" class="hide">
<div class="device<?php echo $devicenum; ?>differentMeasurement hide">
<div class="form-row mb-1">
<label class="col-md-4 col-form-label">Gerätetyp</label>
<div class="col">
<div class="btn-group btn-group-toggle btn-block" id="device_measureTypeDevices<?php echo $devicenum; ?>" name="device_measureType" data-toggle="buttons" data-default="sdm630" value="sdm630" data-topicprefix="openWB/config/get/SmartHome/" data-topicsubgroup="Devices/<?php echo $devicenum; ?>/">
<label class="btn btn-outline-info">
<input type="radio" name="device_measureTypeDevices<?php echo $devicenum; ?>" id="device_measureTypeDevices<?php echo $devicenum; ?>Shelly" data-option="shelly">Shelly
</label>
<!--<label class="btn btn-outline-info">
<input type="radio" name="device_measureTypeDevices<?php echo $devicenum; ?>" id="device_measureTypeDevices<?php echo $devicenum; ?>http" data-option="http">HTTP
</label> -->
<!--
<label class="btn btn-outline-info">
<input type="radio" name="device_measureTypeDevices<?php echo $devicenum; ?>" id="device_measureTypeDevices<?php echo $devicenum; ?>http" data-option="http">Http
</label>
-->
<label class="btn btn-outline-info btn-toggle">
<input type="radio" name="device_measureTypeDevices<?php echo $devicenum; ?>" id="device_measureTypeDevices<?php echo $devicenum; ?>SDM630" data-option="sdm630"> SDM630
</label>
Expand All @@ -366,12 +395,18 @@ function getCookie(cname) {
<input id="device_measureipDevices<?php echo $devicenum; ?>" name="device_measureip" class="form-control" type="text" pattern="^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$" data-default="192.168.1.1" value="192.168.1.1" inputmode="text" data-topicprefix="openWB/config/get/SmartHome/" data-topicsubgroup="Devices/<?php echo $devicenum; ?>/">
</div>
</div>
<div class="form-row mb-1 deviceMeasureTypeDevices<?php echo $devicenum; ?>-option deviceMeasureTypeDevices<?php echo $devicenum; ?>-option-sdm630">
<div class="form-row mb-1 deviceMeasureTypeDevices<?php echo $devicenum; ?>-option deviceMeasureTypeDevices<?php echo $devicenum; ?>-option-sdm630 hide">
<label for="device_measureidDevices<?php echo $devicenum; ?>" class="col-md-4 col-form-label">ID des Zählers am Netzwerk/Modbus Wandler</label>
<div class="col">
<input id="device_measureidDevices<?php echo $devicenum; ?>" name="device_measureid" class="form-control naturalNumber" type="number" inputmode="decimal" required min="1" max="255" data-default="1" value="1" data-topicprefix="openWB/config/get/SmartHome/" data-topicsubgroup="Devices/<?php echo $devicenum; ?>/">
</div>
</div>
<div class="form-row mb-1 deviceMeasureTypeDevices<?php echo $devicenum; ?>-option deviceMeasureTypeDevices<?php echo $devicenum; ?>-option-http hide">
<label for="device_measureurlDevices<?php echo $devicenum; ?>" class="col-md-4 col-form-label">Leistungs-URL</label>
<div class="col">
<input id="device_measureurlDevices<?php echo $devicenum; ?>" name="device_measureurld" class="form-control" data-default="" value="" data-topicprefix="openWB/config/get/SmartHome/" data-topicsubgroup="Devices/<?php echo $devicenum; ?>/">
</div>
</div>
</div>
</div> <!-- end card body Allgemeine Einstellungen Gerät <?php echo $devicenum; ?> -->
</div> <!-- end card Allgemeine Einstellungen Gerät <?php echo $devicenum; ?> -->
Expand Down Expand Up @@ -523,6 +558,7 @@ function visibility_device_typeDevices<?php echo $devicenum; ?>( data ){
// console.log("device_typeDevices: data: "+data);
hideSection(".device<?php echo $devicenum; ?>-option");
showSection(".device<?php echo $devicenum; ?>-option-"+data);
visibility_device_differentMeasurementDevices<?php echo $devicenum; ?>();
}

function visibility_device_differentMeasurementDevices<?php echo $devicenum; ?>( data ){
Expand All @@ -532,12 +568,14 @@ function visibility_device_differentMeasurementDevices<?php echo $devicenum; ?>(
}
// console.log("device_differentMeasurementDevices: data: "+data);
if( data == 0 ){
hideSection('#device<?php echo $devicenum; ?>differentMeasurement');
hideSection('.device<?php echo $devicenum; ?>differentMeasurement');
showSection('.device<?php echo $devicenum; ?>noDifferentMeasurement');
} else {
showSection('#device<?php echo $devicenum; ?>differentMeasurement');
showSection('.device<?php echo $devicenum; ?>differentMeasurement');
hideSection('.device<?php echo $devicenum; ?>noDifferentMeasurement');
// update visibility if direct child sections
visibility_device_measureTypeDevices<?php echo $devicenum; ?>();
}
visibility_device_measureTypeDevices<?php echo $devicenum; ?>();
}

function visibility_device_measureTypeDevices<?php echo $devicenum; ?>( data ){
Expand Down
38 changes: 37 additions & 1 deletion web/settings/topicsToSubscribe_smarthomeconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,41 @@ var topicsToSubscribe = [
["openWB/config/get/SmartHome/Devices/6/device_ausschaltverzoegerung", 0],
["openWB/config/get/SmartHome/Devices/7/device_ausschaltverzoegerung", 0],
["openWB/config/get/SmartHome/Devices/8/device_ausschaltverzoegerung", 0],
["openWB/config/get/SmartHome/Devices/9/device_ausschaltverzoegerung", 0]
["openWB/config/get/SmartHome/Devices/9/device_ausschaltverzoegerung", 0],
["openWB/config/get/SmartHome/Devices/1/device_einschalturl", 0],
["openWB/config/get/SmartHome/Devices/2/device_einschalturl", 0],
["openWB/config/get/SmartHome/Devices/3/device_einschalturl", 0],
["openWB/config/get/SmartHome/Devices/4/device_einschalturl", 0],
["openWB/config/get/SmartHome/Devices/5/device_einschalturl", 0],
["openWB/config/get/SmartHome/Devices/6/device_einschalturl", 0],
["openWB/config/get/SmartHome/Devices/7/device_einschalturl", 0],
["openWB/config/get/SmartHome/Devices/8/device_einschalturl", 0],
["openWB/config/get/SmartHome/Devices/9/device_einschalturl", 0],
["openWB/config/get/SmartHome/Devices/1/device_ausschalturl", 0],
["openWB/config/get/SmartHome/Devices/2/device_ausschalturl", 0],
["openWB/config/get/SmartHome/Devices/3/device_ausschalturl", 0],
["openWB/config/get/SmartHome/Devices/4/device_ausschalturl", 0],
["openWB/config/get/SmartHome/Devices/5/device_ausschalturl", 0],
["openWB/config/get/SmartHome/Devices/6/device_ausschalturl", 0],
["openWB/config/get/SmartHome/Devices/7/device_ausschalturl", 0],
["openWB/config/get/SmartHome/Devices/8/device_ausschalturl", 0],
["openWB/config/get/SmartHome/Devices/9/device_ausschalturl", 0],
["openWB/config/get/SmartHome/Devices/1/device_leistungurl", 0],
["openWB/config/get/SmartHome/Devices/2/device_leistungurl", 0],
["openWB/config/get/SmartHome/Devices/3/device_leistungurl", 0],
["openWB/config/get/SmartHome/Devices/4/device_leistungurl", 0],
["openWB/config/get/SmartHome/Devices/5/device_leistungurl", 0],
["openWB/config/get/SmartHome/Devices/6/device_leistungurl", 0],
["openWB/config/get/SmartHome/Devices/7/device_leistungurl", 0],
["openWB/config/get/SmartHome/Devices/8/device_leistungurl", 0],
["openWB/config/get/SmartHome/Devices/9/device_leistungurl", 0],
["openWB/config/get/SmartHome/Devices/1/device_measureurl", 0],
["openWB/config/get/SmartHome/Devices/2/device_measureurl", 0],
["openWB/config/get/SmartHome/Devices/3/device_measureurl", 0],
["openWB/config/get/SmartHome/Devices/4/device_measureurl", 0],
["openWB/config/get/SmartHome/Devices/5/device_measureurl", 0],
["openWB/config/get/SmartHome/Devices/6/device_measureurl", 0],
["openWB/config/get/SmartHome/Devices/7/device_measureurl", 0],
["openWB/config/get/SmartHome/Devices/8/device_measureurl", 0],
["openWB/config/get/SmartHome/Devices/9/device_measureurl", 0]
];

0 comments on commit 2d1be43

Please sign in to comment.