Hello guys,
I been trying to create a python script to toggle my switches status whenever there is a power outage.
I have several chacon outlets controlled by an RFX433 device. Whenver there is a power outage at my home and the power is then restabilished, these switches remain off.
My domoticz is supplied by an UPS and I have a relay powered by a normal supply for which I created a switch to know if the power is ON or OFF.
My idea is to activate a python switch whenever the power is restabished by toggling the status of my switches 2 times to bring the outlets to their previous state.
I tried running some scripts using json but without success. I didn't want to be running "curl" commands on my script.
Has anyone run/developed something like this ?
Regards,
Domoticz current state - toggle switches after power supply down
Moderator: leecollings
-
- Posts: 7
- Joined: Thursday 24 September 2015 11:36
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Domoticz current state - toggle switches after power supply down
Since no help was available, please check how I did it :
import os
import sys
import csv
import time
import datetime
from shutil import move
from datetime import date, timedelta
import urllib2
import json
import subprocess
def main():
switches = ["79","80","110","109","108","42","78","44"]
i=0
FNULL = open(os.devnull, 'w')
while i<len(switches):
print(switches)
subprocess.call(["/usr/bin/curl", "-s",
"http://USERNAME:PASSWORD@DOMOTICZ_IP_ADDRESS:PORT/json.htm?type=command¶m=switchlight&idx=" + switches +"&switchcmd=Toggle"])
time.sleep(2)
subprocess.call(["/usr/bin/curl", "-s",
"http://USERNAME:PASSWORD@DOMOTICZ_IP_ADDRESS:PORT/json.htm?type=command¶m=switchlight&idx=" + switches +"&switchcmd=Toggle"])
time.sleep(2)
i+=1
main ()
import os
import sys
import csv
import time
import datetime
from shutil import move
from datetime import date, timedelta
import urllib2
import json
import subprocess
def main():
switches = ["79","80","110","109","108","42","78","44"]
i=0
FNULL = open(os.devnull, 'w')
while i<len(switches):
print(switches)
subprocess.call(["/usr/bin/curl", "-s",
"http://USERNAME:PASSWORD@DOMOTICZ_IP_ADDRESS:PORT/json.htm?type=command¶m=switchlight&idx=" + switches +"&switchcmd=Toggle"])
time.sleep(2)
subprocess.call(["/usr/bin/curl", "-s",
"http://USERNAME:PASSWORD@DOMOTICZ_IP_ADDRESS:PORT/json.htm?type=command¶m=switchlight&idx=" + switches +"&switchcmd=Toggle"])
time.sleep(2)
i+=1
main ()
Who is online
Users browsing this forum: No registered users and 1 guest