From c64ca20b06eabca6c5392ff4fd5e45d750bfb0e6 Mon Sep 17 00:00:00 2001 From: Norbert Date: Thu, 22 Aug 2024 08:13:35 +0200 Subject: [PATCH] init --- .idea/.gitignore | 3 + .idea/ShellyX.iml | 10 ++ .../inspectionProfiles/profiles_settings.xml | 6 + .idea/misc.xml | 4 + .idea/modules.xml | 8 + .idea/vcs.xml | 6 + HelloWorld.js | 142 ++++++++++++++++++ main.py | 16 ++ 8 files changed, 195 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/ShellyX.iml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 HelloWorld.js create mode 100644 main.py diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/ShellyX.iml b/.idea/ShellyX.iml new file mode 100644 index 0000000..74d515a --- /dev/null +++ b/.idea/ShellyX.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..bbcb7c6 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..1d00d92 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/HelloWorld.js b/HelloWorld.js new file mode 100644 index 0000000..58bb836 --- /dev/null +++ b/HelloWorld.js @@ -0,0 +1,142 @@ +//GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 +//More information: https://www.gnu.org/licenses/gpl-3.0.txt +//ABSOLUTELY NO WARRANTY!!! +//Made by Ostfriese + +//############################## Config ############################ +let Config = { + temp_diff: 2, + temp_min: 12, + id_inside: 100, + hum_target: 55, + interval: 10, // 2 seconds is the minimum interval + Tank_Sensor: 0, //Sensor Wasserstand + comp: 0, // Kompressor + FanH: 1, // Luefter Schnell + FanL: 2, // Luefter langsam + LedG: 3, + LedR: 4, + LedB: 5 +} +//############################## Config end ############################ + +function LedsOff() { + Shelly.call("http.get", { + url: 'http://127.0.0.1/relay/' + JSON.stringify(Config.LedR) + '?turn=on' + }); + Shelly.call("http.get", { + url: 'http://127.0.0.1/relay/' + JSON.stringify(Config.LedG) + '?turn=on' + }); + Shelly.call("http.get", { + url: 'http://127.0.0.1/relay/' + JSON.stringify(Config.LedB) + '?turn=on' + }); +} + +function Gruen() { + LedsOff(); + Shelly.call("http.get", { + url: 'http://127.0.0.1/relay/' + JSON.stringify(Config.LedG) + '?turn=off' + }); +} + +function Rot() { + LedsOff(); + Shelly.call("http.get", { + url: 'http://127.0.0.1/relay/' + JSON.stringify(Config.LedR) + '?turn=off' + }); +} + +function Blau() { + LedsOff(); + Shelly.call("http.get", { + url: 'http://127.0.0.1/relay/' + JSON.stringify(Config.LedB) + '?turn=off' + }); +} + +function allesAus() { + Shelly.call("http.get", { + url: 'http://127.0.0.1/relay/' + JSON.stringify(Config.comp) + '?turn=off' + }); + Shelly.call("http.get", { + url: 'http://127.0.0.1/relay/' + JSON.stringify(Config.FanH) + '?turn=off' + }); + Shelly.call("http.get", { + url: 'http://127.0.0.1/relay/' + JSON.stringify(Config.FanL) + '?turn=off' + }); + LedsOff(); +} + +function niedrigeStufe() { + Shelly.call("http.get", { + url: 'http://127.0.0.1/relay/' + JSON.stringify(Config.comp) + '?turn=on' + }); + Shelly.call("http.get", { + url: 'http://127.0.0.1/relay/' + JSON.stringify(Config.FanH) + '?turn=off' + }); + Shelly.call("http.get", { + url: 'http://127.0.0.1/relay/' + JSON.stringify(Config.FanL) + '?turn=on' + }); + Blau(); +} + +function hoheStufe() { + Shelly.call("http.get", { + url: 'http://127.0.0.1/relay/' + JSON.stringify(Config.comp) + '?turn=on' + }); + Shelly.call("http.get", { + url: 'http://127.0.0.1/relay/' + JSON.stringify(Config.FanH) + '?turn=on' + }); + Shelly.call("http.get", { + url: 'http://127.0.0.1/relay/' + JSON.stringify(Config.FanL) + '?turn=off' + }); + Blau(); +} + +function watch() { + try { + temperature = Shelly.getComponentStatus('Temperature', Config.id_inside).tC; + humidity = Shelly.getComponentStatus('Humidity', Config.id_inside).rh; + tank = Shelly.getComponentStatus('Input', Config.Tank_Sensor).state; + //print('Temp. inside =',temp_inside); + print('Hum. Inside =', humidity); + print('tank= ', tank); + //inside <= minimum + if (humidity <= Config.hum_target) { + //allesAus(); + Gruen(); + print('Relay(', Config.comp, ') off. Inside hum <= ', Config.hum_target); + } else { + delta = humidity - Config.hum_target; + //delta more than or equal Config.temp_diff + //if (!tank && delta >= Config.temp_diff) { + //niedrigeStufe(); + Blau(); + // print('Relay(', Config.comp, ') on. Delta >= ', Config.hum_target); + } + //delta less than Config.temp_diff + //else { + //allesAus(); + // Gruen(); + // print('Relay(', Config.comp, ') off. Delta < ', Config.hum_target); + //} + //} + print('\n') + } catch (err) { + //allesAus(); + //Rot(); + print(err); + } +} + +function start() { + LedsOff(); + //allesAus(); + // do a first shot + print('Starting....'); + watch(); + // set watch timer to configured value + Timer.set(Config.interval * 1000, true, watch); +} + +// schedule script start for 1 second +Timer.set(1000, false, start); diff --git a/main.py b/main.py new file mode 100644 index 0000000..94e3a87 --- /dev/null +++ b/main.py @@ -0,0 +1,16 @@ +# This is a sample Python script. + +# Press ⌃R to execute it or replace it with your code. +# Press Double ⇧ to search everywhere for classes, files, tool windows, actions, and settings. + + +def print_hi(name): + # Use a breakpoint in the code line below to debug your script. + print(f'Hi, {name}') # Press ⌘F8 to toggle the breakpoint. + + +# Press the green button in the gutter to run the script. +if __name__ == '__main__': + print_hi('PyCharm') + +# See PyCharm help at https://www.jetbrains.com/help/pycharm/