Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. ioBroker Allgemein
    4. History-Adapter .csv download PROBLEM

    NEWS

    • ioBroker goes Matter ... Matter Adapter in Stable

    • 15. 05. Wartungsarbeiten am ioBroker Forum

    • Monatsrückblick - April 2025

    History-Adapter .csv download PROBLEM

    This topic has been deleted. Only users with topic management privileges can see it.
    • Homoran
      Homoran Global Moderator Administrators @petzi2712 last edited by

      @petzi2712 sagte in History-Adapter .csv download PROBLEM:

      @Homoran im Video wird die Version vom History Adapter 1.8.5 verwendet.... ich hab meine Version auf die selbige mal Downgegraded ohne gewünschten Erfolg … ich bin langsam echt Ratlos... 😕 Habs auch mit diversen Browsern versucht....

      Entscheidend wird die Version des admin sein

      1 Reply Last reply Reply Quote 0
      • K
        klassisch Most Active last edited by

        Hi,
        diese Funktion könnte ich jetzt auch gut gebrauchen.
        Bei mir werden aber nur ca. 80 Werte der letzten 6 Tage gelistet. Egal was ich eingebe.
        Adapter V3.6.2

        1 Reply Last reply Reply Quote 0
        • P
          petzi2712 last edited by

          Wirklich keiner ne Idee....? Ist das ein "bug oder feature" 😉 ?

          sigi234 1 Reply Last reply Reply Quote 0
          • sigi234
            sigi234 Forum Testing Most Active @petzi2712 last edited by

            @petzi2712 sagte in History-Adapter .csv download PROBLEM:

            Wirklich keiner ne Idee....? Ist das ein "bug oder feature" 😉 ?

            Bug..........

            P 1 Reply Last reply Reply Quote 0
            • P
              petzi2712 @sigi234 last edited by

              @sigi234 schade... gibt es Menschen die das heilen können?!?!

              Homoran 1 Reply Last reply Reply Quote 1
              • Homoran
                Homoran Global Moderator Administrators @petzi2712 last edited by

                @petzi2712 sagte in History-Adapter .csv download PROBLEM:

                @sigi234 schade... gibt es Menschen die das heilen können?!?!

                Wenn jemand systematisch herausbekommt was da schief läuft, wird es einfacher.

                C 1 Reply Last reply Reply Quote 0
                • C
                  chris299 @Homoran last edited by

                  @homoran ziemlich alter thread, aber das Problem ist immernoch akutell (bei mir) und in github: https://github.com/ioBroker/ioBroker.history/issues/309

                  gitisgreat2023 created this issue in ioBroker/ioBroker.history

                  open Save as CSV in History Data only exports ~2000 entries #309

                  Homoran 1 Reply Last reply Reply Quote 0
                  • Homoran
                    Homoran Global Moderator Administrators @chris299 last edited by

                    @chris299 sagte in History-Adapter .csv download PROBLEM:

                    immernoch akutell (bei mir

                    ja, weil es so konzipiert ist.
                    Das ist kein Fehler!

                    C 1 Reply Last reply Reply Quote 0
                    • C
                      chris299 @Homoran last edited by

                      @homoran aha. steht das irgendwo in der Aneitung, und ich habe das übersehen? offensichtlich erscheint mir das nicht...
                      und es drängt sich die Frage auf, wie man denn alle Werte eines Datenpunkts gesammelt extrahiert bekommt (zur weiterverarbeitung in anderen Systemen)....

                      Homoran K 2 Replies Last reply Reply Quote 0
                      • Homoran
                        Homoran Global Moderator Administrators @chris299 last edited by Homoran

                        @chris299 sagte in History-Adapter .csv download PROBLEM:

                        steht das irgendwo in der Aneitung, und ich habe das übersehen? offensichtlich erscheint mir das nicht...

                        gute Frage!
                        Wurde auf jeden Fall mehrfach im Forum diskutiert.
                        Auch die Anzeige der History-Daten ist auf 500 Messwerte limitiert.
                        Die "Extraktion" dieser Daten aus den JSONs benötigt erhebliche Ressourcen.
                        So kann auch ein zoomen in hochauflösenden charts die Load Average deutlich über die Obergrenze bis hin zum Absturz führen.

                        So unschön es ist, müsstest du die Daten paketweise mit benutzerdefinierten Zeiträumen extrahieren, oder per Script versuchen, was jedoch den Server genauso belastet, wenn man nicht bei schwachen Systemen die Abfragegeschwindigkeit entsprechend versucht zu drosseln.

                        1 Reply Last reply Reply Quote 0
                        • K
                          klassisch Most Active @chris299 last edited by

                          @chris299 Hast Du ein lauffähiges Python auf dem ioBroker Rechner?
                          Ich habe mir von ChatGPT ein Python Script erstellen lassen, welches history json-Daten in CSV und xls umwandelt. Ja, das kann dauern, aber mein ioBroker Laptop unter Win ist dadurch bisher noch nicht abgestürzt. Mag nicht die eleganteste Lösung sein, aber so oft brauche ich das ja nicht.

                          C 1 Reply Last reply Reply Quote 0
                          • C
                            chris299 @klassisch last edited by

                            @klassisch danke für den Hinweis. Könntest Du das script hier teilen?

                            K 1 Reply Last reply Reply Quote 0
                            • K
                              klassisch Most Active @chris299 last edited by

                              @chris299 Hier "as it is" Ein roher Klotz, no thrills, kein Komfort, keine Fehlerabfangen und für Windows-Verzeichnisse. Keine Ahnung wie man das auf Linux-Verzeichnisse umstellt. Aber auch da kann ChatGPT sicher helfen. Minimale Dialoge ohne Überprüfung.
                              Ein einigermassen aktuelles Python muß auf dem Rechner laufen (bei mir 3.10.8) und der Python Pfad sollte dem System bekannt sein.
                              Ich starte immer aus der Kommandozeile heraus (CMD), weil ich dann ggf Fehlermeldungen sehen. Bei mir aus einem Verzeichnis D:\auswerungen

                              Das Script heisst z.B.

                              iobroker-history-all-data-to-xls-V3-local-time.py
                              

                              dann starte ich es mit

                              python iobroker-history-all-data-to-xls-V3-local-time.py
                              

                              Es werden einige Pakete benötigt. Steht im Programm als Kommentar. Vielleicht brauchst Du bei Deiner Installation noch weitere. Dann kann man das den Fehlermeldungen entnehmen.
                              Kann am Anfang etwas Gefummel sein. ChatGPT kennt sich mit Python recht gut aus und hilft gerne - auch bei der Umstallung auf Linux, falls erforderlich 🙂

                              Ach ja, Python hat dieselbe Unart wie YAML. Man hat sich von Klammern als Strukturelement verabschiedet und nutzt stattdessen Einrücken. In Vielfachen von 4 Blanks.

                              Hier eine Sctript-Version für local time:

                              # created with the help of ChatGPT
                              # Install openpyxl library if necessary
                              # Make sure to install pandas using: pip install pandas
                              
                              import os
                              import json
                              import pandas as pd
                              from datetime import datetime
                              import pytz  # Make sure to install pytz using: pip install pytz
                              
                              def read_json_file(file_path):
                                  with open(file_path, 'r') as file:
                                      data = json.load(file)
                                  return data
                              
                              def extract_data_from_json(json_data):
                                  data_list = []
                                  for entry in json_data:
                                      if entry.get("val") is not None:
                                          val, ts = entry["val"], entry["ts"]
                                          data_list.append((val, ts))
                                  return data_list
                              
                              def convert_timestamp(ts):
                                  local_tz = pytz.timezone('Europe/Berlin')  # Adjust to your local time zone
                                  local_time = datetime.fromtimestamp(ts / 1000, local_tz)
                                  sample_date = local_time.strftime('%d.%m.%Y')
                                  sample_time = local_time.strftime('%H:%M')
                                  return sample_date, sample_time
                              
                              def generate_excel(start_date, end_date, iobroker_directory, filename_template, xls_directory, xls_name):
                                  # Prepare date range
                                  date_range = pd.date_range(start=start_date, end=end_date).strftime('%Y%m%d')
                              
                                  # Initialize lists to store data
                                  all_data = []
                              
                                  # Counter for monitoring output
                                  counter = 0
                                  dataset_counter = 0
                              
                                  # Display start and end dates
                                  print(f"Start Date: {start_date}")
                                  print(f"End Date: {end_date}")
                              
                                  # Show default values
                                  print(f"ioBroker history directory: {iobroker_directory}")
                                  print(f"ioBroker - Filename: {filename_template}")
                                  print(f"Directory for xls Output: {xls_directory}")
                                  print(f" ")
                                  
                                  # Get user-defined xls_name
                                  user_defined_xls_name = input("Enter the user-defined xls_name (default: 'ioBroker-history'): ") or 'ioBroker-history'
                                  print(f" ")
                                  print(f"Data will be collected from files")
                              
                              
                                  # Iterate through directories and files
                                  for date in date_range:
                                      directory_path = os.path.join(iobroker_directory, date)
                                      if os.path.exists(directory_path):
                                          for root, dirs, files in os.walk(directory_path):
                                              for file in files:
                                                  if file.startswith(filename_template) and file.endswith('.json'):
                                                      file_path = os.path.join(root, file)
                                                      json_data = read_json_file(file_path)
                                                      data_list = extract_data_from_json(json_data)
                                                      all_data.extend(data_list)
                                                      # Monitor progress
                                                      counter += 1
                                                      dataset_counter +=1
                                                      # print(f".", end="")
                                                      # Check if 8 entries are printed and start a new line
                                                      if counter % 150 == 0:
                                                          print(f" {dataset_counter}")
                              
                              
                                  # Convert data to DataFrame
                                  print(f"conversion ongoing, please wait")
                                  df = pd.DataFrame(all_data, columns=['Value', 'Timestamp'])
                              
                                  # Convert timestamp and add Date and Time columns
                                  df['Date'], df['Time'] = zip(*df['Timestamp'].apply(convert_timestamp))
                              
                                  # Replace dot with comma in the 'Value' column
                                  df['Value'] = df['Value'].astype(str).str.replace('.', ',')
                              
                                  # Create complete xls_name
                                  xls_name += f'-from-{start_date}-to-{end_date}.xlsx'
                                  xls_complete_name = user_defined_xls_name + xls_name
                                  csv_name = ""
                                  csv_name += f'-from-{start_date}-to-{end_date}.csv'
                                  csv_complete_name = user_defined_xls_name + csv_name
                              
                                  # Show complete path and file name
                                  output_path = os.path.join(xls_directory, xls_complete_name)
                                  output_path_csv = os.path.join(xls_directory, csv_complete_name)
                                  print(f"Location Excel File: {output_path}")
                                  print(f"Location CSV File: {output_path_csv}")
                              
                              
                                  # Save to CSV
                                  print(f"csv file will be created, please wait")    
                                  df.to_csv(output_path_csv, index=False)
                                  print(f"\nCSV file created: {output_path_csv}")
                              
                                  # Save to Excel
                                  print(f"xlsx file will be created, please wait")
                                  df.to_excel(output_path, index=False)
                                  print(f"\nExcel file created: {output_path}")
                              
                                  print(f"job done")
                              
                              # Get user input
                              print(f"Version 1.0 based on ChatGPT 3.5 with own debugs and mods")
                              start_date = input("Enter the start date (YYYYMMDD): ")
                              end_date = input("Enter the end date (YYYYMMDD): ")
                              iobroker_directory = input("ioBroker history directory (default: 'd:\\ioBroker-data\\History\\'): ") or 'd:\\ioBroker-data\\History\\'
                              filename_template = input("ioBroker json filename: (default: 'history.hm-rpc.1.CUX9000052.1.STATE.json'): ") or 'history.hm-rpc.1.CUX9000052.1.STATE.json'
                              xls_directory = input("Directory for xls Output (default: 'D:\\Auswertungen'): ") or 'D:\\Auswertungen'
                              
                              generate_excel(start_date, end_date, iobroker_directory, filename_template, xls_directory, '')
                              
                              

                              Viel Erfolg!

                              1 Reply Last reply Reply Quote 1
                              • First post
                                Last post

                              Support us

                              ioBroker
                              Community Adapters
                              Donate
                              FAQ Cloud / IOT
                              HowTo: Node.js-Update
                              HowTo: Backup/Restore
                              Downloads
                              BLOG

                              514
                              Online

                              31.6k
                              Users

                              79.5k
                              Topics

                              1.3m
                              Posts

                              csv history download
                              6
                              27
                              1878
                              Loading More Posts
                              • Oldest to Newest
                              • Newest to Oldest
                              • Most Votes
                              Reply
                              • Reply as topic
                              Log in to reply
                              Community
                              Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                              The ioBroker Community 2014-2023
                              logo