Skip to content

Commit

Permalink
Update get_devices_url.py
Browse files Browse the repository at this point in the history
  • Loading branch information
pzim-devdata authored Nov 25, 2023
1 parent 1efdaff commit 1094dcb
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions get_devices_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from pyoverkiz.enums import OverkizCommand
from pyoverkiz.models import Command
from pyoverkiz.models import Scenario
import base64

async def main() -> None:

Expand All @@ -33,6 +34,7 @@ async def main() -> None:
list_of_tahoma_states = os.path.dirname(os.path.abspath(__file__))+'/temp/states.txt'

server_choosen = os.path.dirname(os.path.abspath(__file__))+'/temp/server_choosen.txt'
test_file = os.path.dirname(os.path.abspath(__file__))+'/test/test.txt'

try :
f = open(server_choosen, 'r')
Expand Down Expand Up @@ -60,13 +62,21 @@ async def main() -> None:
args = parser.parse_args()

try :
f = open(passwd_file, 'r')
f = open(test_file, 'r')
test = f.read()
f.close()
except FileNotFoundError:
test = "Hipk,@nP3%c@U2ZpC"

try :
f = open(passwd_file, 'rb')
content = f.read()
f.close()
if len(content.splitlines()[0]) > 0 :
USERNAME = content.splitlines()[0]
if len(content.splitlines()[1]) > 0 :
PASSWORD = content.splitlines()[1]
content_str = base64.b64decode(content).decode('utf-8')
if len(content_str.split(':')[0]) > 0 :
USERNAME = content_str.split(':')[0]
if len(content_str.split(':')[1]) > 0 :
PASSWORD = content_str.split(':')[1].replace(test, "")
except: pass

for arg in sys.argv:
Expand Down Expand Up @@ -106,6 +116,9 @@ async def main() -> None:
elif "StatelessOnOff" in device.widget :
f7.write(device.label+","+device.id+","+device.widget+"\n")
print( "Device "+device.label+" controled by tahoma. Added to : "+list_of_tahoma_plugs)
elif "StatefulOnOff" in device.widget :
f7.write(device.label+","+device.id+","+device.widget+"\n")
print( "Device "+device.label+" controled by tahoma. Added to : "+list_of_tahoma_plugs)
elif "PositionableScreen" in device.widget or "PositionableHorizontalAwning" in device.widget:
f8.write(device.label+","+device.id+","+device.widget+"\n")
print( "Device "+device.label+" controled by tahoma. Added to : "+list_of_tahoma_sunscreens)
Expand Down

0 comments on commit 1094dcb

Please sign in to comment.