Ejemplo n.º 1
0
    def onStart(self):
        if Parameters["Mode6"] == "Debug":
            Domoticz.Debugging(1)
            Domoticz.Trace(True)
            self.debug = True
            DumpConfigToLog()

        Domoticz.Debug("onStart called")
        updateInterval = int(Parameters["Mode1"])
        if updateInterval > 30 or updateInterval < 7:
            updateInterval = 10
            Domoticz.Error("Invalid interval setting, changed to 10")

        Domoticz.Heartbeat(updateInterval)
        self.webos_client = WebOsClient(Parameters["Address"], "NONE", 5)

        # First get some TV details
        try:
            tv_details = self.webos_client.get_software_info()
            Domoticz.Log("Product name: " + tv_details["product_name"])
            Domoticz.Log("Software version: " + tv_details["major_ver"] + "." +
                         tv_details["minor_ver"])
            Domoticz.Log("MAC Address: " + tv_details["device_id"])
        except Exception as e:
            Domoticz.Error("Error at reading TV info")

        if not (1 in Devices):
            Domoticz.Device(Name="TV Status", Unit=1, Type=17,
                            Switchtype=17).Create()

        if not (2 in Devices):
            Domoticz.Device(Name="TV Volume",
                            Unit=2,
                            Type=244,
                            Subtype=73,
                            Switchtype=7,
                            Image=8).Create()

        return True