def onCommand(self, Unit, Command, Level, Hue):
        Domoticz.Log("onCommand called for Unit " + str(Unit) + ": Parameter '" + str(Command) + "', Level: " + str(Level))
        
        Command = Command.strip()
        action, sep, params = Command.partition(' ')
        action = action.capitalize()

        self.mill = mill.Mill(Parameters["Username"], Parameters["Password"])
        self.mill.sync_connect()
        self.mill.sync_update_heaters()
        
        Domoticz.Debug("Action = "+action)
        
        if (action == 'On'):
            if (Devices[Unit].Type == 244):
                Domoticz.Log("Turning Switch "+Devices[Unit].DeviceID+" (external: "+str(decodeHeaterId(Devices[Unit].DeviceID[0:4]))+") On!")
                self.mill.sync_heater_control(decodeHeaterId(Devices[Unit].DeviceID[0:4]), fan_status=0, power_status=1)        
        if (action == 'Off'):
            if (Devices[Unit].Type == 244):
                Domoticz.Log("Turning Switch "+Devices[Unit].DeviceID+" (external: "+str(decodeHeaterId(Devices[Unit].DeviceID[0:4]))+") Off!")
                self.mill.sync_heater_control(decodeHeaterId(Devices[Unit].DeviceID[0:4]), fan_status=0, power_status=0)
        if (action == 'Set'):
            if (Devices[Unit].Type==242):
                Domoticz.Log("Setting Thermostat "+Devices[Unit].DeviceID+" (external: "+str(decodeHeaterId(Devices[Unit].DeviceID[0:4]))+") to "+str(Level))
                self.mill.sync_set_heater_temp(decodeHeaterId(Devices[Unit].DeviceID[0:4]), round(Level))

        self.getDevices()
                
        self.mill.sync_close_connection()
Exemple #2
0
 def setUpClass(cls):
     from dotenv import load_dotenv, find_dotenv
     load_dotenv(find_dotenv())
     cls.key = os.getenv('MILLHEAT_KEY')
     cls.token = os.getenv('MILLHEAT_TOKEN')
     cls.user = os.getenv('MILLHEAT_USER')
     cls.passwd = os.getenv('MILLHEAT_PASS')
     cls.mill = Mill.Mill(cls.key, cls.token, cls.user, cls.passwd)
    def onHeartbeat(self):
        Domoticz.Log("onHeartbeat called")
        
        self.mill = mill.Mill(Parameters["Username"], Parameters["Password"])
        self.mill.sync_connect()
        
        # Do some stuffff
        self.getDevices()
        
        Domoticz.Heartbeat(self.pollInterval)

        self.mill.sync_close_connection()
    def onStart(self):
        Domoticz.Log("onStart called")
        
        self.pollInterval = int(Parameters["Mode1"])  #Time in seconds between two polls
                
        if Parameters["Mode2"] == "Notify":
            self.notify = True

        if Parameters["Mode6"] == "Debug":
            Domoticz.Debugging(1)
            self.debug = True
            DumpConfigToLog()
                
        Domoticz.Heartbeat(self.pollInterval)
        
        self.mill = mill.Mill(Parameters["Username"], Parameters["Password"])
        self.mill.sync_connect()
        self.mill.sync_update_heaters()
        
        self.getDevices()
Exemple #5
0
import json
from dotenv import load_dotenv
import os

load_dotenv()

DARKSKY_SECRET = os.getenv('DARKSKY_SECRET')
MILL_USERNAME = os.getenv('MILL_USERNAME')
MILL_PASSWORD = os.getenv('MILL_PASSWORD')
LATITUDE = os.getenv('LATITUDE')
LONGITUDE = os.getenv('LONGITUDE')

DARKSKY_URL = "https://api.darksky.net/forecast/"+DARKSKY_SECRET + \
    "/"+LATITUDE+", "+LONGITUDE+"?exclude=[hourly,daily,alerts,flags]&units=si"

mill_connection = mill.Mill(MILL_USERNAME, MILL_PASSWORD)
mill_connection.sync_connect()

current_oat = 100


def deg(num):
    return str(num)+"°C"


def getOAT():
    try:
        response = urllib.request.urlopen(DARKSKY_URL)
        data = json.load(response)
        oat = data['currently']['temperature']
        print(deg(oat))