Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

Commit

Permalink
Merge pull request snaptec#2660 from okaegi/smart171
Browse files Browse the repository at this point in the history
Smarthome...
  • Loading branch information
benderl authored Mar 22, 2023
2 parents 7c53ab5 + c962bf3 commit 47b78e7
Show file tree
Hide file tree
Showing 27 changed files with 354 additions and 143 deletions.
4 changes: 2 additions & 2 deletions packages/modules/smarthome/acthor/smartacthor.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/usr/bin/python3
from smarthome.smartbase import Sbase
from smarthome.global0 import log
from typing import Dict
import subprocess
import logging
log = logging.getLogger(__name__)


class Sacthor(Sbase):
def __init__(self) -> None:
# setting
super().__init__()
print('__init__ Sacthor executed')
self._smart_paramadd = {} # type: Dict[str, str]
self._device_acthortype = 'none'
self._device_acthorpower = 'none'
Expand Down
4 changes: 2 additions & 2 deletions packages/modules/smarthome/avmhomeautomation/smartavm.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/python3
from smarthome.smartbase import Sbase, Slavm
from smarthome.global0 import log
import subprocess
import logging
log = logging.getLogger(__name__)


class Savm(Sbase):
Expand All @@ -13,7 +14,6 @@ def __init__(self):
self._device_actor = 'none'
self._device_username = 'none'
self._device_password = 'none'
print('__init__ Savm excuted')

def getwatt(self, uberschuss, uberschussoffset):
self.prewatt(uberschuss, uberschussoffset)
Expand Down
4 changes: 2 additions & 2 deletions packages/modules/smarthome/elwa/smartelwa.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/usr/bin/python3
from smarthome.smartbase import Sbase
from smarthome.global0 import log
from typing import Dict
import subprocess
import logging
log = logging.getLogger(__name__)


class Selwa(Sbase):
def __init__(self) -> None:
# setting
super().__init__()
self._dynregel = 1
print('__init__ Selwa executed')

def updatepar(self, input_param: Dict[str, str]) -> None:
super().updatepar(input_param)
Expand Down
5 changes: 2 additions & 3 deletions packages/modules/smarthome/http/smarthttp.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/python3
from smarthome.smartbase import Sbase, Slhttp
from smarthome.global0 import log
import subprocess
import logging
log = logging.getLogger(__name__)


class Shttp(Sbase):
Expand All @@ -12,8 +13,6 @@ def __init__(self):
self._device_einschalturl = 'none'
self._device_ausschalturl = 'none'

print('__init__ Shttp excuted')

def getwatt(self, uberschuss, uberschussoffset):
self.prewatt(uberschuss, uberschussoffset)
self._mydevicemeasure0.devuberschuss = self.devuberschuss
Expand Down
4 changes: 2 additions & 2 deletions packages/modules/smarthome/idm/smartidm.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/python3
from smarthome.smartbase import Sbase
from smarthome.global0 import log
import subprocess
import logging
log = logging.getLogger(__name__)


class Sidm(Sbase):
Expand All @@ -11,7 +12,6 @@ def __init__(self):
self._smart_paramadd = {}
self._device_idmnav = '2'
self.device_nummer = 0
print('__init__ Sidm executed')

def updatepar(self, input_param):
super().updatepar(input_param)
Expand Down
3 changes: 2 additions & 1 deletion packages/modules/smarthome/lambda_/smartlambda.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/python3
from smarthome.smartbase import Sbase
from smarthome.global0 import log
import subprocess
import logging
log = logging.getLogger(__name__)


class Slambda(Sbase):
Expand Down
4 changes: 2 additions & 2 deletions packages/modules/smarthome/mqtt/smartmqtt.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/usr/bin/python3
from smarthome.smartbase import Sbase, Slmqtt
from smarthome.global0 import log
import subprocess
import logging
log = logging.getLogger(__name__)


class Smqtt(Sbase):
def __init__(self):
# setting
super().__init__()
self._old_measuretype0 = 'none'
print('__init__ Smqtt executed')

def getwatt(self, uberschuss, uberschussoffset):
self.prewatt(uberschuss, uberschussoffset)
Expand Down
4 changes: 2 additions & 2 deletions packages/modules/smarthome/mystrom/smartmystrom.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/usr/bin/python3
import subprocess
from smarthome.global0 import log
from smarthome.smartbase import Sbase, Slmystrom
import logging
log = logging.getLogger(__name__)


class Smystrom(Sbase):
def __init__(self):
# setting
super().__init__()
self._old_measuretype0 = 'none'
print('__init__ Smystrom excuted')

def getwatt(self, uberschuss, uberschussoffset):
self.prewatt(uberschuss, uberschussoffset)
Expand Down
4 changes: 2 additions & 2 deletions packages/modules/smarthome/nxdacxx/smartnxdacxx.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/usr/bin/python3
from smarthome.smartbase import Sbase
from smarthome.global0 import log
from typing import Dict
import subprocess
import logging
log = logging.getLogger(__name__)


class Snxdacxx(Sbase):
def __init__(self) -> None:
# setting
super().__init__()
print('__init__ Snxdacxx executed')
self._smart_paramadd = {} # type: dict [str,str]
self._device_nxdacxxueb = 0
self._device_nxdacxxtype = 0
Expand Down
3 changes: 2 additions & 1 deletion packages/modules/smarthome/ratiotherm/smartratiotherm.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/python3
from smarthome.smartbase import Sbase
from smarthome.global0 import log
import subprocess
import logging
log = logging.getLogger(__name__)


class Sratiotherm(Sbase):
Expand Down
30 changes: 26 additions & 4 deletions packages/modules/smarthome/shelly/off.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import sys
import time
import urllib.request
import os
named_tuple = time.localtime() # getstruct_time
time_string = time.strftime("%m/%d/%Y, %H:%M:%S shelly off.py", named_tuple)
devicenumber = str(sys.argv[1])
Expand All @@ -11,10 +12,31 @@
chan = int(sys.argv[4])
except Exception:
chan = 0
shaut = int(sys.argv[5])
user = str(sys.argv[6])
pw = str(sys.argv[7])
fbase = '/var/www/html/openWB/ramdisk/smarthome_device_ret.'
fnameg = fbase + str(ipadr) + '_shelly_infog'
if os.path.isfile(fnameg):
with open(fnameg, 'r') as f:
gen = str(f.read())
else:
gen = "0"
if (chan == 0):
urllib.request.urlopen("http://"+str(ipadr)+"/relay/0?turn=off",
timeout=3)
url = "http://" + str(ipadr) + "/relay/0?turn=off"
# urllib.request.urlopen("http://"+str(ipadr)+"/relay/0?turn=off",
# timeout=3)
else:
chan = chan - 1
urllib.request.urlopen("http://"+str(ipadr)+"/relay/" + str(chan) +
"?turn=off", timeout=3)
url = "http://" + str(ipadr) + "/relay/" + str(chan) + "?turn=off"
# urllib.request.urlopen("http://"+str(ipadr)+"/relay/" + str(chan) +
# "?turn=off", timeout=3)
if (shaut == 1):
# print("Shelly off" + str(shaut) + user + pw)
passman = urllib.request.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, url, user, pw)
authhandler = urllib.request.HTTPBasicAuthHandler(passman)
opener = urllib.request.build_opener(authhandler)
urllib.request.install_opener(opener)
with urllib.request.urlopen(url) as response:
response.read().decode("utf-8")
31 changes: 27 additions & 4 deletions packages/modules/smarthome/shelly/on.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,42 @@
import sys
import time
import urllib.request
import os
named_tuple = time.localtime() # getstruct_time
time_string = time.strftime("%m/%d/%Y, %H:%M:%S shelly on.py", named_tuple)
devicenumber = str(sys.argv[1])
ipadr = str(sys.argv[2])
uberschuss = int(sys.argv[3])
gen = "1"
try:
chan = int(sys.argv[4])
except Exception:
chan = 0
shaut = int(sys.argv[5])
user = str(sys.argv[6])
pw = str(sys.argv[7])
fbase = '/var/www/html/openWB/ramdisk/smarthome_device_ret.'
fnameg = fbase + str(ipadr) + '_shelly_infog'
if os.path.isfile(fnameg):
with open(fnameg, 'r') as f:
gen = str(f.read())
else:
gen = "1"
if (chan == 0):
urllib.request.urlopen("http://"+str(ipadr)+"/relay/0?turn=on",
timeout=3)
url = "http://" + str(ipadr) + "/relay/0?turn=on"
# urllib.request.urlopen("http://"+str(ipadr)+"/relay/0?turn=on",
# timeout=3)
else:
chan = chan - 1
urllib.request.urlopen("http://"+str(ipadr)+"/relay/" + str(chan) +
"?turn=on", timeout=3)
url = "http://" + str(ipadr) + "/relay/" + str(chan) + "?turn=on"
# urllib.request.urlopen("http://"+str(ipadr)+"/relay/" + str(chan) +
# "?turn=on", timeout=3)
if (shaut == 1):
# print("Shelly on" + str(shaut) + user + pw)
passman = urllib.request.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, url, user, pw)
authhandler = urllib.request.HTTPBasicAuthHandler(passman)
opener = urllib.request.build_opener(authhandler)
urllib.request.install_opener(opener)
with urllib.request.urlopen(url) as response:
response.read().decode("utf-8")
38 changes: 31 additions & 7 deletions packages/modules/smarthome/shelly/smartshelly.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
#!/usr/bin/python3
from smarthome.smartbase import Sbase, Slshelly
from smarthome.global0 import log
from typing import Dict
import subprocess
import logging
log = logging.getLogger(__name__)


class Sshelly(Sbase):
def __init__(self):
def __init__(self) -> None:
# setting
super().__init__()
self._old_measuretype0 = 'none'
print('__init__ Sshelly excuted')
self._device_shpassword = 'none'
self._device_shusername = 'none'
self._device_shauth = 0

def getwatt(self, uberschuss, uberschussoffset):
def getwatt(self, uberschuss: int, uberschussoffset: int) -> None:
self.prewatt(uberschuss, uberschussoffset)
self._mydevicemeasure0.devuberschuss = self.devuberschuss
self._mydevicemeasure0.getwattread()
Expand All @@ -23,8 +27,25 @@ def getwatt(self, uberschuss, uberschussoffset):
self.temp2 = self._mydevicemeasure0.temp2
self.postwatt()

def updatepar(self, input_param):
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_shusername'):
self._device_shusername = value
elif (key == 'device_shpassword'):
self._device_shpassword = value
elif (key == 'device_shauth'):
self._device_shauth = valueint
else:
log.info("(" + str(self.device_nummer) + ") Sshelly überlesen " + key +
" " + value)
if (self._old_measuretype0 == 'none'):
self._mydevicemeasure0 = Slshelly()
self._old_measuretype0 = 'shelly'
Expand All @@ -37,7 +58,7 @@ def updatepar(self, input_param):
" update " + self.device_type)
self._mydevicemeasure0.updatepar(input_param)

def turndevicerelais(self, zustand, ueberschussberechnung, updatecnt):
def turndevicerelais(self, zustand: int, ueberschussberechnung: int, updatecnt: int) -> None:
self.preturn(zustand, ueberschussberechnung, updatecnt)
if (zustand == 1):
pname = "/on.py"
Expand All @@ -46,7 +67,10 @@ def turndevicerelais(self, zustand, ueberschussberechnung, updatecnt):

argumentList = ['python3', self._prefixpy + 'shelly' + pname,
str(self.device_nummer), str(self._device_ip), '0',
str(self._device_chan)]
str(self._device_chan),
str(self._device_shauth),
self._device_shusername,
self._device_shpassword]
try:
self.proc = subprocess.Popen(argumentList)
self.proc.communicate()
Expand Down
Loading

0 comments on commit 47b78e7

Please sign in to comment.