Pārlūkot izejas kodu

Emotion Stats hinzufügen
Refs #2

Patrick Baumgartner 4 gadi atpakaļ
vecāks
revīzija
72e519a77f
11 mainītis faili ar 1611 papildinājumiem un 0 dzēšanām
  1. 1 0
      .gitignore
  2. BIN
      .vs/Trixy/v17/.suo
  3. 26 0
      Stats/AdminStats.py
  4. 964 0
      Stats/DeviceStats.py
  5. 49 0
      Stats/HouseStats.py
  6. 52 0
      Stats/MicLevel.py
  7. 26 0
      Stats/OutdoorStats.py
  8. 25 0
      Stats/OwnerStats.py
  9. 24 0
      Stats/TalkingStats.py
  10. 424 0
      Stats/__init__.py
  11. 20 0
      Trixy.pyproj

+ 1 - 0
.gitignore

@@ -1 +1,2 @@
 /.vs
+*/__pycache__

BIN
.vs/Trixy/v17/.suo


+ 26 - 0
Stats/AdminStats.py

@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from datetime import *
+
+class AdminStats(object):
+
+    LastAdminDate = None
+
+
+    @property
+    def IsAllowed(self):
+        if self.LastAdminDate==None:
+            return False
+        if datetime.now() - timedelta(minutes=1) > self.LastAdminDate:
+            return False
+        else:
+            return True
+
+
+    @IsAllowed.setter
+    def IsAllowed(self, value):
+        if value==True:
+            self.LastAdminDate = datetime.now()
+        else:
+            self.LastAdminDate = None

+ 964 - 0
Stats/DeviceStats.py

@@ -0,0 +1,964 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import time
+import os.path
+import TextConfig
+from RepeatTimer import RepeatTimer
+import configparser
+
+class DeviceStats(object):
+
+    #TODO: via config.ini deaktivierbare Stats, z.B. angry dauerhaft auf 0 setzen
+    #TODO: Abhängigkeit der Mondphase einbauen - Bei Vollmond gehen manche Stats schneller höch
+    #TODO: Abhängigkeit der Blauen Stunde / Goldenen Stunde, bedingt an Wetter und Wolken
+
+    MAX_VALUE:float = 1000
+    SAVE_STATS_INTERVAL = 1
+
+    #angry = 0.0
+    #aroused = 0.0
+    #hungry = 0.0
+    #happyness = 0.0
+    #funny = 0.0
+    #annoyed = 0.0
+    #irritated = 0.0
+    #bored = 0.0
+    #intelligent = 0.0
+    #sleepy = 0.0
+    #energy = 0.0
+    #exhausted = 0.0
+    #depressive = 0.0
+    #sad = 0.0
+    #useless = 0.0
+    #usefull = 0.0
+    #compfortable = 0.0
+    #temperate = 0.0 # Wohl temperiert - ist die Temperatur angenehm
+    #shy = 0.0
+    #excited = 0.0
+    #toLoud = 0.0 # Zu laut
+    #toQuiet = 0.0 # Zu leise
+    #playful = 0.0
+    #naiv = 0.0
+    #freezy = 0.0
+    #hot = 0.0
+    #humanity = 0.0
+    #lonely = 0.0
+    #soziality = 0.0
+
+    #lastTimeToLoud = 0
+    #lastTimeToQuiet = 0
+    #lastTimeAngry = 0
+    #lastTimeLonely = 0
+    lastUpdate = 0
+
+    def __init__(self):
+        self._angry = 0.0
+        self._aroused = 0.0
+        self._hungry = 0.0
+        self._happyness = 0.0
+        self._funny = 0.0
+        self._annoyed = 0.0
+        self._irritated = 0.0
+        self._bored = 0.0
+        self._intelligent = 0.0
+        self._sleepy = 0.0
+        self._energy = 0.0
+        self._exhausted = 0.0
+        self._depressive = 0.0
+        self._sad = 0.0
+        self._useless = 0.0
+        self._usefull = 0.0
+        self._compfortable = 0.0
+        self._temperate = 0.0
+        self._shy = 0.0
+        self._excited = 0.0
+        self._toLoud = 0.0
+        self._toQuiet = 0.0
+        self._playful = 0.0
+        self._naiv = 0.0
+        self._freezy = 0.0
+        self._hot = 0.0
+        self._lonely = 0.0
+        self._humanity = 0.0
+        self._soziality = 0.0
+
+
+        self._lastTimeToLoud = 0.0
+        self._lastTimeToQuiet = 0.0
+        self._lastTimeAngry = 0.0
+        self._lastTimeLonely = 0.0
+
+        self._locked_angry = -1.0
+        self._locked_aroused = -1.0
+        self._locked_hungry = -1.0
+        self._locked_happyness = -1.0
+        self._locked_funny = -1.0
+        self._locked_annoyed = -1.0
+        self._locked_irritated = -1.0
+        self._locked_bored = -1.0
+        self._locked_intelligent = -1.0
+        self._locked_sleepy = -1.0
+        self._locked_energy = -1.0
+        self._locked_exhausted = -1.0
+        self._locked_depressive = -1.0
+        self._locked_sad = -1.0
+        self._locked_useless = -1.0
+        self._locked_usefull = -1.0
+        self._locked_compfortable = -1.0
+        self._locked_temperate = -1.0
+        self._locked_shy = -1.0
+        self._locked_excited = -1.0
+        self._locked_toLoud = -1.0
+        self._locked_toQuiet = -1.0
+        self._locked_playful = -1.0
+        self._locked_naiv = -1.0
+        self._locked_freezy = -1.0
+        self._locked_hot = -1.0
+        self._locked_lonely = -1.0
+        self._locked_humanity = -1.0
+        self._locked_soziality = -1.0
+
+        self.textconfig = TextConfig.TextConfig("stats.txt")
+        self.Load()
+        self.Thread_Save = RepeatTimer(self.SAVE_STATS_INTERVAL*60, self.Save)
+        self.Thread_Save.start()
+        if(True):
+            config = configparser.ConfigParser()
+            config.read('config.ini')
+            if "angry" in config["Locked_Stats"]:
+                self._locked_angry = float(config["Locked_Stats"]["angry"])
+            if "aroused" in config["Locked_Stats"]:
+                self._locked_aroused = float(config["Locked_Stats"]["aroused"])
+            if "hungry" in config["Locked_Stats"]:
+                self._locked_hungry = float(config["Locked_Stats"]["hungry"])
+            if "happyness" in config["Locked_Stats"]:
+                self._locked_happyness = float(config["Locked_Stats"]["happyness"])
+            if "funny" in config["Locked_Stats"]:
+                self._locked_funny = float(config["Locked_Stats"]["funny"])
+            if "annoyed" in config["Locked_Stats"]:
+                self._locked_annoyed = float(config["Locked_Stats"]["annoyed"])
+            if "irritated" in config["Locked_Stats"]:
+                self._locked_irritated = float(config["Locked_Stats"]["irritated"])
+            if "bored" in config["Locked_Stats"]:
+                self._locked_bored = float(config["Locked_Stats"]["bored"])
+            if "intelligent" in config["Locked_Stats"]:
+                self._locked_intelligent = float(config["Locked_Stats"]["intelligent"])
+            if "sleepy" in config["Locked_Stats"]:
+                self._locked_sleepy = float(config["Locked_Stats"]["sleepy"])
+            if "energy" in config["Locked_Stats"]:
+                self._locked_energy = float(config["Locked_Stats"]["energy"])
+            if "exhausted" in config["Locked_Stats"]:
+                self._locked_exhausted = float(config["Locked_Stats"]["exhausted"])
+            if "depressive" in config["Locked_Stats"]:
+                self._locked_depressive = float(config["Locked_Stats"]["depressive"])
+            if "sad" in config["Locked_Stats"]:
+                self._locked_sad = float(config["Locked_Stats"]["sad"])
+            if "useless" in config["Locked_Stats"]:
+                self._locked_useless = float(config["Locked_Stats"]["useless"])
+            if "usefull" in config["Locked_Stats"]:
+                self._locked_usefull = float(config["Locked_Stats"]["usefull"])
+            if "compfortable" in config["Locked_Stats"]:
+                self._locked_compfortable = float(config["Locked_Stats"]["compfortable"])
+            if "temperate" in config["Locked_Stats"]:
+                self._locked_temperate = float(config["Locked_Stats"]["temperate"])
+            if "shy" in config["Locked_Stats"]:
+                self._locked_shy = float(config["Locked_Stats"]["shy"])
+            if "excited" in config["Locked_Stats"]:
+                self._locked_excited = float(config["Locked_Stats"]["excited"])
+            if "toLoud" in config["Locked_Stats"]:
+                self._locked_toLoud = float(config["Locked_Stats"]["toLoud"])
+            if "toQuiet" in config["Locked_Stats"]:
+                self._locked_toQuiet = float(config["Locked_Stats"]["toQuiet"])
+            if "playful" in config["Locked_Stats"]:
+                self._locked_playful = float(config["Locked_Stats"]["playful"])
+            if "naiv" in config["Locked_Stats"]:
+                self._locked_naiv = float(config["Locked_Stats"]["naiv"])
+            if "freezy" in config["Locked_Stats"]:
+                self._locked_freezy = float(config["Locked_Stats"]["freezy"])
+            if "hot" in config["Locked_Stats"]:
+                self._locked_hot = float(config["Locked_Stats"]["hot"])
+            if "lonely" in config["Locked_Stats"]:
+                self._locked_lonely = float(config["Locked_Stats"]["lonely"])
+            if "humanity" in config["Locked_Stats"]:
+                self._locked_humanity = float(config["Locked_Stats"]["humanity"])
+            if "soziality" in config["Locked_Stats"]:
+                self._locked_soziality = float(config["Locked_Stats"]["soziality"])
+            
+
+    
+
+    @property
+    def angry(self) -> float:
+        if self._locked_angry >= 0:
+            return self._locked_angry
+        return self._angry
+
+    @angry.setter
+    def angry(self, value:float):
+        if value<0:
+            self._aroused = 0
+        elif value > self.MAX_VALUE:
+            self._aroused = self.MAX_VALUE
+        else:
+            self._aroused = value
+        if value > 0:
+            self._lastTimeAngry = time.time()
+
+    @property
+    def aroused(self) -> float:
+        if self._locked_aroused >= 0:
+            return self._locked_aroused
+        return self._aroused
+
+    @aroused.setter
+    def aroused(self, value:float):
+        if value<0:
+            self._aroused = 0
+        elif value > self.MAX_VALUE:
+            self._aroused = self.MAX_VALUE
+        else:
+            self._aroused = value
+
+    @property
+    def hungry(self) -> float:
+        if self._locked_hungry >= 0:
+            return self._locked_hungry
+        return self._hungry
+
+    @hungry.setter
+    def hungry(self, value:float):
+        if value<0:
+            self._hungry = 0
+        elif value > self.MAX_VALUE:
+            self._hungry = self.MAX_VALUE
+        else:
+            self._hungry = value
+
+    @property
+    def happyness(self) -> float:
+        if self._locked_happyness >= 0:
+            return self._locked_happyness
+        return self._happyness
+
+    @happyness.setter
+    def happyness(self, value:float):
+        if value<0:
+            self._happyness = 0
+        elif value > self.MAX_VALUE:
+            self._happyness = self.MAX_VALUE
+        else:
+            self._happyness = value
+
+    @property
+    def funny(self) -> float:
+        if self._locked_funny >= 0:
+            return self._locked_funny
+        return self._funny
+
+    @funny.setter
+    def funny(self, value:float):
+        if value<0:
+            self._funny = 0
+        elif value > self.MAX_VALUE:
+            self._funny = self.MAX_VALUE
+        else:
+            self._funny = value
+
+    @property
+    def annoyed(self) -> float:
+        if self._locked_annoyed >= 0:
+            return self._locked_annoyed
+        return self._annoyed
+
+    @annoyed.setter
+    def annoyed(self, value:float):
+        if value<0:
+            self._annoyed = 0
+        elif value > self.MAX_VALUE:
+            self._annoyed = self.MAX_VALUE
+        else:
+            self._annoyed = value
+
+    @property
+    def irritated(self) -> float:
+        if self._locked_irritated >= 0:
+            return self._locked_irritated
+        return self._irritated
+
+    @irritated.setter
+    def irritated(self, value:float):
+        if value<0:
+            self._irritated = 0
+        elif value > self.MAX_VALUE:
+            self._irritated = self.MAX_VALUE
+        else:
+            self._irritated = value
+
+    @property
+    def bored(self) -> float:
+        if self._locked_bored >= 0:
+            return self._locked_bored
+        return self._bored
+
+    @bored.setter
+    def bored(self, value:float):
+        if value<0:
+            self._bored = 0
+        elif value > self.MAX_VALUE:
+            self._bored = self.MAX_VALUE
+        else:
+            self._bored = value
+
+    @property
+    def intelligent(self) -> float:
+        if self._locked_intelligent >= 0:
+            return self._locked_intelligent
+        return self._intelligent
+
+    @intelligent.setter
+    def intelligent(self, value:float):
+        if value<0:
+            self._intelligent = 0
+        elif value > self.MAX_VALUE:
+            self._intelligent = self.MAX_VALUE
+        else:
+            self._intelligent = value
+
+    @property
+    def sleepy(self) -> float:
+        if self._locked_sleepy >= 0:
+            return self._locked_sleepy
+        return self._sleepy
+
+    @sleepy.setter
+    def sleepy(self, value:float):
+        if value<0:
+            self._sleepy = 0
+        elif value > self.MAX_VALUE:
+            self._sleepy = self.MAX_VALUE
+        else:
+            self._sleepy = value
+
+    @property
+    def energy(self) -> float:
+        if self._locked_energy >= 0:
+            return self._locked_energy
+        return self._energy
+
+    @energy.setter
+    def energy(self, value:float):
+        if value<0:
+            self._energy = 0
+        elif value > self.MAX_VALUE:
+            self._energy = self.MAX_VALUE
+        else:
+            self._energy = value
+
+    @property
+    def exhausted(self) -> float:
+        if self._locked_exhausted >= 0:
+            return self._locked_exhausted
+        return self._exhausted
+
+    @exhausted.setter
+    def exhausted(self, value:float):
+        if value<0:
+            self._exhausted = 0
+        elif value > self.MAX_VALUE:
+            self._exhausted = self.MAX_VALUE
+        else:
+            self._exhausted = value
+
+    @property
+    def depressive(self) -> float:
+        if self._locked_depressive >= 0:
+            return self._locked_depressive
+        return self._depressive
+
+    @depressive.setter
+    def depressive(self, value:float):
+        if value<0:
+            self._depressive = 0
+        elif value > self.MAX_VALUE:
+            self._depressive = self.MAX_VALUE
+        else:
+            self._depressive = value
+
+    @property
+    def sad(self) -> float:
+        if self._locked_sad >= 0:
+            return self._locked_sad
+        return self._sad
+
+    @sad.setter
+    def sad(self, value:float):
+        if value<0:
+            self._sad = 0
+        elif value > self.MAX_VALUE:
+            self._sad = self.MAX_VALUE
+        else:
+            self._sad = value
+
+    @property
+    def useless(self) -> float:
+        if self._locked_useless >= 0:
+            return self._locked_useless
+        return self._useless
+
+    @useless.setter
+    def useless(self, value):
+        if value<0:
+            self._useless = 0
+        elif value > self.MAX_VALUE:
+            self._useless = self.MAX_VALUE
+        else:
+            self._useless = value
+
+    @property
+    def usefull(self) -> float:
+        if self._locked_usefull >= 0:
+            return self._locked_usefull
+        return self._usefull
+
+    @usefull.setter
+    def usefull(self, value:float):
+        if value<0:
+            self._usefull = 0
+        elif value > self.MAX_VALUE:
+            self._usefull = self.MAX_VALUE
+        else:
+            self._usefull = value
+
+    @property
+    def compfortable(self) -> float:
+        if self._locked_compfortable >= 0:
+            return self._locked_compfortable
+        return self._compfortable
+
+    @compfortable.setter
+    def compfortable(self, value:float):
+        if value<0:
+            self._compfortable = 0
+        elif value > self.MAX_VALUE:
+            self._compfortable = self.MAX_VALUE
+        else:
+            self._compfortable = value
+
+    @property
+    def temperate(self) -> float:
+        if self._locked_temperate >= 0:
+            return self._locked_temperate
+        return self._temperate
+
+    @temperate.setter
+    def temperate(self, value:float):
+        if value<0:
+            self._temperate = 0
+        elif value > self.MAX_VALUE:
+            self._temperate = self.MAX_VALUE
+        else:
+            self._temperate = value
+
+    @property
+    def shy(self) -> float:
+        if self._locked_shy >= 0:
+            return self._locked_shy
+        return self._shy
+
+    @shy.setter
+    def shy(self, value:float):
+        if value<0:
+            self._shy = 0
+        elif value > self.MAX_VALUE:
+            self._shy = self.MAX_VALUE
+        else:
+            self._shy = value
+
+    @property
+    def excited(self) -> float:
+        if self._locked_excited >= 0:
+            return self._locked_excited
+        return self._excited
+
+    @excited.setter
+    def excited(self, value:float):
+        if value<0:
+            self._excited = 0
+        elif value > self.MAX_VALUE:
+            self._excited = self.MAX_VALUE
+        else:
+            self._excited = value
+
+    @property
+    def toLoud(self) -> float:
+        if self._locked_toLoud >= 0:
+            return self._locked_toLoud
+        return self._toLoud
+
+    @toLoud.setter
+    def toLoud(self, value:float):
+        if value<0:
+            self._toLoud = 0
+        elif value > self.MAX_VALUE:
+            self._toLoud = self.MAX_VALUE
+        else:
+            self._toLoud = value
+        if value > 0:
+            lastTimeToLoud = time.time()
+
+    @property
+    def toQuiet(self) -> float:
+        if self._locked_toQuiet >= 0:
+            return self._locked_toQuiet
+        return self._toQuiet
+
+    @toQuiet.setter
+    def toQuiet(self, value:float):
+        if value<0:
+            self._toQuiet = 0
+        elif value > self.MAX_VALUE:
+            self._toQuiet = self.MAX_VALUE
+        else:
+            self._toQuiet = value
+        if value > 0:
+            lastTimeToQuiet = time.time()
+            
+    @property
+    def playful(self) -> float:
+        if self._locked_playful >= 0:
+            return self._locked_playful
+        return self._playful
+
+    @playful.setter
+    def playful(self, value:float):
+        if value<0:
+            self._playful = 0
+        elif value > self.MAX_VALUE:
+            self._playful = self.MAX_VALUE
+        else:
+            self._playful = value
+
+    @property
+    def naiv(self) -> float:
+        if self._locked_naiv >= 0:
+            return self._locked_naiv
+        return self._naiv
+
+    @naiv.setter
+    def naiv(self, value:float):
+        if value<0:
+            self._naiv = 0
+        elif value > self.MAX_VALUE:
+            self._naiv = self.MAX_VALUE
+        else:
+            self._naiv = value
+
+    @property
+    def freezy(self) -> float:
+        if self._locked_freezy >= 0:
+            return self._locked_freezy
+        return self._freezy
+
+    @freezy.setter
+    def freezy(self, value:float):
+        if value<0:
+            self._freezy = 0
+        elif value > self.MAX_VALUE:
+            self._freezy = self.MAX_VALUE
+        else:
+            self._freezy = value
+
+    @property
+    def hot(self) -> float:
+        if self._locked_hot >= 0:
+            return self._locked_hot
+        return self._hot
+
+    @hot.setter
+    def hot(self, value:float):
+        if value<0:
+            self._hot = 0
+        elif value > self.MAX_VALUE:
+            self._hot = self.MAX_VALUE
+        else:
+            self._hot = value
+
+    @property
+    def humanity(self) -> float:
+        if self._locked_humanity >= 0:
+            return self._locked_humanity
+        return self._humanity
+
+    @humanity.setter
+    def humanity(self, value:float):
+        if value<0:
+            self._humanity = 0
+        elif value > self.MAX_VALUE:
+            self._humanity = self.MAX_VALUE
+        else:
+            self._humanity = value
+
+    @property
+    def lonely(self) -> float:
+        if self._locked_lonely >= 0:
+            return self._locked_lonely
+        return self._lonely
+
+    @lonely.setter
+    def lonely(self, value:float):
+        if value<0:
+            self._lonely = 0
+        elif value > self.MAX_VALUE:
+            self._lonely = self.MAX_VALUE
+        else:
+            self._lonely = value
+        if value > 0:
+            self._lastTimeLonely = time.time()
+
+    @property
+    def soziality(self) -> float:
+        if self._locked_soziality >= 0:
+            return self._locked_soziality
+        return self._soziality
+
+    @soziality.setter
+    def soziality(self, value:float):
+        if value<0:
+            self._soziality = 0
+        elif value > self.MAX_VALUE:
+            self._soziality = self.MAX_VALUE
+        else:
+            self._soziality = value
+
+
+    @property
+    def lastTimeToQuiet(self):
+        return self._lastTimeToQuiet
+
+    @property
+    def lastTimeToLoud(self):
+        return self._lastTimeToLoud
+
+    @property
+    def lastTimeAngry(self):
+        return self._lastTimeAngry
+
+    @property
+    def lastTimeLonely(self):
+        return self._lastTimeLonely
+
+
+    def set(self, name:str, val:float) -> bool:
+        n = name.lower()
+        if n=="angry": self.angry = val
+        elif n=="aroused": self.aroused = val
+        elif n=="hungry": self.hungry = val
+        elif n=="happyness": self.happyness = val
+        elif n=="funny": self.funny = val
+        elif n=="annoyed": self.annoyed = val
+        elif n=="irritated": self.irritated = val
+        elif n=="bored": self.bored = val
+        elif n=="intelligent": self.intelligent = val
+        elif n=="sleepy": self.sleepy = val
+        elif n=="energy": self.energy = val
+        elif n=="exhausted": self.exhausted = val
+        elif n=="depressive": self.depressive = val
+        elif n=="sad": self.sad = val
+        elif n=="useless": self.useless = val
+        elif n=="usefull": self.usefull = val
+        elif n=="compfortable": self.compfortable = val
+        elif n=="temperate": self.temperate = val
+        elif n=="shy": self.shy = val
+        elif n=="excited": self.excited = val
+        elif n=="toLoud": self.toLoud = val
+        elif n=="toQuiet": self.toQuiet = val
+        elif n=="playful": self.playful = val
+        elif n=="naiv": self.naiv = val
+        elif n=="freezy": self.freezy = val
+        elif n=="hot": self.hot = val
+        elif n=="humanity": self.humanity = val
+        elif n=="lonely": self.lonely = val
+        elif n=="soziality": self.soziality = val
+        else: return False
+        return True
+
+    def get(self, name:str) -> float:
+        n = name.lower()
+        if n=="angry": return self.angry
+        elif n=="aroused": return self.aroused
+        elif n=="hungry": return self.hungry
+        elif n=="happyness": return self.happyness
+        elif n=="funny": return self.funny
+        elif n=="annoyed": return self.annoyed
+        elif n=="irritated": return self.irritated
+        elif n=="bored": return self.bored
+        elif n=="intelligent": return self.intelligent
+        elif n=="sleepy": return self.sleepy
+        elif n=="energy": return self.energy
+        elif n=="exhausted": return self.exhausted
+        elif n=="depressive": return self.depressive
+        elif n=="sad": return self.sad
+        elif n=="useless": return self.useless
+        elif n=="usefull": return self.usefull
+        elif n=="compfortable": return self.compfortable
+        elif n=="temperate": return self.temperate
+        elif n=="shy": return self.shy
+        elif n=="excited": return self.excited
+        elif n=="toLoud": return self.toLoud
+        elif n=="toQuiet": return self.toQuiet
+        elif n=="playful": return self.playful
+        elif n=="naiv": return self.naiv
+        elif n=="freezy": return self.freezy
+        elif n=="hot": return self.hot
+        elif n=="humanity": return self.humanity
+        elif n=="lonely": return self.lonely
+        elif n=="soziality": return self.soziality
+        else: return -1.0
+
+
+    def Save(self):
+        self.textconfig.setValue({
+            "max": self.MAX_VALUE,
+            "angry": self._angry,
+            "aroused": self.aroused,
+            "hungry": self.hungry,
+            "happyness": self._happyness,
+            "funny": self._funny,
+            "annoyed":self._annoyed,
+            "irritated": self.irritated,
+            "bored": self.bored,
+            "intelligent": self.intelligent,
+            "sleepy": self.sleepy,
+            "energy": self.energy,
+            "exhausted": self.exhausted,
+            "depressive": self.depressive,
+            "sad": self.sad,
+            "useless": self.useless,
+            "usefull": self.usefull,
+            "compfortable": self.compfortable,
+            "temperate": self.temperate,
+            "shy": self.shy,
+            "excited": self.excited,
+            "toLoud": self.toLoud,
+            "toQuiet": self.toQuiet,
+            "playful": self.playful,
+            "naiv": self.naiv,
+            "freezy": self.freezy,
+            "hot": self.hot,
+            "humanity": self.humanity,
+            "lonely": self.lonely,
+            "soziality": self.soziality,
+            "lastTimeToLoud": self.lastTimeToLoud,
+            "lastTimeToQuiet": self.lastTimeToQuiet,
+            "lastTimeAngry": self.lastTimeAngry,
+            "lastTimeLonely": self.lastTimeLonely,
+            "lastUpdate": self.lastUpdate
+        })
+        self.textconfig.Save()
+
+    def Save(self, file = "stats.txt"):
+        if os.path.isfile(file):
+            os.remove(file)
+        with open(file, 'w') as f:
+            f.writelines([
+                "max "+str(self.MAX_VALUE)+"\n",
+                "angry "+str(self.angry)+"\n",
+                "aroused "+str(self.aroused)+"\n",
+                "hungry "+str(self.hungry)+"\n",
+                "happyness "+str(self.happyness)+"\n",
+                "funny "+str(self.funny)+"\n",
+                "annoyed "+str(self.annoyed)+"\n",
+                "irritated "+str(self.irritated)+"\n",
+                "bored "+str(self.bored)+"\n",
+                "intelligent "+str(self.intelligent)+"\n",
+                "sleepy "+str(self.sleepy)+"\n",
+                "energy "+str(self.energy)+"\n",
+                "exhausted "+str(self.exhausted)+"\n",
+                "depressive "+str(self.depressive)+"\n",
+                "sad "+str(self.sad)+"\n",
+                "useless "+str(self.useless)+"\n",
+                "usefull "+str(self.usefull)+"\n",
+                "compfortable "+str(self.compfortable)+"\n",
+                "temperate "+str(self.temperate)+"\n",
+                "shy "+str(self.shy)+"\n",
+                "excited "+str(self.excited)+"\n",
+                "toLoud "+str(self.toLoud)+"\n",
+                "toQuiet "+str(self.toQuiet)+"\n",
+                "playful "+str(self.playful)+"\n",
+                "naiv "+str(self.naiv)+"\n",
+                "freezy "+str(self.freezy)+"\n",
+                "hot "+str(self.hot)+"\n",
+                "humanity "+str(self.humanity)+"\n",
+                "lonely "+str(self.lonely)+"\n",
+                "soziality "+str(self.soziality)+"\n",
+                "\n",
+                "lastTimeToLoud "+str(self.lastTimeToLoud)+"\n",
+                "lastTimeToQuiet "+str(self.lastTimeToQuiet)+"\n",
+                "lastTimeAngry "+str(self.lastTimeAngry)+"\n",
+                "lastTimeLonely "+str(self.lastTimeLonely)+"\n",
+                "lastUpdate "+str(self.lastUpdate)+"\n"
+            ])
+
+    def Load(self, file = "stats.txt"):
+        if os.path.isfile(file) == False:
+            return False
+        #lines=[]
+        count=0
+        max = self.MAX_VALUE
+        
+        #lines = self._loadTextConfig("stats.txt")
+        self.textconfig.Load()
+        lines = self.textconfig.getItems()
+        count = self.textconfig.count
+
+        if count>0:
+            for c in range(0, count):
+                itm = lines[c]
+                if itm["var"]=="angry": self.angry = float(itm["val"]) / max * self.MAX_VALUE
+                elif itm["var"]=="aroused": self.aroused = float(itm["val"]) / max * self.MAX_VALUE
+                elif itm["var"]=="hungry": self.hungry = float(itm["val"]) / max * self.MAX_VALUE
+                elif itm["var"]=="happyness": self.happyness = float(itm["val"]) / max * self.MAX_VALUE
+                elif itm["var"]=="funny": self.funny = float(itm["val"]) / max * self.MAX_VALUE
+                elif itm["var"]=="annoyed": self.annoyed = float(itm["val"]) / max * self.MAX_VALUE
+                elif itm["var"]=="irritated": self.irritated = float(itm["val"]) / max * self.MAX_VALUE
+                elif itm["var"]=="bored": self.bored = float(itm["val"]) / max * self.MAX_VALUE
+                elif itm["var"]=="intelligent": self.intelligent = float(itm["val"]) / max * self.MAX_VALUE
+                elif itm["var"]=="sleepy": self.sleepy = float(itm["val"]) / max * self.MAX_VALUE
+                elif itm["var"]=="energy": self.energy = float(itm["val"]) / max * self.MAX_VALUE
+                elif itm["var"]=="exhausted": self.exhausted = float(itm["val"]) / max * self.MAX_VALUE
+                elif itm["var"]=="depressive": self.depressive = float(itm["val"]) / max * self.MAX_VALUE
+                elif itm["var"]=="sad": self.sad = float(itm["val"]) / max * self.MAX_VALUE
+                elif itm["var"]=="useless": self.useless = float(itm["val"]) / max * self.MAX_VALUE
+                elif itm["var"]=="usefull": self.usefull = float(itm["val"]) / max * self.MAX_VALUE
+                elif itm["var"]=="compfortable": self.compfortable = float(itm["val"]) / max * self.MAX_VALUE
+                elif itm["var"]=="temperate": self.temperate = float(itm["val"]) / max * self.MAX_VALUE
+                elif itm["var"]=="shy": self.shy = float(itm["val"]) / max * self.MAX_VALUE
+                elif itm["var"]=="excited": self.excited = float(itm["val"]) / max * self.MAX_VALUE
+                elif itm["var"]=="toLoud": self.toLoud = float(itm["val"]) / max * self.MAX_VALUE
+                elif itm["var"]=="toQuiet": self.toQuiet = float(itm["val"]) / max * self.MAX_VALUE
+                elif itm["var"]=="playful": self.playful = float(itm["val"]) / max * self.MAX_VALUE
+                elif itm["var"]=="naiv": self.naiv = float(itm["val"]) / max * self.MAX_VALUE
+                elif itm["var"]=="freezy": self.freezy = float(itm["val"]) / max * self.MAX_VALUE
+                elif itm["var"]=="hot": self.hot = float(itm["val"]) / max * self.MAX_VALUE
+                elif itm["var"]=="humanity": self.humanity = float(itm["val"]) / max * self.MAX_VALUE
+                elif itm["var"]=="lonely": self.lonely = float(itm["val"]) / max * self.MAX_VALUE
+                elif itm["var"]=="soziality": self.soziality = float(itm["val"]) / max * self.MAX_VALUE
+                elif itm["var"]=="lastTimeToLoud": self._lastTimeToLoud = float(itm["val"]) / max * self.MAX_VALUE
+                elif itm["var"]=="lastTimeToQuiet": self._lastTimeToQuiet = float(itm["val"]) / max * self.MAX_VALUE
+                elif itm["var"]=="lastTimeAngry": self._lastTimeAngry = float(itm["val"]) / max * self.MAX_VALUE
+                elif itm["var"]=="lastTimeLonely": self._lastTimeLonely = float(itm["val"]) / max * self.MAX_VALUE
+            self.lastUpdate = time.time
+            return True
+        return False
+
+
+
+    def __del__(self):
+        print("Del DeviceStats")
+        self.Thread_Save.cancel()
+        del self._angry
+        del self._annoyed
+        del self._aroused
+        del self._bored
+        del self._compfortable
+        del self._depressive
+        del self._energy
+        del self._excited
+        del self._exhausted
+        del self._freezy
+        del self._funny
+        del self._happyness
+        del self._hot
+        del self._humanity
+        del self._hungry
+        del self._intelligent
+        del self._irritated
+        del self._lastTimeToLoud
+        del self._lastTimeToQuiet
+        del self._lonely
+        del self._naiv
+        del self._playful
+        del self._sad
+        del self._shy
+        del self._sleepy
+        del self._soziality
+        del self._temperate
+        del self._toLoud
+        del self._toQuiet
+        del self._usefull
+        del self._useless
+
+        del self._locked_angry
+        del self._locked_annoyed
+        del self._locked_aroused
+        del self._locked_bored
+        del self._locked_compfortable
+        del self._locked_depressive
+        del self._locked_energy
+        del self._locked_excited
+        del self._locked_exhausted
+        del self._locked_freezy
+        del self._locked_funny
+        del self._locked_happyness
+        del self._locked_hot
+        del self._locked_humanity
+        del self._locked_hungry
+        del self._locked_intelligent
+        del self._locked_irritated
+        del self._locked_lastTimeToLoud
+        del self._locked_lastTimeToQuiet
+        del self._locked_lonely
+        del self._locked_naiv
+        del self._locked_playful
+        del self._locked_sad
+        del self._locked_shy
+        del self._locked_sleepy
+        del self._locked_soziality
+        del self._locked_temperate
+        del self._locked_toLoud
+        del self._locked_toQuiet
+        del self._locked_usefull
+        del self._locked_useless
+
+        del self.Thread_Save
+
+
+    def getJson(self):
+        return {
+            "angry": self.angry,
+            "aroused": self.aroused,
+            "hungry": self.hungry,
+            "happyness": self.happyness,
+            "funny": self.funny,
+            "annoyed": self.annoyed,
+            "irritated": self.irritated,
+            "bored": self.bored,
+            "intelligent": self.intelligent,
+            "sleepy": self.sleepy,
+            "energy": self.energy,
+            "exhausted": self.exhausted,
+            "depressive": self.depressive,
+            "sad": self.sad,
+            "useless": self.useless,
+            "usefull": self.usefull,
+            "compfortable": self.compfortable,
+            "temperate": self.temperate,
+            "shy": self.shy,
+            "excited": self.excited,
+            "toLoud": self.toLoud,
+            "toQuiet": self.toQuiet,
+            "playful": self.playful,
+            "naiv": self.naiv,
+            "freezy": self.freezy,
+            "hot": self.hot,
+            "humanity": self.humanity,
+            "lonely": self.lonely,
+            "soziality": self.soziality,
+            
+            "lastTimeToLoud":self.lastTimeToLoud,
+            "lastTimeToQuiet":self.lastTimeToQuiet,
+            "lastTimeAngry":self.lastTimeAngry,
+            "lastTimeLonely":self.lastTimeLonely,
+            "lastUpdate":self.lastUpdate
+        }

+ 49 - 0
Stats/HouseStats.py

@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+class HouseStats(object):
+    temp_avg = 20.0
+    temp_coldest = 99.0
+    temp_hottest = 0.0
+
+    bAllWindowOpen = False
+    bAllWindowClosed = False
+    bAllDoorOpen = False
+    bAllDoorClosed = False
+    bAllLightOn = False
+    bAllLightOff = False
+    bAtHome = False
+    bSleeping = False
+
+    timeWindowWasOpen = 0
+    timeWindowWasClosed = 0
+
+    timeDoorWasOpen = 0
+    timeDoorWasClosed = 0
+
+    def getJson(self):
+        return {
+            "temp": {
+                "avg": self.temp_avg,
+                "coldest": self.temp_coldest,
+                "hottest": self.temp_hottest
+            },
+            "Windows": {
+                "All_Closed": self.bAllWindowClosed,
+                "All_Opened": self.bAllWindowOpen,
+                "LastOpenTime": self.timeWindowWasOpen,
+                "LastClosedTime": self.timeWindowWasClosed
+            },
+            "Doors": {
+                "All_Closed": self.bAllDoorClosed,
+                "All_Opened": self.bAllDoorOpen,
+                "LastOpenTime": self.timeDoorWasOpen,
+                "LastClosedTime": self.timeDoorWasClosed
+            },
+            "Lights": {
+                "All_On": self.bAllLightOn,
+                "All_Off": self.bAllLightOff
+            },
+            "OwnerAtHome": self.bAtHome,
+            "OwnerSleeping": self.bSleeping
+        }

+ 52 - 0
Stats/MicLevel.py

@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+class MicLevel(object):
+    SamplesRead = 0
+    Length = 0.0
+    ScaleBy = 0.0
+    Ampitude_Max = 0.0
+    Ampitude_Min = 0.0
+    Ampitude_Avg = 0.0
+    Ampitude_Norm = 0.0
+    Ampitude_RMS = 0.0
+    Norm_Mean = 0.0
+    Delta_Max = 0.0
+    Delta_Min = 0.0
+    Delta_Mean = 0.0
+    Delta_RMS = 0.0
+
+    Frequency_Rough = 0.0
+    Volume_Adjustment = 0.0
+
+    Volume_Min = 0.0
+    Volume_Max = 0.0
+    Volume_Avg = 0.0
+
+    def getJson(self):
+        return {
+            "SamplesRead": self.SamplesRead,
+            "Length": self.Length,
+            "ScaleBy": self.ScaleBy,
+            "Ampitude": {
+                "Max": self.Ampitude_Max,
+                "Min": self.Ampitude_Min,
+                "Avg": self.Ampitude_Avg,
+                "Norm": self.Ampitude_Norm,
+                "RMS": self.Ampitude_RMS
+            },
+            "Norm_Mean": self.Norm_Mean,
+            "Delta": {
+                "Max": self.Delta_Max,
+                "Min": self.Delta_Min,
+                "Mean": self.Delta_Mean,
+                "RMS": self.Delta_RMS
+            },
+            "Frequency_Rough": self.Frequency_Rough,
+            "Volume_Adjustment": self.Volume_Adjustment,
+            "Volume": {
+                "Min": self.Volume_Min,
+                "Max": self.Volume_Max,
+                "Avg": self.Volume_Avg
+            }
+        }

+ 26 - 0
Stats/OutdoorStats.py

@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+class OutdoorStats(object):
+    Temperature = 20.0
+    bWindy = False
+    Pressure = 0.0
+    Humidity = 0.0
+    WindSpeed = 0.0
+    WindDegree = 0
+    Clouds = 0.0
+    bRaining = False
+    bSnowing = False
+
+    def getJson(self):
+        return {
+            "Temperature": self.Temperature,
+            "bWindy": self.bWindy,
+            "Pressure": self.Pressure,
+            "Humidity": self.Humidity,
+            "WindSpeed": self.WindSpeed,
+            "WindDegree": self.WindDegree,
+            "Clouds": self.Clouds,
+            "bRaining": self.bRaining,
+            "bSnowing": self.bSnowing
+        }

+ 25 - 0
Stats/OwnerStats.py

@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+import configparser
+
+class OwnerStats(object):
+    bIsAtHome = False
+    bIsSick = False
+    bHasHollidays = False
+    bKrankgeschrieben = False
+    bSleeping = False
+    bIsSad = False
+    bCanStayAtHomeTomorrow = False
+
+    Calender = []
+
+    def getJson(self):
+        return {
+            "bIsAtHome": self.bIsAtHome,
+            "bIsSick": self.bIsSick,
+            "bHasHollidays": self.bHasHollidays,
+            "bKrankgeschrieben": self.bKrankgeschrieben,
+            "bSleeping": self.bSleeping,
+            "bIsSad": self.bIsSad,
+            "bCanStayAtHomeTomorrow": self.bCanStayAtHomeTomorrow
+        }

+ 24 - 0
Stats/TalkingStats.py

@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+class TalkingStats(object):
+    bTalk = 0.0
+    bAnswerQuestions = 0.0
+    bTalkAfterOrder = 0.0
+    bRandomHappy = 0.0
+    bRandomPlay = 0.0
+    bRandomAngry = 0.0
+    bRandomGramp = 0.0
+    bRandomCompliment = 0.0
+
+    def getJson(self):
+        return {
+            "bTalk": self.bTalk,
+            "bAnswerQuestions": self.bAnswerQuestions,
+            "bTalkAfterOrder": self.bTalkAfterOrder,
+            "bRandomHappy": self.bRandomHappy,
+            "bRandomPlay": self.bRandomPlay,
+            "bRandomAngry": self.bRandomAngry,
+            "bRandomGramp": self.bRandomGramp,
+            "bRandomCompliment": self.bRandomCompliment
+        }

+ 424 - 0
Stats/__init__.py

@@ -0,0 +1,424 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from Stats.DeviceStats import DeviceStats as _DeviceStats
+from Stats.HouseStats import HouseStats as _HouseStats
+from Stats.MicLevel import MicLevel as _MicLevel
+from Stats.OutdoorStats import OutdoorStats as _OutdoorStats
+from Stats.OwnerStats import OwnerStats as _OwnerStats
+from Stats.TalkingStats import TalkingStats as _TalkingStats
+from Stats.AdminStats import AdminStats as _AdminStats
+
+import MicCapture
+import OpenWeatherMap
+from Homematic import Homematic
+from threading import Timer
+import time
+import datetime
+import configparser
+from RepeatTimer import RepeatTimer
+import lib.MoonPhase as mp
+import random
+
+class Stats(object):
+
+    instance = None
+    @staticmethod
+    def getInstance():
+        if Stats.instance==None:
+            Stats.instance = Stats()
+        return Stats.instance
+
+    deviceStats = _DeviceStats()
+    houseStats = _HouseStats()
+    micLevel = _MicLevel()
+    outdoorStats = _OutdoorStats()
+    ownerStats = _OwnerStats()
+    talkingStats = _TalkingStats()
+    adminStats = _AdminStats()
+
+    weather = OpenWeatherMap.OpenWeatherMap()
+
+
+    UPDATE_EMOTION_DELAY_MINUTE = 1.66
+    UPDATE_HOMEMATIC_DELAY_MINUTE = 1
+    UPDATE_DATETIME_DELAY_MINUTE = 10
+    UPDATE_OUTDOOR_DELAY_MINUTE = 2.1
+    UPDATE_MIC_DELAY_MINUTE = 0.5
+
+    Thread_Homematic = None
+    Thread_Emotion = None
+    Thread_DateTime = None
+    Thread_OutDoor = None
+    Thread_Mic = None
+    lastUpdate = 0.0
+    homematic = None
+
+    moonPhase = None
+    Mic = MicCapture.MicCapture()
+
+    def __init__(self):
+        print("Init Stats")
+
+        print("- Read Config")
+        try:
+            config = configparser.ConfigParser()
+            config.read('config.ini')
+        except:
+            print("Failed to get Config")
+            config = dict
+            config["Homematic"] = dict
+            config["Homematic"]["url"]=""
+            config["Homematic"]["SwitchList"]=""
+            config["Homematic"]["LightList"]=""
+            config["Homematic"]["TermoList"]=""
+            config["Homematic"]["DoorList"]=""
+            config["Homematic"]["WindowList"]=""
+
+        self.moonPhase = mp.phase(time=datetime.datetime.now())
+
+        self.deviceStats.lastUpdate = time.time()
+
+        print("- Init Homematic")
+        if config["Homematic"]["url"]!="":
+            self.homematic = Homematic(config["Homematic"]["url"], {
+                "SwitchList":config["Homematic"]["SwitchList"],
+                "LightList":config["Homematic"]["LightList"],
+                "TermoList":config["Homematic"]["TermoList"],
+                "DoorList":config["Homematic"]["DoorList"],
+                "WindowList":config["Homematic"]["WindowList"]
+            })
+
+            if self.homematic.bConnected:
+                print("- - Homematic conected")
+                print("- - Update HomeMatic")
+                self.__UpdateHomematic()
+                print("- - Start Homematic-Timer")
+                self.Thread_Homematic = RepeatTimer(self.UPDATE_HOMEMATIC_DELAY_MINUTE*60, self.__UpdateHomematic)
+                self.Thread_Homematic.start()
+            else:
+                print("- - No homatic")
+            print("- - HomeMatic Done")
+        else:
+            print("- - Homematic failed")
+
+        self.__UpdateDateTime()
+        self.Thread_DateTime = RepeatTimer(self.UPDATE_DATETIME_DELAY_MINUTE*60, self.__UpdateDateTime)
+        self.Thread_DateTime.start()
+
+        self.__UpdateOutdoor()
+        self.Thread_OutDoor = RepeatTimer(self.UPDATE_OUTDOOR_DELAY_MINUTE*60, self.__UpdateOutdoor)
+        self.Thread_OutDoor.start()
+
+        self.Thread_Mic = RepeatTimer(self.UPDATE_MIC_DELAY_MINUTE*60, self.__UpdateMic)
+        self.Thread_Mic.start()
+        
+        print("- Init Emotion")
+        self.Thread_Emotion = RepeatTimer(self.UPDATE_EMOTION_DELAY_MINUTE*60, self.__UpdateEmotion)
+        print("- - Start Emotion Timer")
+        self.Thread_Emotion.start()
+
+        print("- - Init Stats done")
+        return super().__init__()
+
+    def __UpdateMic(self):
+        self.Mic.Update()
+        self.micLevel.Volume_Min = self.Mic.LastResult["min"]
+        self.micLevel.Volume_Max = self.Mic.LastResult["max"]
+        self.micLevel.Volume_Avg = self.Mic.LastResult["avg"]
+        print(self.micLevel.getJson())
+
+    def __UpdateDateTime(self):
+        self.moonPhase = mp.phase(time=datetime.datetime.now())
+
+    def __UpdateOutdoor(self):
+        self.weather.Update()
+        self.outdoorStats.bRaining = self.weather.CurrentLocation.Rain.PerHour>0.1
+        self.outdoorStats.bSnowing = self.weather.CurrentLocation.Rain.PerHour>0.1 and self.weather.CurrentLocation.Main.TempMax<1
+        self.outdoorStats.bWindy = self.weather.CurrentLocation.Wind.Speed>20
+        self.outdoorStats.Clouds = self.weather.CurrentLocation.Clouds.All
+        self.outdoorStats.Humidity = self.weather.CurrentLocation.Main.Humidity
+        self.outdoorStats.Pressure = self.weather.CurrentLocation.Main.Pressure
+        self.outdoorStats.Temperature = self.weather.CurrentLocation.Main.Temperature
+        self.outdoorStats.WindDegree = self.weather.CurrentLocation.Wind.Deg
+        self.outdoorStats.WindSpeed = self.weather.CurrentLocation.Wind.Speed
+
+    def __UpdateHomematic(self):
+        print("Update Homematic")
+        self.homematic.updateDevices()
+        # Check open/closed windows
+        self.houseStats.bAllWindowOpen = True
+        self.houseStats.bAllWindowClosed = True
+        for ise in self.homematic.favWindowList:
+            if self.homematic.windowList[ise]["value"]==False:
+                self.houseStats.bAllWindowOpen = False
+            else:
+                self.houseStats.bAllWindowClosed = False
+        # Check open/closed doors
+        self.houseStats.bAllDoorOpen = True
+        self.houseStats.bAllDoorClosed = True
+        for ise in self.homematic.favDoorList:
+            if self.homematic.doorList[ise]["value"]==False:
+                self.houseStats.bAllDoorOpen = False
+            else:
+                self.houseStats.bAllDoorClosed = False
+        # Check all Lights
+        self.houseStats.bAllLightOn = True
+        self.houseStats.bAllLightOff = True
+        for ise in self.homematic.favLightList:
+            if self.homematic.lightList[ise]["value"]==False:
+                self.houseStats.bAllLightOn = False
+            else:
+                self.houseStats.bAllLightOff = False
+        # Termo
+        temp_min=40.0
+        temp_max=0.0
+        temp_avg_add=0.0
+        temp_avg_count=0
+        for ise in self.homematic.favThermoList:
+            if self.homematic.thermoList[ise]["value"] > temp_max:
+                temp_max = self.homematic.thermoList[ise]["value"]
+            if self.homematic.thermoList[ise]["value"] < temp_min:
+                temp_min = self.homematic.thermoList[ise]["value"]
+            temp_avg_add += self.homematic.thermoList[ise]["value"]
+            temp_avg_count += 1
+        self.houseStats.temp_avg = temp_avg_add / temp_avg_count
+        self.houseStats.temp_coldest = temp_min
+        self.houseStats.temp_hottest = temp_max
+
+    def __UpdateEmotion(self):
+        print("Update Emotion")
+        newTime = int(time.time())
+        updateDur = float(self.deviceStats.MAX_VALUE * ((newTime - self.deviceStats.lastUpdate) / 3600)) # Per Thausend
+        self.deviceStats.lastUpdate = newTime
+        #curHour = ((newTime % 86400) / 3600)
+        curHour = datetime.datetime.now().hour
+        moonImpact = 1.0
+
+        # Define MoonPhase Impact
+        if self.moonPhase["phase"]==4:
+            if self.outdoorStats.Clouds>80:
+                if curHour>23 or curHour<6:
+                    moonImpact += random.randint(0,9)/60
+                else:
+                    moonImpact += random.randint(0,5)/80
+            else:
+                if curHour>23 or curHour<6:
+                    moonImpact += random.randint(0,9)/120
+                else:
+                    moonImpact += random.randint(0,5)/180
+
+        # Calculate impact for stats calculation
+        impact = moonImpact
+
+        if time.time() - self.deviceStats.lastTimeToLoud > 600:
+            self.deviceStats.toLoud += float(updateDur / 8) * impact
+        if time.time() - self.deviceStats.lastTimeToQuiet > 600:
+            self.deviceStats.toQuiet += float(updateDur / 8) * impact
+        
+        # Home depended
+        if self.houseStats.temp_avg > 25.0 or self.houseStats.temp_hottest > 28.0:
+            self.deviceStats.hot += float(updateDur / 12) * impact
+        else:
+            self.deviceStats.hot -= float(updateDur / 38) * impact
+        if self.houseStats.temp_avg < 17.0 or self.houseStats.temp_hottest < 15.0:
+            self.deviceStats.freezy += float(updateDur / 12) * impact
+        else:
+            self.deviceStats.freezy -= float(updateDur / 38) * impact
+
+        if self.deviceStats.hot <200 and self.deviceStats.freezy < 200:
+            self.deviceStats.temperate -= float(updateDur / 12) * impact
+        else:
+            self.deviceStats.temperate += float(updateDur / 48) * impact
+
+        self.deviceStats.toLoud -= (float)(updateDur / 48)
+        if self.houseStats.bAtHome == True and self.houseStats.AtSleep == False:
+            self.deviceStats.toQuiet -= (float)(updateDur / 48)
+
+        # substractive
+        self.deviceStats.angry -= (float)(updateDur / 48)  * impact # 48std to 1000
+        self.deviceStats.annoyed -= (float)(updateDur / 50)
+        self.deviceStats.aroused -= (float)(updateDur / 72) * impact
+        if self.houseStats.bSleeping:
+            self.deviceStats.exhausted -= (float)(updateDur / 18)
+        else:
+            self.deviceStats.exhausted -= (float)(updateDur / 48)
+        self.deviceStats.humanity -= (float)(updateDur / 48)
+        self.deviceStats.naiv -= (float)(updateDur / 48)
+        self.deviceStats.shy -= (float)(updateDur / 500)
+        self.deviceStats.soziality -= (float)(updateDur / 48) * impact
+        self.deviceStats.usefull -= (float)(updateDur / 48)
+
+        # Additive
+        self.deviceStats.bored += (float)(updateDur / 50)
+        if self.houseStats.bSleeping:
+            self.deviceStats.energy += (float)(updateDur / 14) * impact
+        else:
+            self.deviceStats.energy += (float)(updateDur / 30) * impact
+        self.deviceStats.useless += (float)(updateDur / 168) # 168 = 1 Woche
+
+        if self.deviceStats.angry>500 or self.deviceStats.annoyed>400 or self.deviceStats.depressive>300 or self.deviceStats.energy<100 or self.deviceStats.sleepy>500 or self.deviceStats.toLoud>300:
+            self.deviceStats.exhausted += (float)(updateDur / 18)
+
+        if self.deviceStats.toQuiet > 50:
+            if self.deviceStats.toQuiet > 150:
+                if self.deviceStats.toQuiet > 450:
+                    if self.deviceStats.toQuiet > 600:
+                        self.deviceStats.lonely+= (float)(updateDur / 5)
+                    else:
+                        self.deviceStats.lonely+=(float)(updateDur / 8)
+                else:
+                    self.deviceStats.lonely+=(float)(updateDur / 32)
+            else:
+                self.deviceStats.lonely+=(float)(updateDur / 64)
+
+        # Dependend
+        if self.deviceStats.usefull > 600:
+            self.deviceStats.happyness += (float)(updateDur / 20) * impact
+        elif self.deviceStats.usefull > 400:
+            self.deviceStats.happyness += (float)(updateDur / 40) * impact
+        elif self.deviceStats.usefull > 300 and self.deviceStats.useless < 300:
+            self.deviceStats.happyness += (float)(updateDur / 50) * impact
+        else:
+            self.deviceStats.happyness -= (float)(updateDur / 20)
+
+        if self.deviceStats.temperate > 300:
+            self.deviceStats.angry += (float)(updateDur / 60) * impact
+        if self.deviceStats.freezy > 400 or self.deviceStats.hot > 400:
+            self.deviceStats.angry += (float)(updateDur / 50) * impact
+        if self.deviceStats.toLoud > 300 or self.deviceStats.toQuiet > 500:
+            self.deviceStats.angry += (float)(updateDur / 30) * impact
+
+        if self.houseStats.bSleeping:
+            self.deviceStats.sleepy -= (float)(updateDur / 15) * impact
+        else:
+            if self.deviceStats.toQuiet > 300:
+                self.deviceStats.sleepy += (float)(updateDur / 24);
+            if curHour > 21 or curHour < 8:
+                self.deviceStats.sleepy += (float)(updateDur / 48)
+
+        if self.outdoorStats.bRaining == True:
+            if self.outdoorStats.bWindy:
+                self.deviceStats.depressive += (float)(updateDur / 10)
+            else:
+                self.deviceStats.depressive += (float)(updateDur / 20)
+        elif self.deviceStats.angry > 650:
+            self.deviceStats.depressive += (float)(updateDur / 40) * impact
+        elif self.deviceStats.angry > 500:
+            self.deviceStats.depressive += (float)(updateDur / 50) * impact
+        elif self.deviceStats.angry > 300:
+            self.deviceStats.depressive += (float)(updateDur / 90) * impact
+        else:
+            self.deviceStats.depressive -= (float)(updateDur / 50)
+            
+        self.deviceStats.excited += (float)(updateDur / 50)
+        if self.deviceStats.depressive > 70:
+            if self.deviceStats.angry < 100:
+                self.deviceStats.happyness += (float)(updateDur / 120)
+            if self.deviceStats.compfortable > 300:
+                self.deviceStats.happyness += (float)(updateDur / 120)
+        else:
+            if self.deviceStats.angry < 120:
+                self.deviceStats.happyness += (float)(updateDur / 120)
+            if self.deviceStats.angry < 80:
+                self.deviceStats.happyness += (float)(updateDur / 45)
+            if self.deviceStats.compfortable > 300:
+                self.deviceStats.happyness += (float)(updateDur / 90)
+        
+        if self.deviceStats.happyness > 150:
+            self.deviceStats.funny += (float)(updateDur / 48) # Depends on happyness (>100) and other stats
+            if self.deviceStats.happyness > 300:
+                self.deviceStats.funny += (float)(updateDur / 48) # Depends on happyness (>100) and other stats
+        else:
+            self.deviceStats.funny -= (float)(updateDur / 90) # Depends on other stats
+        if self.deviceStats.hot < 100 and self.deviceStats.freezy < 100:
+            self.deviceStats.compfortable += (float)(updateDur / 90) # Depends on other stats
+        if self.deviceStats.toLoud < 200 and self.deviceStats.toQuiet < 400:
+            self.deviceStats.compfortable += (float)(updateDur / 120) # Depends on other stats
+            
+
+        if self.deviceStats.hot > 800 or self.deviceStats.freezy > 800:
+            self.deviceStats.compfortable -= (float)(updateDur / 20) # Depends on other stats
+            self.deviceStats.playful -= (float)(updateDur / 20) * impact # Depends on other stats
+            self.deviceStats.energy -= (float)(updateDur / 15) * impact
+        elif self.deviceStats.hot > 400 or self.deviceStats.freezy > 350:
+            self.deviceStats.compfortable -= (float)(updateDur / 80) # Depends on other stats
+            self.deviceStats.energy -= (float)(updateDur / 30)
+        elif self.deviceStats.hot > 200 or self.deviceStats.freezy > 100:
+            self.deviceStats.compfortable -= (float)(updateDur / 150) # Depends on other stats
+            
+
+        if self.deviceStats.toLoud > 800 or self.deviceStats.toQuiet > 800:
+            self.deviceStats.compfortable -= (float)(updateDur / 20) # Depends on other stats
+            self.deviceStats.angry += (float)(updateDur / 20) * impact
+            self.deviceStats.sleepy += (float)(updateDur / 20)
+            self.deviceStats.lonely -= (float)(updateDur / 100) * impact
+            self.deviceStats.happyness -= (float)(updateDur / 100)
+            self.deviceStats.bored -= (float)(updateDur / 100)
+            self.deviceStats.annoyed += (float)(updateDur / 100)
+        elif self.deviceStats.toLoud > 400 or self.deviceStats.toQuiet > 80:
+            self.deviceStats.compfortable -= (float)(updateDur / 80) # Depends on other stats
+            self.deviceStats.angry += (float)(updateDur / 80)
+            self.deviceStats.sleepy += (float)(updateDur / 80) * impact
+            self.deviceStats.annoyed += (float)(updateDur / 150) * impact
+        elif self.deviceStats.toLoud > 200 or self.deviceStats.toQuiet > 100:
+            self.deviceStats.compfortable -= (float)(updateDur / 150) # Depends on other stats
+            self.deviceStats.sleepy += (float)(updateDur / 100)
+            
+
+        if self.deviceStats.happyness > 650 and self.deviceStats.funny > 500:
+            self.deviceStats.playful += (float)(updateDur / 8) # Depends on naiv, funny and other stats
+        elif self.deviceStats.happyness > 500 and self.deviceStats.funny > 500:
+            self.deviceStats.playful += (float)(updateDur / 12) * impact # Depends on naiv, funny and other stats
+        elif self.deviceStats.happyness > 300 and self.deviceStats.funny > 300:
+            self.deviceStats.playful += (float)(updateDur / 18) # Depends on naiv, funny and other stats
+        elif self.deviceStats.happyness > 150 and self.deviceStats.funny > 150:
+            self.deviceStats.playful += (float)(updateDur / 48) # Depends on naiv, funny and other stats
+        else:
+            self.deviceStats.playful -= (float)(updateDur / 48) * impact # Depends on naiv, funny and other stats
+
+
+        if self.deviceStats.angry > 800:
+            self.deviceStats.sad += (float)(updateDur / 12)
+        elif self.deviceStats.angry > 600:
+            self.deviceStats.sad += (float)(updateDur / 18)
+        elif self.deviceStats.angry > 450:
+            self.deviceStats.sad += (float)(updateDur / 24)
+        elif self.deviceStats.angry > 250:
+            self.deviceStats.sad += (float)(updateDur / 30)
+        else:
+            self.deviceStats.sad -= (float)(updateDur / 48)
+        self.deviceStats.Save()
+        
+
+    def getJson(self):
+        return {
+            "DeviceStats": self.deviceStats.getJson(),
+            "HouseStats": self.houseStats.getJson(),
+            "MicLevel": self.micLevel.getJson(),
+            "OutdoorStats": self.outdoorStats.getJson(),
+            "OwnerStats": self.ownerStats.getJson(),
+            "TalkingStats": self.talkingStats.getJson()
+        }
+
+    def __del__(self):
+        print("Del Stat-Classes")
+
+        self.Thread_Emotion.cancel()
+        self.Thread_Homematic.cancel()
+        self.Thread_DateTime.cancel()
+        self.Thread_OutDoor.cancel()
+        self.Thread_Mic.cancel()
+
+        del self.Thread_Emotion
+        del self.Thread_Homematic
+        del self.Thread_DateTime
+        del self.Thread_OutDoor
+        del self.Thread_Mic
+
+        del self.deviceStats
+        del self.HouseStats
+        del self.MicLevel
+        del self.OutdoorStats
+        del self.OwnerStats
+        del self.TalkingStats

+ 20 - 0
Trixy.pyproj

@@ -22,11 +22,31 @@
   </PropertyGroup>
   <ItemGroup>
     <Compile Include="main.py" />
+    <Compile Include="Stats\AdminStats.py" />
+    <Compile Include="Stats\DeviceStats.py" />
+    <Compile Include="Stats\HouseStats.py" />
+    <Compile Include="Stats\MicLevel.py" />
+    <Compile Include="Stats\OutdoorStats.py" />
+    <Compile Include="Stats\OwnerStats.py" />
+    <Compile Include="Stats\TalkingStats.py" />
+    <Compile Include="Stats\__init__.py" />
   </ItemGroup>
   <ItemGroup>
     <Content Include=".gitignore" />
     <Content Include="LICENSE" />
     <Content Include="README.md" />
+    <Content Include="Stats\__pycache__\AdminStats.cpython-37.pyc" />
+    <Content Include="Stats\__pycache__\DeviceStats.cpython-37.pyc" />
+    <Content Include="Stats\__pycache__\HouseStats.cpython-37.pyc" />
+    <Content Include="Stats\__pycache__\MicLevel.cpython-37.pyc" />
+    <Content Include="Stats\__pycache__\OutdoorStats.cpython-37.pyc" />
+    <Content Include="Stats\__pycache__\OwnerStats.cpython-37.pyc" />
+    <Content Include="Stats\__pycache__\TalkingStats.cpython-37.pyc" />
+    <Content Include="Stats\__pycache__\__init__.cpython-37.pyc" />
+  </ItemGroup>
+  <ItemGroup>
+    <Folder Include="Stats\" />
+    <Folder Include="Stats\__pycache__\" />
   </ItemGroup>
   <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets" />
   <!-- Uncomment the CoreCompile target to enable the Build command in