Ankündigung

Einklappen
Keine Ankündigung bisher.

Item mit Zeitberechnung bspw für Verbrauchsauswertung als Systemitems bereitstellen

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge
    Sisamiwe
    Forums-Einsteiger

  • Sisamiwe
    antwortet
    Zitat von z1marco Beitrag anzeigen
    Hast Du noch eine Idee?
    Der Fehler kommt immer dann, wenn es in dem Abfragezeitraum keine Daten gibt.
    Bist Du sicher, dass die db für den Zeitraum Werte enthält?

    Du kannst folgendes mal probieren:
    Du gehst im Admin Interface auf "Dienste" und dann "eval Syntax Prüfer". Dort kannst Du unter "Ausdruck (Eingabe im Python eval-Format" Deinen gesamten Ausdruck eingeben oder reinkopieren. Mit "Prüfen" startest Du die gleiche Abfrage, wie sonst beim Triggern des Items.

    Wenn der Fehler immer noch kommt, kannst du sukzessive Deinen eval-Asudruck zurückbauen, um den Fehler einzugrenzen.

    Einen Kommentar schreiben:

  • z1marco
    Forums-Einsteiger

  • z1marco
    antwortet
    Hallo Michael,

    die Berechnung für heute klappt wunderbar, leider kommt bei gestern und vielen anderen Berechnungen der Fehler

    unsupported operand type(s) for -: 'float' and 'NoneType'

    Hast Du das genauso bei Dir am laufen oder kann da ein Copy Paste Fehler drinnen sein?

    Folgender Eval Wert für heute funktioniert:
    round((sh.Energie.Haushalt.Verbrauch() - sh.Energie.Haushalt.Verbrauch.db('max', str(shtime.time_since(shtime.today(), 'im')) + 'i', str(shtime.time_since(shtime.today(), 'im')) + 'i')), 2)


    Folgender Eval Wert für gestern kommt o.g. Fehler:
    round((sh.Energie.Haushalt.Verbrauch.db('max', str(shtime.time_since(shtime.today(), 'im')) + 'i', str(shtime.time_since(shtime.today(), 'im')) + 'i') - sh.Energie.Haushalt.Verbrauch.db('max', str(shtime.time_since(shtime.yesterday(), 'im')) + 'i', str(shtime.time_since(shtime.yesterday(), 'im')) + 'i')), 2)

    Ich finde leider den Fehler nicht und denke, dass es eigentlich gehen müsste.

    Hast Du noch eine Idee?

    vielen Dank

    Einen Kommentar schreiben:

  • Sisamiwe
    Forums-Einsteiger

  • Sisamiwe
    antwortet
    Hallo,

    ich habe mir basierend auf sh.time ein struct für die Verbrauchsauswertung gebaut.
    Verwendet werden kann dieses struct bei allen Items, die fortlaufende Zählerstände enthalten.

    struct.yaml

    Code:
    wertehistorie_total:
        name: Struct für Wertehistorie total
        heute:
            type: num
            visu_acl: ro
            eval: round((sh...() - sh...db('max', str(shtime.time_since(shtime.today(), 'im')) + 'i', str(shtime.time_since(shtime.today(), 'im')) + 'i')), 2)
            eval_trigger:
              - ..
            cache: yes
    
        woche:
            type: num
            visu_acl: ro
            eval: round((sh...() - sh...db('max', str(shtime.time_since(shtime.beginning_of_week(), 'im')) + 'i', str(shtime.time_since(shtime.beginning_of_week(), 'im')) + 'i')), 2)
            eval_trigger:
              - ..
            cache: yes
    
        monat:
            type: num
            visu_acl: ro
            eval: round((sh...() - sh...db('max', str(shtime.time_since(shtime.beginning_of_month(), 'im')) + 'i', str(shtime.time_since(shtime.beginning_of_month(), 'im')) + 'i')), 2)
            eval_trigger:
              - ..
            cache: yes
    
        jahr:
            type: num
            visu_acl: ro
            eval: round((sh...() - sh...db('max', str(shtime.time_since(shtime.beginning_of_year(), 'im')) + 'i', str(shtime.time_since(shtime.beginning_of_year(), 'im')) + 'i')), 2)
            eval_trigger:
              - ..
            cache: yes
    
        gestern:
            type: num
            visu_acl: ro
            eval: round((sh...db('max', str(shtime.time_since(shtime.today(), 'im')) + 'i', str(shtime.time_since(shtime.today(), 'im')) + 'i') - sh...db('max', str(shtime.time_since(shtime.yesterday(), 'im')) + 'i', str(shtime.time_since(shtime.yesterday(), 'im')) + 'i')), 2)
            crontab:
             - 1 0 * * = 1
             - init+20 = 1
            database: init
    
        gestern_minus1:
            type: num
            visu_acl: ro
            eval: round((sh...db('max', str(shtime.time_since(shtime.yesterday(), 'im')) + 'i', str(shtime.time_since(shtime.yesterday(), 'im')) + 'i') - sh...db('max', str((shtime.time_since(shtime.yesterday(), 'im')) + 1440) + 'i', str((shtime.time_since(shtime.yesterday(), 'im')) + 1440) + 'i')), 2)
            crontab:
             - 1 0 * * = 1
             - init+20 = 1
            cache: yes
        
        gestern_minus2:
            type: num
            visu_acl: ro
            eval: round((sh...db('max', str((shtime.time_since(shtime.yesterday(), 'im')) + 1440) + 'i', str((shtime.time_since(shtime.yesterday(), 'im')) + 1440) + 'i') - sh...db('max', str((shtime.time_since(shtime.yesterday(), 'im')) + 2880) + 'i', str((shtime.time_since(shtime.yesterday(), 'im')) + 2880) + 'i')), 2)
            crontab:
             - 1 0 * * = 1
             - init+20 = 1
            cache: yes
            
        gestern_minus3:
            type: num
            visu_acl: ro
            eval: round((sh...db('max', str((shtime.time_since(shtime.yesterday(), 'im')) + 2880) + 'i', str((shtime.time_since(shtime.yesterday(), 'im')) + 2880) + 'i') - sh...db('max', str((shtime.time_since(shtime.yesterday(), 'im')) + 4320) + 'i', str((shtime.time_since(shtime.yesterday(), 'im')) + 4320) + 'i')), 2)
            crontab:
             - 1 0 * * = 1
             - init+20 = 1
            cache: yes
            
        gestern_minus4:
            type: num
            visu_acl: ro
            eval: round((sh...db('max', str((shtime.time_since(shtime.yesterday(), 'im')) + 4320) + 'i', str((shtime.time_since(shtime.yesterday(), 'im')) + 4320) + 'i') - sh...db('max', str((shtime.time_since(shtime.yesterday(), 'im')) + 5760) + 'i', str((shtime.time_since(shtime.yesterday(), 'im')) + 5760) + 'i')), 2)
            crontab:
             - 1 0 * * = 1
             - init+20 = 1
            cache: yes
    
        gestern_minus5:
            type: num
            visu_acl: ro
            eval: round((sh...db('max', str((shtime.time_since(shtime.yesterday(), 'im')) + 5760) + 'i', str((shtime.time_since(shtime.yesterday(), 'im')) + 5760) + 'i') - sh...db('max', str((shtime.time_since(shtime.yesterday(), 'im')) + 7200) + 'i', str((shtime.time_since(shtime.yesterday(), 'im')) + 7200) + 'i')), 2)
            crontab:
             - 1 0 * * = 1
             - init+20 = 1
            cache: yes                
            
        vorwoche:
            type: num
            visu_acl: ro
            eval: round((sh...db('max', str(shtime.time_since(shtime.beginning_of_week(), 'im')) + 'i', str(shtime.time_since(shtime.beginning_of_week(), 'im')) + 'i') - sh...db('max', str(shtime.time_since(shtime.beginning_of_week(shtime.calendar_week() - 1), 'im')) + 'i', str(shtime.time_since(shtime.beginning_of_week(shtime.calendar_week() - 1), 'im')) + 'i')), 2)
            crontab:
             - 1 0 * * = 1
             - init+20 = 1
            database: init
    
        vorwoche_minus1:
            type: num
            visu_acl: ro
            eval: round((sh...db('max', str(shtime.time_since(shtime.beginning_of_week(shtime.calendar_week() - 1), 'im')) + 'i', str(shtime.time_since(shtime.beginning_of_week(shtime.calendar_week() - 1), 'im')) + 'i') - sh...db('max', str(shtime.time_since(shtime.beginning_of_week(shtime.calendar_week() - 2), 'im')) + 'i', str(shtime.time_since(shtime.beginning_of_week(shtime.calendar_week() - 2), 'im')) + 'i')), 2)
            crontab:
             - 1 0 * * = 1
             - init+20 = 1
            cache: yes
            
        vorwoche_minus2:
            type: num
            visu_acl: ro
            eval: round((sh...db('max', str(shtime.time_since(shtime.beginning_of_week(shtime.calendar_week() - 2), 'im')) + 'i', str(shtime.time_since(shtime.beginning_of_week(shtime.calendar_week() - 2), 'im')) + 'i') - sh...db('max', str(shtime.time_since(shtime.beginning_of_week(shtime.calendar_week() - 3), 'im')) + 'i', str(shtime.time_since(shtime.beginning_of_week(shtime.calendar_week() - 3), 'im')) + 'i')), 2)
            crontab:
             - 1 0 * * = 1
             - init+20 = 1
            cache: yes
            
        vorwoche_minus3:
            type: num
            visu_acl: ro
            eval: round((sh...db('max', str(shtime.time_since(shtime.beginning_of_week(shtime.calendar_week() - 3), 'im')) + 'i', str(shtime.time_since(shtime.beginning_of_week(shtime.calendar_week() - 3), 'im')) + 'i') - sh...db('max', str(shtime.time_since(shtime.beginning_of_week(shtime.calendar_week() - 4), 'im')) + 'i', str(shtime.time_since(shtime.beginning_of_week(shtime.calendar_week() - 4), 'im')) + 'i')), 2)
            crontab:
             - 1 0 * * = 1
             - init+20 = 1
            cache: yes
            
        vormonat:
            type: num
            visu_acl: ro
            eval: round((sh...db('max', str(shtime.time_since(shtime.beginning_of_week(shtime.calendar_week() - 1), 'im')) + 'i', str(shtime.time_since(shtime.beginning_of_week(shtime.calendar_week() - 1), 'im')) + 'i') - sh...db('max', str(shtime.time_since(shtime.beginning_of_month(shtime.current_month() - 2), 'im')) + 'i', str(shtime.time_since(shtime.beginning_of_month(shtime.current_month() - 2), 'im')) + 'i')), 2)
            crontab:
             - 1 0 1 * = 1
             - init+20 = 1
            database: init
            
        vormonat_minus1:
            type: num
            visu_acl: ro
            eval: round((sh...db('max', str(shtime.time_since(shtime.beginning_of_week(shtime.calendar_week() - 1), 'im')) + 'i', str(shtime.time_since(shtime.beginning_of_week(shtime.calendar_week() - 1), 'im')) + 'i') - sh...db('max', str(shtime.time_since(shtime.beginning_of_month(shtime.current_month() - 2), 'im')) + 'i', str(shtime.time_since(shtime.beginning_of_month(shtime.current_month() - 2), 'im')) + 'i')), 2)
            crontab:
             - 1 0 1 * = 1
             - init+20 = 1
            cache: yes    
            
        vormonat_minus2:
            type: num
            visu_acl: ro
            eval: round((sh...db('max', str(shtime.time_since(shtime.beginning_of_week(shtime.calendar_week() - 2), 'im')) + 'i', str(shtime.time_since(shtime.beginning_of_week(shtime.calendar_week() - 2), 'im')) + 'i') - sh...db('max', str(shtime.time_since(shtime.beginning_of_month(shtime.current_month() - 3), 'im')) + 'i', str(shtime.time_since(shtime.beginning_of_month(shtime.current_month() - 3), 'im')) + 'i')), 2)
            crontab:
             - 1 0 1 * = 1
             - init+20 = 1
            cache: yes  
    
        vormonat_zaehlerstand:
            type: num
            visu_acl: ro
            eval: round(sh...db('max', str(shtime.time_since(shtime.beginning_of_month(), 'im')) + 'i', str(shtime.time_since(shtime.beginning_of_month(), 'im')) + 'i'), 2)
            crontab:
             - 1 0 1 * = 1
             - init+20 = 1
            database: init
            
        vormonat_minus1_zaehlerstand:
            type: num
            visu_acl: ro
            eval: round(sh...db('max', str(shtime.time_since(shtime.beginning_of_month(shtime.current_month() - 1), 'im')) + 'i', str(shtime.time_since(shtime.beginning_of_month(shtime.current_month() - 1), 'im')) + 'i'), 2)
            crontab:
             - 1 0 1 * = 1
             - init+20 = 1
            cache: yes
        
        vormonat_minus2_zaehlerstand:
            type: num
            visu_acl: ro
            eval: round(sh...db('max', str(shtime.time_since(shtime.beginning_of_month(shtime.current_month() - 2), 'im')) + 'i', str(shtime.time_since(shtime.beginning_of_month(shtime.current_month() - 2), 'im')) + 'i'), 2)
            crontab:
             - 1 0 1 * = 1
             - init+20 = 1
            cache: yes
    item.yaml:
    Code:
    heizung:
        brenner:
            starts_knx:
                name: Brennerstarts via KNX
                struct: wertehistorie_total
    Die Angaben zur Ermittlung der Datenbankabfragezeiträume sind etwas lang, dafür kommt man ohne Logik aus.
    Vielleicht hilft es jemanden.

    Michael

    Einen Kommentar schreiben:

  • z1marco
    Forums-Einsteiger

  • z1marco
    antwortet
    Kannst Du mir Deine funktionierenden Items mal zur Verfügung stellen? Die Logik wird dann nicht mehr gebraucht oder?

    Einen Kommentar schreiben:

  • Sisamiwe
    Forums-Einsteiger

  • Sisamiwe
    antwortet
    Ja, habe ich bzw wird nun keine Logik mehr gebraucht, sondern man kann sh.time direkt in den Items zur db-Abfrage verwenden.

    Einen Kommentar schreiben:

  • z1marco
    Forums-Einsteiger

  • z1marco
    antwortet
    Hi Sisamiwe,

    hast Du Deine Logik schon auf shtime umgestellt? Ich nutze Deine Logik schon ziemlich lange und bin damit sehr zufrieden.

    Gruß und Danke

    Einen Kommentar schreiben:


  • psilo
    antwortet
    https://github.com/smarthomeNG/smart...shtime.py#L309

    Einen Kommentar schreiben:


  • psilo
    antwortet
    Ich glaube
    Msinn hat im neuen Release einen (sinnvollen) Teil davon als API Funktion inkludiert
    Zuletzt geändert von psilo; 01.03.2020, 13:27.

    Einen Kommentar schreiben:

  • Sisamiwe
    Forums-Einsteiger

  • Item mit Zeitberechnung bspw für Verbrauchsauswertung als Systemitems bereitstellen

    Hallo,

    für die zeitliche Auswertung u.a. von Verbrauch verwende ich eine Logik, die mit folgendes Items "füllt":
    Code:
    %YAML 1.1
    ---
    time:
        date:
            current_month:
                type: foo
            last_month:
                type: foo
            last_month_but_one:
                type: foo
            last_month_but_two:
                type: foo
        year:
            current:
                type: num
        month:
            since:
                year:
                    type: num
                    dbstr:
                        type: str
                        eval_trigger: time.month.since.year
                        eval: str(sh.time.month.since.year()) + 'm'
            until:
                year:
                    type: num
                    dbstr:
                        type: str
                        eval_trigger: time.month.until.year
                        eval: str(sh.time.month.until.year()) + 'm'
            list:
                type: str
                value: Januar Februar März April Mai Juni Juli August September Oktober November Dezember
                visu_acl: r
            current:
                type: num
                cache: yes
                current_name:
                    type: str
                    eval: sh.time.month.list().split()[int(sh.time.month.current() - 1)]
                    eval_trigger: time.month.current
                    cache: yes
        week:
            since:
                month:
                    type: num
                year:
                    type: num
            until:
                month:
                    type: num
                year:
                    type: num
        day:
            since:
                week:
                    type: num
                    dbstr:
                        type: str
                        eval_trigger: time.day.since.week
                        eval: str(sh.time.day.since.week()) + 'd'
                month:
                    type: num
                    dbstr:
                        type: str
                        eval_trigger: time.day.since.month
                        eval: str(sh.time.day.since.month()) + 'd'
                year:
                    type: num
                    dbstr:
                        type: str
                        eval_trigger: time.day.since.year
                        eval: str(sh.time.day.since.year()) + 'd'
            until:
                week:
                    type: num
                    dbstr:
                        type: str
                        eval_trigger: time.day.since.week
                        eval: str(sh.time.day.since.week()) + 'd'
                month:
                    type: num
                    dbstr:
                        type: str
                        eval_trigger: time.day.until.month
                        eval: str(sh.time.day.until.month()) + 'd'
                year:
                    type: num
                    dbstr:
                        type: str
                        eval_trigger: time.day.until.year
                        eval: str(sh.time.day.until.year()) + 'd'
        hour:
            since:
                midnight:
                    type: num
                    cache: yes
                    dbstr:
                        type: str
                        cache: yes
                        eval_trigger: time.hour.since.midnight
                        eval: str(sh.time.hour.since.midnight()) + 'h'
                week:
                    type: num
                    dbstr:
                        type: str
                        cache: yes
                        eval_trigger: time.hour.since.week
                        eval: str(sh.time.hour.since.week()) + 'h'
                month:
                    type: num
                    cache: yes
                    dbstr:
                        type: str
                        cache: yes
                        eval_trigger: time.hour.since.month
                        eval: str(sh.time.hour.since.month()) + 'h'
                year:
                    type: num
                    cache: yes
                    dbstr:
                        type: str
                        cache: yes
                        eval_trigger: time.hour.since.year
                        eval: str(sh.time.hour.since.year()) + 'h'
            until:
                midnight:
                    type: num
                    dbstr:
                        type: str
                        eval_trigger: time.hour.until.midnight
                        eval: str(sh.time.hour.until.midnight()) + 'h'
                week:
                    type: num
                    dbstr:
                        type: str
                        eval_trigger: time.hour.until.week
                        eval: str(sh.time.hour.until.week()) + 'h'
                month:
                    type: num
                    dbstr:
                        type: str
                        eval_trigger: time.hour.until.month
                        eval: str(sh.time.hour.until.month()) + 'h'
                year:
                    type: num
                    dbstr:
                        type: str
                        eval_trigger: time.hour.until.year
                        eval: str(sh.time.hour.until.year()) + 'h'
        minute:
            since:
                hour:
                    type: num
                    dbstr:
                        type: str
                        eval_trigger: time.minute.since.hour
                        eval: str(sh.time.minute.since.hour()) + 'i'
                midnight:
                    type: num
                    cache: yes
                    dbstr:
                        type: str
                        cache: yes
                        eval_trigger: time.minute.since.midnight
                        eval: str(sh.time.minute.since.midnight()) + 'i'
                week:
                    type: num
                    cache: yes
                    dbstr:
                        type: str
                        cache: yes
                        eval_trigger: time.minute.since.week
                        eval: str(sh.time.minute.since.week()) + 'i'
                month:
                    type: num
                    cache: yes
                    dbstr:
                        type: str
                        cache: yes
                        eval_trigger: time.minute.since.month
                        eval: str(sh.time.minute.since.month()) + 'i'
                year:
                    type: num
                    cache: yes
                    dbstr:
                        type: str
                        cache: yes
                        eval_trigger: time.minute.since.year
                        eval: str(sh.time.minute.since.year()) + 'i'
            until:
                hour:
                    type: num
                    dbstr:
                        type: str
                        eval_trigger: time.minute.until.hour
                        eval: str(sh.time.minute.until.hour()) + 'i'
                midnight:
                    type: num
                    dbstr:
                        type: str
                        eval_trigger: time.minute.until.midnight
                        eval: str(sh.time.minute.until.midnight()) + 'i'
                week:
                    type: num
                    dbstr:
                        type: str
                        eval_trigger: time.minute.until.week
                        eval: str(sh.time.minute.until.week()) + 'i'
                month:
                    type: num
                    dbstr:
                        type: str
                        eval_trigger: time.minute.until.month
                        eval: str(sh.time.minute.until.month()) + 'i'
                year:
                    type: num
                    dbstr:
                        type: str
                        eval_trigger: time.minute.until.year
                        eval: str(sh.time.minute.until.year()) + 'i'
        second:
            since:
                minute:
                    type: num
                hour:
                    type: num
                midnight:
                    type: num
                week:
                    type: num
                month:
                    type: num
                year:
                    type: num
            until:
                minute:
                    type: num
                hour:
                    type: num
                midnight:
                    type: num
                week:
                    type: num
                month:
                    type: num
                year:
                    type: num
    Die Logik selbst:
    Code:
    #/logics/zeit.py
    #!/usr/bin/env python
    
    from dateutil.relativedelta import relativedelta
    
    sh_now = sh.now()
    debug = False
    
    # Funktionen                    
    
    #def leap_year(year):
    #    if (year % 400 == 0) or ((year % 4 == 0) and not (year % 100 == 0)):
    #        return True
    #    else:
    #        return False
    
    def days_of_month(month, year):
        if month in [1, 3, 5, 7, 8, 10, 12]:
            days = 31
        elif month in [4, 6, 9, 11]:
            days = 30
        elif (year % 400 == 0) or ((year % 4 == 0) and not (year % 100 == 0)):  #Schaltjahr
            days = 29
        else:
            days = 28
        return days
    
    def days_of_year(year):
        period_end = datetime.datetime(year,12,31)
        days_of_year = (period_end - datetime.datetime(period_end.year, 1, 1)).days + 1
        return(days_of_year)
    
    def day_of_year(year,month,day):
        period_end = datetime.datetime(year,month,day)
        day_of_year = (period_end - datetime.datetime(period_end.year, 1, 1)).days + 1
        return(day_of_year)
    
    if debug == True:
        print("RUNNING LOGIC OF TIME - REMOVE AFTER DEBUG")
        print(sh_now.hour) #Stunde
        print(sh_now.minute) #Minute
        print(sh_now.second) #Sekunde
        print(sh_now.day)  #Tag
        print(sh_now.month) #Monat
        print(sh_now.isoweekday()) #Wochentag
        print(sh.now().isocalendar()[1]) #Kalenderwoche
        
    # Sekunde/Minute
    sh.time.second.since.minute(sh_now.second)
    sh.time.second.until.minute(60 - sh_now.second - 1)
    
    # Minute/Stunde
    sh.time.minute.since.hour(sh_now.minute)
    sh.time.minute.until.hour(60 - sh_now.minute - 1)
    
    # Stunde/Tag
    sh.time.hour.since.midnight(sh_now.hour)
    sh.time.hour.until.midnight(24 - sh_now.hour - 1)
    
    # Tag/Woche
    sh.time.day.since.week(sh_now.isoweekday())
    sh.time.day.until.week(7 - sh_now.isoweekday())
    
    # Stunde/Woche
    sh.time.hour.since.week(sh.time.hour.since.midnight() + (24 * (sh.time.day.since.week() - 1)))
    sh.time.hour.until.week(sh.time.hour.until.midnight() + (24 * sh.time.day.until.week()))
    
    # Kalenderwoche/Jahr
    sh.time.week.since.year(sh.now().isocalendar()[1])
    
    # Monat/Jahr
    sh.time.month.since.year(sh_now.month)
    sh.time.month.until.year(12-sh_now.month)
    
    # Sekunde/Stunde
    sh.time.second.since.hour(sh.time.second.since.minute() + (60 * sh.time.minute.since.hour()))
    sh.time.second.until.hour(sh.time.second.until.minute() + (60 * sh.time.minute.until.hour()))
    
    # Sekunde/Tag
    sh.time.second.since.midnight(sh.time.second.since.minute() + (3600 * sh.time.hour.since.midnight()))
    sh.time.second.until.midnight(sh.time.second.until.minute() + (3600 * sh.time.hour.until.midnight()))
    
    # Minute/Tag
    sh.time.minute.since.midnight(sh.time.minute.since.hour() + (60 * sh.time.hour.since.midnight()))
    sh.time.minute.until.midnight(sh.time.minute.until.hour() + (60 * sh.time.hour.until.midnight()))
    
    # Minute/Woche
    sh.time.minute.since.week(sh.time.minute.since.hour() + (60 * sh.time.hour.since.week()))
    sh.time.minute.until.week(sh.time.minute.until.hour() + (60 * sh.time.hour.until.week()))
    
    # Sekunde/Woche
    sh.time.second.since.week(sh.time.second.since.minute() + (60 * sh.time.minute.since.week()))
    sh.time.second.until.week(sh.time.second.until.minute() + (60 * sh.time.minute.until.week()))
    
    # Tage/Monat
    sh.time.day.since.month(sh_now.day - 1)
    sh.time.day.until.month(days_of_month(sh_now.month,sh_now.year) - sh.time.day.since.month() - 1)
    
    # Tage/Jahr
    sh.time.day.since.year(day_of_year(sh_now.year,sh_now.month,sh_now.day) - 1)
    sh.time.day.until.year(days_of_year(sh_now.year) - sh.time.day.since.year() - 1)
    
    # Stunde/Monat
    sh.time.hour.since.month((24 * sh.time.day.since.month()) + sh.time.hour.since.midnight())
    sh.time.hour.until.month((24 * days_of_month(sh_now.month,sh_now.year)) - sh.time.hour.since.month() - 1)
    
    # Stunde/Jahr
    sh.time.hour.since.year((24 * sh.time.day.since.year()) + sh.time.hour.since.midnight())
    sh.time.hour.until.year((24 * days_of_year(sh_now.year)) - sh.time.hour.since.year() - 1)
    
    # Minute/Monat
    sh.time.minute.since.month((60 * sh.time.hour.since.month()) + sh.time.minute.since.hour())
    sh.time.minute.until.month(sh.time.minute.since.month() - (60 * sh.time.hour.until.month()) - 1)
    
    # Minute/Jahr
    sh.time.minute.since.year((60 * sh.time.hour.since.year()) + sh.time.minute.since.hour())
    sh.time.minute.until.year((60 * sh.time.hour.until.year()) + sh.time.minute.until.hour())
    
    # Sekunde/Monat
    sh.time.second.since.month((60 * sh.time.minute.since.month()) + sh.time.second.since.minute())
    sh.time.second.until.month((60 * sh.time.minute.until.month()) + sh.time.second.until.minute())
    
    # Sekunde/Jahr
    sh.time.second.since.year((60 * sh.time.minute.since.year()) + sh.time.second.since.minute())
    sh.time.second.until.year((60 * sh.time.minute.until.year()) + sh.time.second.until.minute())
    
    # Aktueller Monat
    sh.time.month.current(sh_now.month)
    
    # Aktuelles Jahr
    sh.time.year.current(sh_now.year)
    
    # Aktuelles Monat/Jahr
    today_date = datetime.date.today()
    sh.time.date.current_month(today_date.strftime("%m/%Y"))
    
    # Letzter Monat/Jahr
    last_month = today_date - relativedelta(months=1)
    sh.time.date.last_month(last_month.strftime("%m/%Y"))
    
    # Vorletzter Monat/Jahr
    last_month_but_one = today_date - relativedelta(months=2)
    sh.time.date.last_month_but_one(last_month_but_one.strftime("%m/%Y"))
    
    # VorVorletzter Monat/Jahr
    last_month_but_two = today_date - relativedelta(months=3)
    sh.time.date.last_month_but_two(last_month_but_two.strftime("%m/%Y"))
    Damit kann man dann Datenbankabfragen für gestern, vorgestern, letzten Monat etc mache.
    bspw. so.

    Code:
        gestern:
            type: num
            visu_acl: ro
            eval: round((sh...db('max', sh.time.minute.since.midnight.dbstr(), sh.time.minute.since.midnight.dbstr()) - sh...db('max', str(sh.time.minute.since.midnight() + 1440) + 'i', str(sh.time.minute.since.midnight() + 1440) + 'i')), 2)
            crontab: 1 0 * * = 1
            database: init
    Meine Frage ist, ob es sinnvoll wäre, diese Items als Systemitems oder als Zeitmodul zur Verfügung zu stellen?
    Was meint ihr?
    Msinn
    bmx
    psilo
Lädt...
X