Ejemplo n.º 1
0
class FridgeFreezer:

    def __init__(self,token,haID, url):
        self.token = "Bearer " + token
        self.haID = haID
        self.url = url
        self.headers = {"Accept":"application/vnd.bsh.sdk.v1+json","Content-Type":"application/json","Authorization": self.token}
        self.httputil = HttpUtil()
        self.logger = logModule()
    def getStatus(self):
        url = self.url + self.haID + "/status"
        self.logger.debug(url)
        duration = self.httputil.Get(url,self.headers)
        if duration is not -1:
            self.logger.info("Get Status in "+ str(duration)+ " seconds")
        else:
            self.logger.error("Fail to operate HA due to unknown reason")

    def changeTemperature(self):
        program = ""
        randomPick = random.randint(0,3)
        if randomPick is 0:
            settingKey = "Refrigeration.FridgeFreezer.Setting.SetpointTemperatureFreezer"
            Temperature = random.randint(-24,-16)
            body = {"data":{"key":"Refrigeration.FridgeFreezer.Setting.SetpointTemperatureFreezer","value":Temperature,"unit":"°C"}}
            program = "Freezer Temperature"
        elif randomPick is 1:
            settingKey = "Refrigeration.FridgeFreezer.Setting.SetpointTemperatureRefrigerator"
            Temperature = random.randint(2,8)
            body = {"data":{"key":"Refrigeration.FridgeFreezer.Setting.SetpointTemperatureRefridgerator","value":Temperature,"unit":"°C"}}
            program = "Refrigerator Temperature"
        elif randomPick is 2:
            settingKey = "Refrigeration.FridgeFreezer.Setting.SuperModeFreezer"
            body = {"data":{"key":"Refrigeration.FridgeFreezer.Setting.SuperModeFreezer","value":True}}
            program = "Super Mode Freezer"
        elif randomPick is 3:
            settingKey = "Refrigeration.FridgeFreezer.Setting.SuperModeRefrigerator"
            body = {"data":{"key":"Refrigeration.FridgeFreezer.Setting.SuperModeRefrigerator","value":True}}
            program = "Super Mode Refridgerator"
        url = self.url + self.haID + "/settings/" + settingKey
        self.logger.debug(url)
        bodyJson = json.dumps(body)
        duration = self.httputil.Put(url,bodyJson,self.headers)
        if duration is not -1:
            self.logger.info(program + " starts in " + str(duration) + " seconds")
        else:
            self.logger.error("Failed to operation HA due to unknown reason")

    def stopProgram(self):
        url = self.url + self.haID + "/programs/active"
        duration = self.httputil.Delete(url,self.headers)
        if duration is not -1:
            print ("program stops in "+ str(duration)+ " seconds")
        else:
            print ("Failed to operate HA due to unknown reason")
Ejemplo n.º 2
0
class Washer:

    def __init__(self,token,haID, url):
        self.token = "Bearer " + token
        self.haID = haID
        self.url = url
        self.headers = {"Accept":"application/vnd.bsh.sdk.v1+json","Content-Type":"application/json","Authorization": self.token}
        self.httputil = HttpUtil()
        self.logger = logModule()
    def getStatus(self):
        url = self.url + self.haID + "/status"
        self.logger.debug(url)
        duration = self.httputil.Get(url,self.headers)
        if duration is not -1:
            self.logger.info("Get Status in "+ str(duration) + " seconds")
        else:
            self.logger.error("Fail to operate HA due to unknown reason")

    def putProgram(self):
        program = ""
        randomPick = (random.randint(0,20)%5)
        if randomPick is 0:
            body = {"data":{"key":"LaundryCare.Washer.Program.Cotton","options":[{"key":"LaundryCare.Washer.Option.Temperature","value":"LaundryCare.Washer.EnumType.Temperature.GC30"},{"key":"LaundryCare.Washer.Option.SpinSpeed","value":"LaundryCare.Washer.EnumType.SpinSpeed.RPM800"}]}}
            program = "Cotton"
        elif randomPick is 1:
            body = {"data":{"key":"LaundryCare.Washer.Program.EasyCare","options":[{"key":"LaundryCare.Washer.Option.Temperature","value":"LaundryCare.Washer.EnumType.Temperature.GC30"},{"key":"LaundryCare.Washer.Option.SpinSpeed","value":"LaundryCare.Washer.EnumType.SpinSpeed.RPM800"}]}}
            program = "EasyCare"
        elif randomPick is 2:
            body = {"data":{"key":"LaundryCare.Washer.Program.Mix","options":[{"key":"LaundryCare.Washer.Option.Temperature","value":"LaundryCare.Washer.EnumType.Temperature.GC30"},{"key":"LaundryCare.Washer.Option.SpinSpeed","value":"LaundryCare.Washer.EnumType.SpinSpeed.RPM800"}]}}
            program = "Mix"
        elif randomPick is 3:
            body = {"data":{"key":"LaundryCare.Washer.Program.Wool","options":[{"key":"LaundryCare.Washer.Option.Temperature","value":"LaundryCare.Washer.EnumType.Temperature.GC30"},{"key":"LaundryCare.Washer.Option.SpinSpeed","value":"LaundryCare.Washer.EnumType.SpinSpeed.RPM800"}]}}
            program = "Wool"
        elif randomPick is 4:
            body = {"data":{"key":"LaundryCare.Washer.Program.DelicatesSilk","options":[{"key":"LaundryCare.Washer.Option.Temperature","value":"LaundryCare.Washer.EnumType.Temperature.GC30"},{"key":"LaundryCare.Washer.Option.SpinSpeed","value":"LaundryCare.Washer.EnumType.SpinSpeed.RPM800"}]}}
            program = "Delicates Silk"

        url = self.url + self.haID + "/programs/active"
        self.logger.debug(url)
        bodyJson = json.dumps(body)
        duration = self.httputil.Put(url,bodyJson,self.headers)
        if duration is not -1:
            self.logger.info(program + " starts in " + str(duration)+ " seconds")
        else:
            self.logger.error("Failed to operation HA due to unknown reason")

    def stopProgram(self):
        url = self.url + self.haID + "/programs/active"
        duration = self.httputil.Delete(url,self.headers)
        if duration is not -1:
            self.logger.info("program stops in "+ str(duration)+ " seconds")
        else:
            self.logger.error("Failed to operate HA due to unknown reason")
Ejemplo n.º 3
0
class Oven:

    def __init__(self,token,haID, url):
        self.token = "Bearer " + token
        self.haID = haID
        self.url = url
        self.headers = {"Accept":"application/vnd.bsh.sdk.v1+json","Content-Type":"application/json","Authorization": self.token}
        self.httputil = HttpUtil()
        self.logger = logModule()
    def getStatus(self):
        url = self.url + self.haID + "/status"
        self.logger.debug(url)
        duration = self.httputil.Get(url,self.headers)
        if duration is not -1:
            self.logger.info("Get Status in "+ str(duration) + " seconds")
        else:
            self.logger.error("Fail to operate HA due to unknown reason")

    def putProgram(self):
        program = ""
        randomPick = (random.randint(0,20)%3)
        if randomPick is 0:
            body = {"data":{"key":"Cooking.Oven.Program.HeatingMode.PreHeating","options":[{"key":"Cooking.Oven.Option.SetpointTemperature","value":230,"unit":"°C"},{"key":"BSH.Common.Option.Duration","value":1200,"unit":"seconds"}]}}
            program = "PreHeating"
        elif randomPick is 1:
            body = {"data":{"key":"Cooking.Oven.Program.HeatingMode.HotAir","options":[{"key":"Cooking.Oven.Option.SetpointTemperature","value":230,"unit":"°C"},{"key":"BSH.Common.Option.Duration","value":1200,"unit":"seconds"}]}}
            program = "HotAir"
        elif randomPick is 2:
            body = {"data":{"key":"Cooking.Oven.Program.HeatingMode.TopBottomHeating","options":[{"key":"Cooking.Oven.Option.SetpointTemperature","value":230,"unit":"°C"},{"key":"BSH.Common.Option.Duration","value":1200,"unit":"seconds"}]}}
            program = "TopBottomHeating"
        elif randomPick is 3:
            body = {"data":{"key":"Cooking.Oven.Program.HeatingMode.PizzaSetting","options":[{"key":"Cooking.Oven.Option.SetpointTemperature","value":230,"unit":"°C"},{"key":"BSH.Common.Option.Duration","value":1200,"unit":"seconds"}]}}
            program = "Eco 50 degree"
        url = self.url + self.haID + "/programs/active"
        self.logger.debug(url)
        bodyJson = json.dumps(body)
        duration = self.httputil.Put(url,bodyJson,self.headers)
        if duration is not -1:
            self.logger.info(program + " starts in " + str(duration) + " seconds")
        else:
            self.logger.error("Failed to operation HA due to unknown reason")

    def stopProgram(self):
        url = self.url + self.haID + "/programs/active"
        duration = self.httputil.Delete(url,self.headers)
        if duration is not -1:
            self.logger.info("program stops in "+ str(duration)+ " seconds")
        else:
            self.logger.error("Failed to operate HA due to unknown reason")
Ejemplo n.º 4
0
class Dryer:
    def __init__(self, token, haID, url):
        self.token = "Bearer " + token
        self.haID = haID
        self.url = url
        self.headers = {
            "Accept": "application/vnd.bsh.sdk.v1+json",
            "Content-Type": "application/json",
            "Authorization": self.token
        }
        self.httputil = HttpUtil()
        self.logger = logModule()

    def getStatus(self):
        url = self.url + self.haID + "/status"
        print(url)
        duration = self.httputil.Get(url, self.headers)
        if duration is not -1:
            self.logger.info("Get Status in " + str(duration) + " seconds")
        else:
            self.logger.error("Fail to operate HA due to unknown reason")

    def putProgram(self):
        program = ""
        randomPick = (random.randint(0, 9) % 3)
        if randomPick is 0:
            body = {
                "data": {
                    "key":
                    "LaundryCare.Dryer.Program.Cotton",
                    "options": [{
                        "key":
                        "LaundryCare.Dryer.Option.DryingTarget",
                        "value":
                        "LaundryCare.Dryer.EnumType.DryingTarget.CupboardDry"
                    }]
                }
            }
            program = "Cotton"
        elif randomPick is 1:
            body = {
                "data": {
                    "key":
                    "LaundryCare.Dryer.Program.Synthetic",
                    "options": [{
                        "key":
                        "LaundryCare.Dryer.Option.DryingTarget",
                        "value":
                        "LaundryCare.Dryer.EnumType.DryingTarget.CupboardDry"
                    }]
                }
            }
            program = "Synthetic"
        elif randomPick is 2:
            body = {
                "data": {
                    "key":
                    "LaundryCare.Dryer.Program.Mix",
                    "options": [{
                        "key":
                        "LaundryCare.Dryer.Option.DryingTarget",
                        "value":
                        "LaundryCare.Dryer.EnumType.DryingTarget.CupboardDry"
                    }]
                }
            }
            program = "Mix"
        url = self.url + self.haID + "/programs/active"
        self.logger.debug(url)
        bodyJson = json.dumps(body)
        duration = self.httputil.Put(url, bodyJson, self.headers)
        if duration is not -1:
            self.logger.info(program + " starts in " + str(duration) +
                             " seconds")
        else:
            self.logger.error("Failed to operation HA due to unknown reason")

    def stopProgram(self):
        url = self.url + self.haID + "/programs/active"
        duration = self.httputil.Delete(url, self.headers)
        if duration is not -1:
            self.logger.info("program stops in " + str(duration) + " seconds")
        else:
            self.logger.error("Failed to operate HA due to unknown reason")
Ejemplo n.º 5
0
class CoffeeMaker:
    def __init__(self, token, haID, url):
        self.token = "Bearer " + token
        self.haID = haID
        self.url = url
        self.headers = {
            "Accept": "application/vnd.bsh.sdk.v1+json",
            "Content-Type": "application/json",
            "Authorization": self.token
        }
        self.httputil = HttpUtil()
        self.logger = logModule()

    def getStatus(self):
        url = self.url + self.haID + "/status"
        self.logger.debug(url)
        duration = self.httputil.Get(url, self.headers)
        if duration is not -1:
            self.logger.info("Get Status in " + str(duration) + " seconds")
        else:
            self.logger.error("Fail to operate HA due to unknown reason")

    def putProgram(self):
        program = ""
        randomPick = (random.randint(0, 5))
        if randomPick is 0:
            body = {
                "data": {
                    "key":
                    "ConsumerProducts.CoffeeMaker.Program.Beverage.Espresso",
                    "options": [{
                        "key":
                        "ConsumerProducts.CoffeeMaker.Option.BeanAmount",
                        "value":
                        "ConsumerProducts.CoffeeMaker.EnumType.BeanAmount.Mild"
                    }, {
                        "key":
                        "ConsumerProducts.CoffeeMaker.Option.FillQuantity",
                        "value": 45,
                        "unit": "ml"
                    }]
                }
            }
            program = "Espresso"
        elif randomPick is 1:
            body = {
                "data": {
                    "key":
                    "ConsumerProducts.CoffeeMaker.Program.Beverage.EspressoMacchiato",
                    "options": [{
                        "key":
                        "ConsumerProducts.CoffeeMaker.Option.BeanAmount",
                        "value":
                        "ConsumerProducts.CoffeeMaker.EnumType.BeanAmount.Mild"
                    }, {
                        "key":
                        "ConsumerProducts.CoffeeMaker.Option.FillQuantity",
                        "value": 50,
                        "unit": "ml"
                    }]
                }
            }
            program = "HotAir"
        elif randomPick is 2:
            body = {
                "data": {
                    "key":
                    "ConsumerProducts.CoffeeMaker.Program.Beverage.Coffee",
                    "options": [{
                        "key":
                        "ConsumerProducts.CoffeeMaker.Option.BeanAmount",
                        "value":
                        "ConsumerProducts.CoffeeMaker.EnumType.BeanAmount.Mild"
                    }, {
                        "key":
                        "ConsumerProducts.CoffeeMaker.Option.FillQuantity",
                        "value": 120,
                        "unit": "ml"
                    }]
                }
            }
            program = "TopBottomHeating"
        elif randomPick is 3:
            body = {
                "data": {
                    "key":
                    "ConsumerProducts.CoffeeMaker.Program.Beverage.Cappuccino",
                    "options": [{
                        "key":
                        "ConsumerProducts.CoffeeMaker.Option.BeanAmount",
                        "value":
                        "ConsumerProducts.CoffeeMaker.EnumType.BeanAmount.Mild"
                    }, {
                        "key":
                        "ConsumerProducts.CoffeeMaker.Option.FillQuantity",
                        "value": 180,
                        "unit": "ml"
                    }]
                }
            }
            program = "Cappuccino"
        elif randomPick is 4:
            body = {
                "data": {
                    "key":
                    "ConsumerProducts.CoffeeMaker.Program.Beverage.LatteMacchiato",
                    "options": [{
                        "key":
                        "ConsumerProducts.CoffeeMaker.Option.BeanAmount",
                        "value":
                        "ConsumerProducts.CoffeeMaker.EnumType.BeanAmount.Mild"
                    }, {
                        "key":
                        "ConsumerProducts.CoffeeMaker.Option.FillQuantity",
                        "value": 320,
                        "unit": "ml"
                    }]
                }
            }
            program = "Latte Macchiato"
        elif randomPick is 5:
            body = {
                "data": {
                    "key":
                    "ConsumerProducts.CoffeeMaker.Program.Beverage.CaffeLatte",
                    "options": [{
                        "key":
                        "ConsumerProducts.CoffeeMaker.Option.BeanAmount",
                        "value":
                        "ConsumerProducts.CoffeeMaker.EnumType.BeanAmount.Mild"
                    }, {
                        "key":
                        "ConsumerProducts.CoffeeMaker.Option.FillQuantity",
                        "value": 240,
                        "unit": "ml"
                    }]
                }
            }
            program = "Caffe Latte"
        url = self.url + self.haID + "/programs/active"
        self.logger.debug(url)
        bodyJson = json.dumps(body)
        duration = self.httputil.Put(url, bodyJson, self.headers)
        if duration is not -1:
            self.logger.info(program + " starts in " + str(duration) +
                             " seconds")
        else:
            self.logger.error("Failed to operation HA due to unknown reason")

    def stopProgram(self):
        url = self.url + self.haID + "/programs/active"
        duration = self.httputil.Delete(url, self.headers)
        if duration is not -1:
            self.logger.info("program stops in " + str(duration) + " seconds")
        else:
            self.logger.error("Failed to operate HA due to unknown reason")
Ejemplo n.º 6
0
class Dishwasher:
    def __init__(self, token, haID, url):
        self.token = "Bearer " + token
        self.haID = haID
        self.url = url
        self.headers = {
            "Accept": "application/vnd.bsh.sdk.v1+json",
            "Content-Type": "application/json",
            "Authorization": self.token
        }
        self.httputil = HttpUtil()
        self.logger = logModule()

    def getStatus(self):
        url = self.url + self.haID + "/status"
        self.logger.debug(url)
        duration = self.httputil.Get(url, self.headers)
        if duration is not -1:
            self.logger.info("Get Status in " + str(duration) + " seconds")
        else:
            self.logger.error("Fail to operate HA due to unknown reason")

    def putProgram(self):
        program = ""
        randomPick = (random.randint(0, 4))
        if randomPick is 0:
            body = {
                "data": {
                    "key":
                    "Dishcare.Dishwasher.Program.Auto1",
                    "options": [{
                        "key": "BSH.Common.Option.StartInRelative",
                        "value": 1800,
                        "unit": "seconds"
                    }]
                }
            }
            program = "Auto 35-45 degree"
        elif randomPick is 1:
            body = {
                "data": {
                    "key":
                    "Dishcare.Dishwasher.Program.Auto2",
                    "options": [{
                        "key": "BSH.Common.Option.StartInRelative",
                        "value": 1800,
                        "unit": "seconds"
                    }]
                }
            }
            program = "Auto 45-65 degree"
        elif randomPick is 2:
            body = {
                "data": {
                    "key":
                    "Dishcare.Dishwasher.Program.Auto3",
                    "options": [{
                        "key": "BSH.Common.Option.StartInRelative",
                        "value": 1800,
                        "unit": "seconds"
                    }]
                }
            }
            program = "Auto 65-75 degree"
        elif randomPick is 3:
            body = {
                "data": {
                    "key":
                    "Dishcare.Dishwasher.Program.Eco50",
                    "options": [{
                        "key": "BSH.Common.Option.StartInRelative",
                        "value": 1800,
                        "unit": "seconds"
                    }]
                }
            }
            program = "Eco 50 degree"
        elif randomPick is 4:
            body = {
                "data": {
                    "key":
                    "Dishcare.Dishwasher.Program.Quick45",
                    "options": [{
                        "key": "BSH.Common.Option.StartInRelative",
                        "value": 1800,
                        "unit": "seconds"
                    }]
                }
            }
            program = "Quick45"
        url = self.url + self.haID + "/programs/active"
        self.logger.debug(url)
        bodyJson = json.dumps(body)
        duration = self.httputil.Put(url, bodyJson, self.headers)
        if duration is not -1:
            self.logger.info(program + " starts in " + str(duration) +
                             " seconds")
        else:
            self.logger.error("Failed to operation HA due to unknown reason")

    def stopProgram(self):
        url = self.url + self.haID + "/programs/active"
        duration = self.httputil.Delete(url, self.headers)
        if duration is not -1:
            self.logger.info("program stops in " + str(duration) + " seconds")
        else:
            self.logger.error("Failed to operate HA due to unknown reason")