def dev_status(): s = sonoff.Sonoff("*****@*****.**", "smarteff", "us") devices = s.get_devices() return render_template("never.html", kablolubaglanti="Monitoring", devicelist=devices, deviceid=1)
def manage_devices(): s = sonoff.Sonoff("*****@*****.**", "smarteff", "us") devices = s.get_devices() return render_template("ingdog.html", sayfabasligi="Main Page", devicelist=devices, deviceid=1)
def onSwitchChanged(self, widget, state): if state == True: #Clear old data self.cTreeStore.clear() #Instantiate sonoff with access data self.cHome = sonoff.Sonoff(self.cEntryUsername.get_text(), self.cEntryPassword.get_text(), self.cEntryRegion.get_active_text(), self.cEntryApiKey.get_text() #self.cEntryToken.get_text() ) self.updateTreeView() else: #NO - The slider was turned off. #Clear the TextView self.cTreeStore.clear()
def full_login(self): while True: if self.username is None: self.username = gr( "ConfigurationResource").config["sonoff_username"] if self.password is None: self.password = gr( "ConfigurationResource").config["sonoff_password"] if self.region is None: self.region = gr("ConfigurationResource").config.get( "sonoff_region", "us") self.s = sonoff.Sonoff(self.username, self.password, self.region) yield from self.update() yield from asyncio.sleep(HOURS(8))
device.switch(action) elif action == "wait3": device.on() time.sleep(3) device.off() elif action == "status": status = device.get_status() print() print("----------------") print(str(status)) print("----------------") print() print() s = sonoff.Sonoff(config.username, config.password, config.api_region) devices = s.get_devices() print("Found " + str(len(devices)) + " devices.") end = False while not end: show_devices(devices) device_id = select_deviceId() device = Device.device_from_info(s, devices[device_id]) show_menu() action = read_action() execute(device, action) if action == "exit": end = True
import sonoff if __name__ == '__main__': devices = [] try: s = sonoff.Sonoff('*****@*****.**', 'Sonoff123@', 'eu') s.update_devices() devices = s.get_devices() print(devices) except Exception as e: print('EX ' + e)
import json import sonoff import time import requests # logger setup logger = logging.getLogger('my-logger') logger.propagate = False logging.basicConfig(filename='event_history.log', format='%(asctime)s - %(message)s', datefmt='%d-%b-%y %H:%M:%S', level=logging.WARNING) logging.StreamHandler(stream=None) s = sonoff.Sonoff("*****@*****.**", "smarteff", "us") # endpoint to handle person events @app.route("/HandlePersonEvent", methods=['POST']) def person_event(): # parse http request body data = request.json person_id = data['personid'] event = data['event'] # get person or throw 404 person = Person.query.get_or_404(person_id) # change is_inside status according to event