Klimalogg mit HTTPD bei Minusgraden

Begonnen von privat58, 26 März 2015, 07:52:49

Vorheriges Thema - Nächstes Thema

privat58

Hallo zusammen,
ich habe einen KlimaloggPro mit 8 Sensoren mit weewx am Raspberry angeschlossen. weewx schreibt die Werte aller Sensoren in eine txt Datei, die ich mit dem HTTPMOD Modul abhole.
Ich habe folgendes in der config stehen:

define KLIMALOGG HTTPMOD http://192.168.0.120/fhem1.txt 300
attr KLIMALOGG reading01Name TempStation
attr KLIMALOGG reading01Regex temp0: ([\d\.]+)
attr KLIMALOGG reading01Expr {sprintf("%.1f", $val)}

So habe ich alle Sensoren mit Temperatur, Luftfeuchte und Batterie eingebunden.
Bei Minusgraden werden im "buf" -Feld die negativen Werte dargestellt. Ich bekomme aber nur  die positiven Werte als Reading angezeigt. Die Werte stehen stehen z.Bsp. so "temp1: -1.57333333333" in der txt Datei und auch im "buf".

Kann mir jemand einen Tip geben, wie ich das attr KLIMALOGG reading01Expr ändern muss?
Dank an Euch im Voraus
Steffen

privat58

Hallo noch einmal,
ich komme nicht weiter, auch ein sprintf("% .1f") oder sprintf("%+.1f") funktioniert nicht.
Falls noch andere eine KlimaloggPro Anlage haben und Interesse besteht, kann ich die Sachen von weewx einmal zusammenschreiben und hier einstellen.
Steffen


justme1968

in der regex muss das negative vorzeichen mit berücksichtigt werden. z.b. so:
attr KLIMALOGG reading01Regex temp0: ([\d\.-]+)

gruss
  andre
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

privat58

Hallo Andre,

Dank an Dich, genau das war es. Jetzt kommen die Werte richtig. Ich war in der Annahme, das wenn die Werte im "buf" richtig stehen, dann mit dem attr reading01Expr geändert werden müssen.
Ich werde in den nächsten Tagen alles zusammenstellen und hier einstellen, dann kann es auch von Anderen genutzt werden.
Steffen

privat58

Wie versprochen habe ich einmal alles zusammengestellt und in ein zip getan.

Ich selber nutze den KlimaloggPro auf einem Raspberry2 (1Gb) mit lihgttpd, meine Daten und logs werden auf einen Stick geschrieben.
weewx ist eine eigenständige Software auf Pythonbasis für verschiedene Wetterstationen und bietet eine eigene Datenbank und Auswertung.
Es können die aktuellen Daten aller Sensoren, sowie der Taupunkt, die gefühlte Temperatur und min/max Werte ausgelesen werden.

1. weewx runterladen ( weewx.com ) und auf dem Rechner installieren.
2. weewx anhalten und die Dateien im Anhang nach Anleitung kopieren
3. Es muss in der weewx.config folgendes geändert werden
        location = "Stuttgart"    #trage ein was Du möchtest
        latitude = 12.478    #halt wo die Station wohnt
        longitude =  11.997
   # diesen Pfad nach eigenen Bedürfnissen anpassen oder erst einmal so lassen, diesen aber in der lighttp config angeben
       [[kl]]
        HTML_ROOT = public_html/kl   
        skin = kl
4. den Klimalogg in fhem definieren und den Pfad zur fhem.txt angeben

Seit der Änderung mit dem Minuszeichen habe ich keine Probleme mehr. Meine eigenen Linux- und Programmierkenntnisse sind minimal, so das ich bei speziellen Fragen keine große Hilfe sein werde. Eventuell hat auch ein Anderer Ideen, wie man es einfacher umsetzen kann.
Viel Spaß damit
Steffen



kaktus567

#5
@privat58: leider komme ich mit der weewx.conf nicht klar bzw. mit "weewx_kl-driver_instructions_v1-7.htm". Speziell Punkt 6. Könntest Du die weewx.conf zur Verfügung stellen ?  :-[

Leider funktioniert der Webserver auch nicht, trotz Anleitung http://www.weewx.com/docs/debian.htm

privat58

Hallo,
das Projekt wird von Luc weiterentwickelt und es stehen die Installationsdateien bei github.
https://github.com/matthewwall/weewx-klimalogg
Danach sollte weewx erst einmal seperat laufen. Das ganze muss dann noch für fhem angepasst werden.
In der Datei etc/weewx/skins/kl/skin.conf müssen folgende Zeilen ergänzt werden (ich habe das davor und danach mitkopiert, dann siehst Du es besser):[CheetahGenerator]
    encoding = html_entities    # 'html_entities', 'utf8', or 'strict_ascii'
    [[ToDate]]
        [[[index]]]
            template = index.html.tmpl

        #FHEM data
        [[[FHEM]]]
            template = fhem.txt.tmpl

[ImageGenerator]
    data_binding = kl_binding

Anschließend die Datei fhem.txt.tmpl nach etc/weewx/skins/kl kopieren. Die Datei hat folgenden Inhalt:#set $fhem_dateformat1 = "%Y%m%d%H%M"
time: $current.dateTime.format($fhem_dateformat1)
temp0: $current.temp0.degree_C.raw
temp0maxday: $day.temp0.max.raw
temp0minday: $day.temp0.min.raw
temp0maxmonth: $month.temp0.max.raw
temp0minmonth: $month.temp0.min.raw
temp0maxyear: $year.temp0.max.raw
temp0minyear: $year.temp0.min.raw
dewpoint0: $current.dewpoint0.formatted
temp1: $current.temp1.degree_C.raw
temp1maxday: $day.temp1.max.raw
temp1minday: $day.temp1.min.raw
temp1maxmonth: $month.temp1.max.raw
temp1minmonth: $month.temp1.min.raw
temp1maxyear: $year.temp1.max.raw
temp1minyear: $year.temp1.min.raw
temp2: $current.temp2.degree_C.raw
temp2maxday: $day.temp2.max.raw
temp2minday: $day.temp2.min.raw
temp2maxmonth: $month.temp2.max.raw
temp2minmonth: $month.temp2.min.raw
temp2maxyear: $year.temp2.max.raw
temp2minyear: $year.temp2.min.raw
temp3: $current.temp3.degree_C.raw
temp3maxday: $day.temp3.max.raw
temp3minday: $day.temp3.min.raw
temp3maxmonth: $month.temp3.max.raw
temp3minmonth: $month.temp3.min.raw
temp3maxyear: $year.temp3.max.raw
temp3minyear: $year.temp3.min.raw
temp4: $current.temp4.degree_C.raw
temp4maxday: $day.temp4.max.raw
temp4minday: $day.temp4.min.raw
temp4maxmonth: $month.temp4.max.raw
temp4minmonth: $month.temp4.min.raw
temp4maxyear: $year.temp4.max.raw
temp4minyear: $year.temp4.min.raw
temp5: $current.temp5.degree_C.raw
temp5maxday: $day.temp5.max.raw
temp5minday: $day.temp5.min.raw
temp5maxmonth: $month.temp5.max.raw
temp5minmonth: $month.temp5.min.raw
temp5maxyear: $year.temp5.max.raw
temp5minyear: $year.temp5.min.raw
temp6: $current.temp6.degree_C.raw
temp6maxday: $day.temp6.max.raw
temp6minday: $day.temp6.min.raw
temp6maxmonth: $month.temp6.max.raw
temp6minmonth: $month.temp6.min.raw
temp6maxyear: $year.temp6.max.raw
temp6minyear: $year.temp6.min.raw
temp7: $current.temp7.degree_C.raw
temp7maxday: $day.temp7.max.raw
temp7minday: $day.temp7.min.raw
temp7maxmonth: $month.temp7.max.raw
temp7minmonth: $month.temp7.min.raw
temp7maxyear: $year.temp7.max.raw
temp7minyear: $year.temp7.min.raw
temp8: $current.temp8.degree_C.raw
temp8maxday: $day.temp8.max.raw
temp8minday: $day.temp8.min.raw
temp8maxmonth: $month.temp8.max.raw
temp8minmonth: $month.temp8.min.raw
temp8maxyear: $year.temp8.max.raw
temp8minyear: $year.temp8.min.raw
hum0: $current.humidity0.formatted
hum1: $current.humidity1.formatted
hum2: $current.humidity2.formatted
hum3: $current.humidity3.formatted
hum4: $current.humidity4.formatted
hum5: $current.humidity5.formatted
hum6: $current.humidity6.formatted
hum7: $current.humidity7.formatted
hum8: $current.humidity8.formatted
heatindex0: $current.heatindex0.raw
heatindex1: $current.heatindex1.raw
heatindex2: $current.heatindex2.raw
heatindex3: $current.heatindex3.raw
heatindex4: $current.heatindex4.raw
heatindex5: $current.heatindex5.raw
heatindex6: $current.heatindex6.raw
heatindex7: $current.heatindex7.raw
heatindex8: $current.heatindex8.raw
dewpoint0: $current.dewpoint0.raw
dewpoint1: $current.dewpoint1.raw
dewpoint2: $current.dewpoint2.raw
dewpoint3: $current.dewpoint3.raw
dewpoint4: $current.dewpoint4.raw
dewpoint5: $current.dewpoint5.raw
dewpoint6: $current.dewpoint6.raw
dewpoint7: $current.dewpoint7.raw
dewpoint8: $current.dewpoint8.raw
batt0: $current.batteryStatus0.raw
batt1: $current.batteryStatus1.raw
batt2: $current.batteryStatus2.raw
batt3: $current.batteryStatus3.raw
batt4: $current.batteryStatus4.raw
batt5: $current.batteryStatus5.raw
batt6: $current.batteryStatus6.raw
batt7: $current.batteryStatus7.raw
batt8: $current.batteryStatus8.raw
signalquality: $current.rxCheckPercent.formatted


Die weewx.conf an Deine Bedürfnisse anpassen.
# WEEWX CONFIGURATION FILE
#
# Copyright (c) 2009-2015 Tom Keffer <tkeffer@gmail.com>
# See the file LICENSE.txt for your rights.

##############################################################################

# This section is for general configuration information.

# Set to 1 for extra debug info, otherwise comment it out or set to zero
debug = 0

# Root directory of the weewx data file hierarchy for this station
WEEWX_ROOT = /

# How long to wait before timing out a socket (FTP, HTTP) connection
socket_timeout = 20

# Do not modify this. It is used when installing and updating weewx.
version = 3.3.1

##############################################################################

#   This section is for information about the station.

[Station]
   
    # Description of the station location
    location = Name #anpassen
   
    # Latitude and longitude in decimal degrees
    latitude = 12.345 #anpassen
    longitude = 12.345 #anpassen
   
    # Altitude of the station, with unit it is in. This is downloaded from
    # from the station if the hardware supports it.
    altitude = 123, meter #anpassen
   
    # Set to type of station hardware. There must be a corresponding stanza
    # in this file with a 'driver' parameter indicating the driver to be used.
    station_type = KlimaLogg
   
    # If you have a website, you may specify an URL
    #station_url = http://www.example.com
   
    # The start of the rain year (1=January; 10=October, etc.). This is
    # downloaded from the station if the hardware supports it.
    rain_year_start = 1
   
    # Start of week (0=Monday, 6=Sunday)
    week_start = 0

##############################################################################

#   This section is for uploading data to Internet sites

[StdRESTful]
   
    [[StationRegistry]]
        # To register this weather station with weewx, set this to true
        register_this_station = false
   
    [[AWEKAS]]
        # This section is for configuring posts to AWEKAS.
       
        # If you wish to do this, set the option 'enable' to true,
        # and specify a username and password.
        enable = false
        username = replace_me
        password = replace_me
   
    [[CWOP]]
        # This section is for configuring posts to CWOP.
       
        # If you wish to do this, set the option 'enable' to true,
        # and specify the station ID (e.g., CW1234).
        enable = false
        station = replace_me
   
    # If this is an APRS (radio amateur) station, uncomment
    # the following and replace with a passcode (e.g., 12345).
    #passcode = replace_me (APRS stations only)
   
    [[PWSweather]]
        # This section is for configuring posts to PWSweather.com.
       
        # If you wish to do this, set the option 'enable' to true,
        # and specify a station and password.
        enable = false
        station = replace_me
        password = replace_me
   
    [[WOW]]
        # This section is for configuring posts to WOW.
       
        # If you wish to do this, set the option 'enable' to true,
        # and specify a station and password.
        enable = false
        station = replace_me
        password = replace_me
   
    [[Wunderground]]
        # This section is for configuring posts to the Weather Underground.
       
        # If you wish to do this, set the option 'enable' to true,
        # and specify a station (e.g., 'KORHOODR3') and password.
        enable = false
        station = replace_me
        password = replace_me
       
        # Set the following to True to have weewx use the WU "Rapidfire"
        # protocol. Not all hardware can support it. See the User's Guide.
        rapidfire = False

##############################################################################

#   This section specifies what reports, using which skins, to generate.

[StdReport]
   
    # Where the skins reside, relative to WEEWX_ROOT
    SKIN_ROOT = /etc/weewx/skins
   
    # Where the generated reports should go, relative to WEEWX_ROOT
    HTML_ROOT = /var/www/weewx
   
    # The database binding indicates which data should be used in reports.
    data_binding = kl_binding
   
    # Each of the following subsections defines a report that will be run.
   
    [[StandardReport]]
        # See the customizing guide to change the units, plot types and line
        # colors, modify the fonts, display additional sensor data, and other
        # customizations. Many of those changes can be made here by overriding
        # parameters, or by modifying templates within the skin itself.
       
        # The StandardReport uses the 'Standard' skin, which contains the
        # images, templates and plots for the report.
        #skin = Standard
skin = kl

        [[[Units]]]
            [[[[Groups]]]]
                group_altitude = meter
                group_speed2 = meter_per_second2
                group_pressure = mbar
                group_rain = mm
                group_rainrate = mm_per_hour
                group_temperature = degree_C
                group_degree_day = degree_C_day
                group_speed = meter_per_second
   
    [[FTP]]
        # FTP'ing the results to a webserver is treated as just another report,
        # albeit one with an unusual report generator!
        skin = Ftp
       
        # If you wish to use FTP, uncomment and fill out the next four lines.
        #user = replace with the ftp username
        #password = replace with the ftp password
        #server = replace with the ftp server name, e.g, www.threefools.org
        #path = replace with the ftp destination directory (e.g., /weather)
       
        # Set to True for a secure FTP (SFTP) connection. Not all servers
        # support this.
        secure_ftp = False
       
        # To upload files from something other than what HTML_ROOT is set
        # to above, specify a different HTML_ROOT here.
        #HTML_ROOT = /var/www/weewx
       
        # Most FTP servers use port 21
        port = 21
       
        # Set to 1 to use passive mode, zero for active mode
        passive = 1
   
    [[RSYNC]]
        # rsync'ing to a webserver is treated as just another report
        skin = Rsync
       
        # If you wish to use rsync, you must configure passwordless ssh using
        # public/private key authentication from the user account that weewx
        # runs as to the user account on the remote machine where the files
        # will be copied.
        #
        # The following three lines determine where files will be sent.
        #server = replace with the rsync server name, e.g, www.threefools.org
        #path = replace with the rsync destination directory (e.g., /weather)
        #user = replace with the rsync username
       
        # Rsync can be configured to remove files from the remote server if
        # they don't exist under HTML_ROOT locally. USE WITH CAUTION: if you
        # make a mistake in the remote path, you could could unintentionally
        # cause unrelated files to be deleted. Set to 1 to enable remote file
        # deletion, zero to allow files to accumulate remotely.
        delete = 0

     [[kl]]
       
        HTML_ROOT = ./var/www/weewx/kl  #public_html/kl
        skin = kl

##############################################################################

#   This service acts as a filter, converting the unit system coming from
#   the hardware to a unit system in the database.

[StdConvert]
   
    # The target_unit affects only the unit system in the database. Once
    # chosen it cannot be changed without converting the entire database.
    # Modification of target_unit after starting weewx will result in
    # corrupt data - the database will contain a mix of US and METRIC data.
    #
    # The value of target_unit does not affect the unit system for
    # reporting - reports can display US, Metric, or any combination of units.
    #
    # In most cases, target_unit should be left as the default: US
    #
    # In particular, those migrating from a standard wview installation
    # should use US since that is what the wview database contains.
   
    # DO NOT MODIFY THIS VALUE UNLESS YOU KNOW WHAT YOU ARE DOING!
    target_unit = METRIC    # Options are 'US', 'METRICWX', or 'METRIC'

##############################################################################

#   This section can adjust data using calibration expressions.

[StdCalibrate]
   
    [[Corrections]]
        # For each type, an arbitrary calibration expression can be given.
        # It should be in the units defined in the StdConvert section.
        # Example:
        foo = foo + 0.2

##############################################################################

#   This section is for quality control checks. If units are not specified,
#   values must be in the units defined in the StdConvert section.

[StdQC]
   
    [[MinMax]]
        barometer = 26, 32.5, inHg
        outTemp = -40, 120, degree_F
        inTemp = 10, 120, degree_F
        outHumidity = 0, 100
        inHumidity = 0, 100
        windSpeed = 0, 120, mile_per_hour

##############################################################################

#   This section controls the origin of derived values.

[StdWXCalculate]
    # Derived quantities are calculated by this service. Possible values are:
    #  hardware        - use the value provided by hardware
    #  software        - use the value calculated by weewx
    #  prefer_hardware - use value provide by hardware if available,
    #                      otherwise use value calculated by weewx
   
    pressure = prefer_hardware
    barometer = prefer_hardware
    altimeter = prefer_hardware
    windchill = prefer_hardware
    heatindex = prefer_hardware
    dewpoint = prefer_hardware
    inDewpoint = prefer_hardware
    rainRate = prefer_hardware

##############################################################################

#   For hardware that supports it, this section controls how often the
#   onboard clock gets updated.

[StdTimeSynch]
   
    # How often to check the weather station clock for drift (in seconds)
    clock_check = 14400
   
    # How much it can drift before we will correct it (in seconds)
    max_drift = 5

##############################################################################

#   This section is for configuring the archive service.

[StdArchive]
   
    # If the station hardware supports data logging then the archive interval
    # will be downloaded from the station. Otherwise, specify it (in seconds).
    archive_interval = 300
   
    # How long to wait (in seconds) before processing new archive data. Must
    # be greater than zero.
    archive_delay = 15
   
    # If possible, new archive records are downloaded from the station
    # hardware. If the hardware does not support this, then new archive
    # records will be generated in software.
    # Set the following to "software" to force software record generation.
    record_generation = hardware
   
    # Whether to include LOOP data in hi/low statistics
    loop_hilo = True
   
    # The data binding used to save archive records
    data_binding = kl_binding

##############################################################################

#   This section binds a data store to a database.

[DataBindings]
   
    [[wx_binding]]
        # The database must match one of the sections in [Databases].
        # This is likely to be the only option you would want to change.
        database = archive_sqlite
        # The name of the table within the database
        table_name = archive
        # The manager handles aggregation of data for historical summaries
        manager = weewx.wxmanager.WXDaySummaryManager
        # The schema defines the structure of the database.
        # It is *only* used when the database is created.
        schema = schemas.wview.schema
    [[kl_binding]]
        manager = weewx.wxmanager.WXDaySummaryManager
        database = archive_sqlite
        table_name = archive
        schema = user.kl.schema

##############################################################################

#   This section defines various databases.

[Databases]
   
    # A SQLite database is simply a single file
    [[archive_sqlite]]
        database_type = SQLite
        database_name = weewx.sdb
   
    # MySQL
    [[archive_mysql]]
        database_type = MySQL
        database_name = weewx

##############################################################################

#   This section defines defaults for the different types of databases.

[DatabaseTypes]
   
    # Defaults for SQLite databases
    [[SQLite]]
        driver = weedb.sqlite
        # Directory in which the database files are located
        SQLITE_ROOT = /opt/fhem/weewx
#/var/lib/weewx
   
    # Defaults for MySQL databases
    [[MySQL]]
        driver = weedb.mysql
        # The host where the database is located
        host = localhost
        # The user name for logging in to the host
        user = weewx
        # The password for the user name
        password = weewx

##############################################################################

#   This section configures the internal weewx engine.

[Engine]
   
    [[Services]]
        # This section specifies the services that should be run. They are
        # grouped by type, and the order of services within each group
        # determines the order in which the services will be run.
        prep_services = weewx.engine.StdTimeSynch
        data_services = ,
        process_services = weewx.engine.StdConvert, weewx.engine.StdCalibrate, weewx.engine.StdQC, weewx.wxservices.StdWXCalculate
        archive_services = weewx.engine.StdArchive
        restful_services = weewx.restx.StdStationRegistry, weewx.restx.StdWunderground, weewx.restx.StdPWSweather, weewx.restx.StdCWOP, weewx.restx.StdWOW, weewx.restx.StdAWEKAS
        report_services = weewx.engine.StdPrint, weewx.engine.StdReport

##############################################################################

[KlimaLogg]
    # This section is for the TFA KlimaLogg series of weather stations.
   
    # Radio frequency to use between USB transceiver and console: US or EU
    # US uses 915 MHz, EU uses 868.3 MHz.  Default is EU.
    transceiver_frequency = EU
   
    # The station model, e.g., 'TFA KlimaLoggPro' or 'TFA KlimaLogg'
    model = TFA KlimaLogg
   
    # The driver to use:
    driver = user.kl
   
    # debug flags:
    #  0=no logging; 1=minimum logging; 2=normal logging; 3=detailed logging
    # Don't forget to set debug flags to 0 when finished testing!
    debug_comm = 0
    debug_config_data = 0  #1
    debug_weather_data = 0 #1
    debug_history_data = 0 #1
    debug_dump_format = 0 #auto
   
    # The serial number will be used to choose the right Weather Display Transceiver when more than one is present.
    # TIP: when the serial number of a transceiver is not known yet, remove temporary the other transceiver from
    # your server and start the driver without the serial number setting; the serial number and devid will be
    # presented in the debug logging.
    # USB transceiver Kat.Nr.: 30.3175  05/2014
    # serial = 010128031400117  # devid = 0x0075
   
    # logger_channel = 1
    # polling_interval = 10
    # comm_interval = 8
   
    # The catchup mechanism will catchup history records to a maximum of limit_rec_read_to [0 .. 51200]
    # limit_rec_read_to = 300 #range [0..51200]
   
    # Sensor texts can have 1-10 upper-case alphanumeric characters;
    #   other allowed characters: space - + ( ) * , . / \ and o (o = lower case O used as degree symbol)
    # Note: You can't preset sensor texts for non-present sensors
    # Example preset of sensor texts:
    # sensor_text1 = "5565 BED1"
    # sensor_text2 = "6DDF LAUN"
    # sensor_text3 = "7131 FRID"
    # sensor_text4 = "52F4 KID1"
    # sensor_text5 = "67D7 BATH"
    # sensor_text6 = "3731 KID2"
    # sensor_text7 = "76F4 STUD"
    # sensor_text8 = "25D7 GARA"
   
    # Preset sensor_map_id
    sensor_map_id = 0    #  0 = KL_SENSOR_MAP, 1 = WVIEW_SENSOR_MAP

Bitte die Daten für Deinen Standort anpassen. Die Datenbank lasse ich in das fhem-Verzeichniss schreiben, damit diese bei einem fhem-backup mitgesichert wird.

Lion

#7
Hallo Steffen,

ich finde das Thema hier mal in Deutsch klasse. Evtl. kannst du mir auf die Sprünge helfen? Du hast das ja schon so wie ich es will am Laufen.

Ich habe viele Postings von Luc und Matthew zu Thema TFA KlimaLoggPro und weewx gelesen, und auch alles soweit umgesetzt.

Aber es will nicht klappen, ich scheitere schon an der Kopplung. Muss man wirklich erst um 0 Uhr am Rechner sitzen und weewx starten um zu syncen? Bisher ist der Dongle noch mit einem Windowstablet gekoppelt. Wenn ich ihn derzeit wieder an das Windowstablet stecke geht es dort auch wieder sofort. D.H. er will seine Kopplung zum alten Windowstablet nicht vergessen.

Da ich das auf einem meiner fhem raspis einsetzen möchte, habe ich mir erstmal eine Debian VM eingerichtet und versuche dort weewx ans Laufen zu bekommen. Nachfolgend etwas dazu aus meinem syslog:

Mar 19 14:27:05 debian2 weewx[3968]: Stopping weewx weather system: weewx not running....
Mar 19 14:27:09 debian2 weewx[4016]: engine: Initializing weewx version 3.5.0
Mar 19 14:27:09 debian2 weewx[4016]: engine: Using Python 2.7.9 (default, Mar  1 2015, 12:57:24) #012[GCC 4.9.2]
Mar 19 14:27:09 debian2 weewx[4016]: engine: Platform Linux-3.16.0-4-amd64-x86_64-with-debian-8.3
Mar 19 14:27:09 debian2 weewx[4016]: engine: pid file is /var/run/weewx.pid
Mar 19 14:27:09 debian2 weewx[4007]: Starting weewx weather system: weewx.
Mar 19 14:27:09 debian2 weewx[4020]: engine: Using configuration file /etc/weewx/weewx.conf
Mar 19 14:27:09 debian2 weewx[4020]: engine: Initializing engine
Mar 19 14:27:09 debian2 weewx[4020]: engine: Loading station type KlimaLogg (user.kl)
Mar 19 14:27:09 debian2 weewx[4020]: KlimaLogg: MainThread: driver version is 1.1.7
Mar 19 14:27:09 debian2 weewx[4020]: KlimaLogg: MainThread: frequency is EU
Mar 19 14:27:09 debian2 weewx[4020]: KlimaLogg: MainThread: using sensor map for kl schema
Mar 19 14:27:09 debian2 weewx[4020]: KlimaLogg: MainThread: catchup limited to 51200 records
Mar 19 14:27:09 debian2 weewx[4020]: KlimaLogg: MainThread: timing is 300 ms (0.300 s)
Mar 19 14:27:09 debian2 weewx[4020]: KlimaLogg: MainThread: CommunicationService.init
Mar 19 14:27:09 debian2 weewx[4020]: KlimaLogg: MainThread: comm_interval is 8
Mar 19 14:27:09 debian2 weewx[4020]: KlimaLogg: MainThread: logger_channel is 1
Mar 19 14:27:09 debian2 weewx[4020]: KlimaLogg: MainThread: found transceiver at bus=001 device=004
Mar 19 14:27:10 debian2 kernel: [ 9902.070220] usb 1-2.1: usbfs: USBDEVFS_CONTROL failed cmd python rqt 128 rq 6 len 255 ret -110
Mar 19 14:27:10 debian2 weewx[4020]: engine: Unable to load driver: error sending control message: Die Wartezeit für die Verbindung ist abgelaufen
Mar 19 14:27:10 debian2 weewx[4020]:     ****  Exiting...


weewx.conf # WEEWX CONFIGURATION FILE
#
# Copyright (c) 2009-2015 Tom Keffer <tkeffer@gmail.com>
# See the file LICENSE.txt for your rights.

##############################################################################

# This section is for general configuration information.

# Set to 1 for extra debug info, otherwise comment it out or set to zero
debug = 1

# Root directory of the weewx data file hierarchy for this station
WEEWX_ROOT = /

# How long to wait before timing out a socket (FTP, HTTP) connection
socket_timeout = 20

# Do not modify this. It is used when installing and updating weewx.
version = 3.5.0

##############################################################################

#   This section is for information about the station.

[Station]
   
    # Description of the station location
    location = "Santa's Workshop, North Pole"
   
    # Latitude and longitude in decimal degrees
   
    # Altitude of the station, with unit it is in. This is downloaded from
    # from the station if the hardware supports it.
    altitude = 0, meter
   
    # Set to type of station hardware. There must be a corresponding stanza
    # in this file with a 'driver' parameter indicating the driver to be used.
    station_type = KlimaLogg
   
    # If you have a website, you may specify an URL
    #station_url = http://www.example.com
   
    # The start of the rain year (1=January; 10=October, etc.). This is
    # downloaded from the station if the hardware supports it.
    rain_year_start = 1
   
    # Start of week (0=Monday, 6=Sunday)
    week_start = 6

##############################################################################

#   This section is for uploading data to Internet sites

[StdRESTful]
   
    [[StationRegistry]]
        # To register this weather station with weewx, set this to true
        register_this_station = false
   
    [[AWEKAS]]
        # This section is for configuring posts to AWEKAS.
       
        # If you wish to do this, set the option 'enable' to true,
        # and specify a username and password.
        enable = false
        username = replace_me
        password = replace_me
   
    [[CWOP]]
        # This section is for configuring posts to CWOP.
       
        # If you wish to do this, set the option 'enable' to true,
        # and specify the station ID (e.g., CW1234).
        enable = false
        station = replace_me
   
    # If this is an APRS (radio amateur) station, uncomment
    # the following and replace with a passcode (e.g., 12345).
    #passcode = replace_me (APRS stations only)
   
    [[PWSweather]]
        # This section is for configuring posts to PWSweather.com.
       
        # If you wish to do this, set the option 'enable' to true,
        # and specify a station and password.
        enable = false
        station = replace_me
        password = replace_me
   
    [[WOW]]
        # This section is for configuring posts to WOW.
       
        # If you wish to do this, set the option 'enable' to true,
        # and specify a station and password.
        enable = false
        station = replace_me
        password = replace_me
   
    [[Wunderground]]
        # This section is for configuring posts to the Weather Underground.
       
        # If you wish to do this, set the option 'enable' to true,
        # and specify a station (e.g., 'KORHOODR3') and password.
        enable = false
        station = replace_me
        password = replace_me
       
        # Set the following to True to have weewx use the WU "Rapidfire"
        # protocol. Not all hardware can support it. See the User's Guide.
        rapidfire = False

##############################################################################

#   This section specifies what reports, using which skins, to generate.

[StdReport]
   
    # Where the skins reside, relative to WEEWX_ROOT
    SKIN_ROOT = /etc/weewx/skins
   
    # Where the generated reports should go, relative to WEEWX_ROOT
    HTML_ROOT = /var/www/weewx
   
    # The database binding indicates which data should be used in reports.
    data_binding = kl_binding
   
    # Each of the following subsections defines a report that will be run.
   
    [[kl]]
        HTML_ROOT = /var/www/weewx/kl
        skin = kl

    [[FTP]]
        # FTP'ing the results to a webserver is treated as just another report,
        # albeit one with an unusual report generator!
        skin = Ftp
       
        # If you wish to use FTP, uncomment and fill out the next four lines.
        #user = replace with the ftp username
        #password = replace with the ftp password
        #server = replace with the ftp server name, e.g, www.threefools.org
        #path = replace with the ftp destination directory (e.g., /weather)
       
        # Set to True for a secure FTP (SFTP) connection. Not all servers
        # support this.
        secure_ftp = False
       
        # To upload files from something other than what HTML_ROOT is set
        # to above, specify a different HTML_ROOT here.
        #HTML_ROOT = /var/www/weewx
       
        # Most FTP servers use port 21
        port = 21
       
        # Set to 1 to use passive mode, zero for active mode
        passive = 1
   
    [[RSYNC]]
        # rsync'ing to a webserver is treated as just another report
        skin = Rsync
       
        # If you wish to use rsync, you must configure passwordless ssh using
        # public/private key authentication from the user account that weewx
        # runs as to the user account on the remote machine where the files
        # will be copied.
        #
        # The following three lines determine where files will be sent.
        #server = replace with the rsync server name, e.g, www.threefools.org
        #path = replace with the rsync destination directory (e.g., /weather)
        #user = replace with the rsync username
       
        # Rsync can be configured to remove files from the remote server if
        # they don't exist under HTML_ROOT locally. USE WITH CAUTION: if you
        # make a mistake in the remote path, you could could unintentionally
        # cause unrelated files to be deleted. Set to 1 to enable remote file
        # deletion, zero to allow files to accumulate remotely.
        delete = 0

##############################################################################

#   This service acts as a filter, converting the unit system coming from
#   the hardware to a unit system in the database.

[StdConvert]
   
    # The target_unit affects only the unit system in the database. Once
    # chosen it cannot be changed without converting the entire database.
    # Modification of target_unit after starting weewx will result in
    # corrupt data - the database will contain a mix of US and METRIC data.
    #
    # The value of target_unit does not affect the unit system for
    # reporting - reports can display US, Metric, or any combination of units.
    #
    # In most cases, target_unit should be left as the default: US
    #
    # In particular, those migrating from a standard wview installation
    # should use US since that is what the wview database contains.
   
    # DO NOT MODIFY THIS VALUE UNLESS YOU KNOW WHAT YOU ARE DOING!
    target_unit = METRIC    # Options are 'US', 'METRICWX', or 'METRIC'

##############################################################################

#   This section can adjust data using calibration expressions.

[StdCalibrate]
   
    [[Corrections]]
        # For each type, an arbitrary calibration expression can be given.
        # It should be in the units defined in the StdConvert section.
        # Example:
        foo = foo + 0.2

##############################################################################

#   This section is for quality control checks. If units are not specified,
#   values must be in the units defined in the StdConvert section.

[StdQC]
   
    [[MinMax]]
        barometer = 26, 32.5, inHg
        outTemp = -40, 120, degree_F
        inTemp = 10, 120, degree_F
        outHumidity = 0, 100
        inHumidity = 0, 100
        windSpeed = 0, 120, mile_per_hour
        pressure = 24, 34.5, inHg

##############################################################################

#   This section controls the origin of derived values.

[StdWXCalculate]
    # Derived quantities are calculated by this service. Possible values are:
    #  hardware        - use the value provided by hardware
    #  software        - use the value calculated by weewx
    #  prefer_hardware - use value provide by hardware if available,
    #                      otherwise use value calculated by weewx
   
    pressure = prefer_hardware
    barometer = prefer_hardware
    altimeter = prefer_hardware
    windchill = prefer_hardware
    heatindex = prefer_hardware
    dewpoint = prefer_hardware
    inDewpoint = prefer_hardware
    rainRate = prefer_hardware

##############################################################################

#   For hardware that supports it, this section controls how often the
#   onboard clock gets updated.

[StdTimeSynch]
   
    # How often to check the weather station clock for drift (in seconds)
    clock_check = 14400
   
    # How much it can drift before we will correct it (in seconds)
    max_drift = 5

##############################################################################

#   This section is for configuring the archive service.

[StdArchive]
   
    # If the station hardware supports data logging then the archive interval
    # will be downloaded from the station. Otherwise, specify it (in seconds).
    archive_interval = 300
   
    # How long to wait (in seconds) before processing new archive data. Must
    # be greater than zero.
    archive_delay = 15
   
    # If possible, new archive records are downloaded from the station
    # hardware. If the hardware does not support this, then new archive
    # records will be generated in software.
    # Set the following to "software" to force software record generation.
    record_generation = hardware
   
    # Whether to include LOOP data in hi/low statistics
    loop_hilo = True
   
    # The data binding used to save archive records
    data_binding = kl_binding

##############################################################################

#   This section binds a data store to a database.

[DataBindings]
   
    [[wx_binding]]
        # The database must match one of the sections in [Databases].
        # This is likely to be the only option you would want to change.
        database = archive_sqlite
        # The name of the table within the database
        table_name = archive
        # The manager handles aggregation of data for historical summaries
        manager = weewx.wxmanager.WXDaySummaryManager
        # The schema defines the structure of the database.
        # It is *only* used when the database is created.
        schema = schemas.wview.schema
    [[kl_binding]]
        manager = weewx.wxmanager.WXDaySummaryManager
        database = archive_sqlite
        table_name = archive
        schema = user.kl.schema

##############################################################################

#   This section defines various databases.

[Databases]
   
    # A SQLite database is simply a single file
    [[archive_sqlite]]
        database_type = SQLite
        database_name = weewx.sdb
   
    # MySQL
    [[archive_mysql]]
        database_type = MySQL
        database_name = weewx

##############################################################################

#   This section defines defaults for the different types of databases.

[DatabaseTypes]
   
    # Defaults for SQLite databases
    [[SQLite]]
        driver = weedb.sqlite
        # Directory in which the database files are located
SQLITE_ROOT =/opt/fhem/weewx
#SQLITE_ROOT = /var/lib/weewx
   
    # Defaults for MySQL databases
    [[MySQL]]
        driver = weedb.mysql
        # The host where the database is located
        host = localhost
        # The user name for logging in to the host
        user = weewx
        # The password for the user name
        password = weewx

##############################################################################

#   This section configures the internal weewx engine.

[Engine]
   
    [[Services]]
        # This section specifies the services that should be run. They are
        # grouped by type, and the order of services within each group
        # determines the order in which the services will be run.
        prep_services = weewx.engine.StdTimeSynch
        data_services = ,
        process_services = weewx.engine.StdConvert, weewx.engine.StdCalibrate, weewx.engine.StdQC, weewx.wxservices.StdWXCalculate
        archive_services = weewx.engine.StdArchive
        restful_services = weewx.restx.StdStationRegistry, weewx.restx.StdWunderground, weewx.restx.StdPWSweather, weewx.restx.StdCWOP, weewx.restx.StdWOW, weewx.restx.StdAWEKAS
        report_services = weewx.engine.StdPrint, weewx.engine.StdReport

##############################################################################

[KlimaLogg]
    # This section is for the TFA KlimaLogg series of weather stations.
   
    # Radio frequency to use between USB transceiver and console: US or EU
    # US uses 915 MHz, EU uses 868.3 MHz.  Default is EU.
    transceiver_frequency = EU
   
    # The station model, e.g., 'TFA KlimaLoggPro' or 'TFA KlimaLogg'
    model = TFA KlimaLoggPro
   
    # The driver to use:
    driver = user.kl
   
    # debug flags:
    #  0=no logging; 1=minimum logging; 2=normal logging; 3=detailed logging
    # Don't forget to set debug flags to 0 when finished testing!
    debug_comm = 1
    debug_config_data = 1
    debug_weather_data = 1
    debug_history_data = 1
    debug_dump_format = auto
   
    # The serial number will be used to choose the right Weather Display Transceiver when more than one is present.
    # TIP: when the serial number of a transceiver is not known yet, remove temporary the other transceiver from
    # your server and start the driver without the serial number setting; the serial number and devid will be
    # presented in the debug logging.
    # USB transceiver Kat.Nr.: 30.3175  05/2014
    # serial = 010128031400117  # devid = 0x0075
   
     logger_channel = 1
     polling_interval = 10
     comm_interval = 8
   
    # The catchup mechanism will catchup history records to a maximum of limit_rec_read_to [0 .. 51200]
    # limit_rec_read_to = 300 #range [0..51200]
   
    # Sensor texts can have 1-10 upper-case alphanumeric characters;
    #   other allowed characters: space - + ( ) * , . / \ and o (o = lower case O used as degree symbol)
    # Note: You can't preset sensor texts for non-present sensors
    # Example preset of sensor texts:
     sensor_text1 = "2515 WOHN"
     sensor_text2 = "2529 DRAU"
     sensor_text3 = "2580 KELL"
     sensor_text4 = "251A VRAU"
     sensor_text5 = "2510 BATH"
     sensor_text6 = "2608 KUEC"
     sensor_text7 = "250B SCHL"
     sensor_text8 = "2596 DACH"
   
    # Preset sensor_map_id
    sensor_map_id = 0    #  0 = KL_SENSOR_MAP, 1 = WVIEW_SENSOR_MAP


Vielen Dank

Lion


privat58

Hallo Lion,
wenn weewx startet, musst Du die USB-Taste am KlimaloggPro drücken, damit eine Verbindung hergestellt werden kann. Wenn das USB-Symbol erscheint, ist eine Verbindung aufgebaut. Weewx liest dann den Speicher aus und kümmert sich um die Uhrzeit.
Es ist Dir überlassen, ob Du es 0Uhr machst oder eher oder später.
:-)

Lion

Danke für deine Antwort.

Jedoch bleibt usbfs: USBDEVFS_CONTROL failed.

Ich werde versuchen Luc zu erreichen.

privat58

Eventuell liegt es an Deiner VM. Wird denn der Empfänger in der VM erkannt? Richte doch den Raspi schnell ein, da Du eh mit fhem spielen möchtest.
Du hast PM.
Steffen

Lion

Ich habe 3 Pi 3 und spreche mit denen nur über WLAN (weil die schon in den Verteilern der Fußbodenheizung mit bis zu 12 Temperaturfühlern (1wire ftw) wohnen) dort will ich das erst implementieren wenn das funktioniert. Da ich nicht so klein wie mein Sohn bin, komme ich da nur sehr schwer hin. da macht ausprobieren keinen Spaß. Mal schauen ob ich Antwort bekomme. Dann melde ich mich was draus geworden ist, bzw. woran es gelegen hat.

Lion

Lion

Ich habe weewx nun doch mal auf dem pi direkt angebunden, und da ich diesmal apt-get -fy install nicht vergessen habe, klappt es sofort.

Dann habe ich mir dir Datenbankdatei mal angeschaut und ein kleines Modul geschrieben welches die Daten direkt aus der Datenbank holt. Ohne Umweg über Textdatei usw.

Bitte schaut euch das mal an ob ich da ganz arge Fehler drin hab. Basis dafür war GPIO4. Hab ich eigentlich schon gesagt wie genial fhem ist! Ich bräuchte mindestens einen Tip wie ich evtl. Connectionprobleme in den fhemlog schubse und wie ich das Modul nennen sollte, da ich denke das 99_KLW ungeschickt ist, ich würde es mindestens 98_KLW nennen wollen, aber ich hab die Nummerierung noch nicht durchschaut. Gerne dürft ihr den Beitrag auch in anderen Forumsteilen pushen.
Danke Lion

##############################################
#
# $Id 99_KLW.pm 2016-03-28 lion $
#
##############################################

package main;

use strict;
use warnings;
use POSIX;
use DBI;

use vars qw{%attr %defs};

sub KLW_Initialize($$) {
my ($hash) = @_;

$hash->{DefFn} = "KLW_Define";
$hash->{UndefFn} = "KLW_Undef";
$hash->{GetFn} = "KLW_Get";
$hash->{AttrList} = "channel:0,1,2,3,4,5,6,7,8 pollingInterval ".$readingFnAttributes;
}

sub KLW_Define($$) {
my ($hash, $def) = @_;
my @a = split("[ \t][ \t]*", $def);
return "syntax: define <name> KLW <id>|KLIMALOGGPRO" if (int(@a) != 3);
$hash->{NAME} = $a[0];
$hash->{TYPE} = 'KLW';

$hash->{STATE} = "Initialized";
$hash->{fhem}{interfaces} = "temperature";
$hash->{fhem}{interfaces} = "humidity";
$hash->{fhem}{interfaces} = "dewpoint";
KLW_DeviceUpdateLoop($hash);
return;
}

sub KLW_Get($) {
my ($hash) = @_;
my $driver   = "SQLite";
my $database = "/opt/fhem/weewx/weewx.sdb";
my $dsn = "DBI:$driver:dbname=$database";
my $userid = "";
my $password = "";
my $dbh = DBI->connect($dsn, $userid, $password, { RaiseError => 1 }) or die $DBI::errstr;

my $channel = $attr{$hash->{NAME}}{channel} || 0;

my $stmt = qq(select temp$channel,humidity$channel,dewpoint$channel from archive where datetime=(select value from archive_day__metadata where name='lastUpdate'););

my $sth = $dbh->prepare( $stmt );

my $rv = $sth->execute() or die $DBI::errstr;

while(my @row = $sth->fetchrow_array())
{
readingsBeginUpdate($hash);
readingsBulkUpdate($hash,"state","T: $row[0]");
readingsBulkUpdate($hash,"temperature",$row[0]);
readingsBulkUpdate($hash,"humidity",$row[1]);
readingsBulkUpdate($hash,"dewpoint",$row[2]);
readingsEndUpdate($hash,1);
}
$dbh->disconnect();
return;
}

sub KLW_DeviceUpdateLoop($) {
my ($hash) = @_;
my $pollingInterval = $attr{$hash->{NAME}}{pollingInterval} || 300;
KLW_Get($hash);
InternalTimer(gettimeofday()+$pollingInterval, "KLW_DeviceUpdateLoop", $hash, 0);
return;
}

sub KLW_Undef($) {
my ($hash) = @_;
RemoveInternalTimer($hash);
return;
}

1;


Anbinden geht dann so:
define INDOOR KLW KLIMALOGGPRO
attr INDOOR channel 0
define WZ.KL KLW KLIMALOGGPRO
attr WZ.KL channel 1
...
define Garage.KL KLW KLIMALOGGPRO
attr Garage.KL channel 8


privat58

Schön, wenn dies funktioniert. Werde es mir die nächsten Tage mal anschauen. Der Winter ist leider auch bei uns vorbei, da ist nicht mehr soviel Zeit über.
Lässt sich noch der Batteriestatus abgreifen? Ich lasse mir die Temperaturen immer rot hinterlegen, wenn diese gewechselt werden müssen.
Danke aber für Deine Arbeit.

Lion

Bei mir steht da überall 0, hab's aber mal mit eingebaut, die Nachkommastellen hab ich ebenfalls noch überarbeitet.

##############################################
#
# $Id 99_KLW.pm 2016-03-29 lion $
#
##############################################

package main;

use strict;
use warnings;
use POSIX;
use DBI;

use vars qw{%attr %defs};

sub KLW_Initialize($$) {
my ($hash) = @_;

$hash->{DefFn} = "KLW_Define";
$hash->{UndefFn} = "KLW_Undef";
$hash->{GetFn} = "KLW_Get";
$hash->{AttrList} = "channel:0,1,2,3,4,5,6,7,8 pollingInterval ".$readingFnAttributes;
}

sub KLW_Define($$) {
my ($hash, $def) = @_;
my @a = split("[ \t][ \t]*", $def);
return "syntax: define <name> KLW <id>|KLIMALOGGPRO" if (int(@a) != 3);
$hash->{NAME} = $a[0];
$hash->{TYPE} = 'KLW';

$hash->{STATE} = "Initialized";
$hash->{fhem}{interfaces} = "temperature";
$hash->{fhem}{interfaces} = "humidity";
$hash->{fhem}{interfaces} = "dewpoint";
$hash->{fhem}{interfaces} = "batteryStatus";
KLW_DeviceUpdateLoop($hash);
return;
}

sub KLW_Get($) {
my ($hash) = @_;
my $driver   = "SQLite";
my $database = "/opt/fhem/weewx/weewx.sdb";
my $dsn = "DBI:$driver:dbname=$database";
my $userid = "";
my $password = "";
my $dbh = DBI->connect($dsn, $userid, $password, { RaiseError => 1 }) or die $DBI::errstr;

my $channel = $attr{$hash->{NAME}}{channel} || 0;

my $stmt = qq(select temp$channel,humidity$channel,dewpoint$channel,batteryStatus$channel from archive where datetime=(select value from archive_day__metadata where name='lastUpdate'););

my $sth = $dbh->prepare( $stmt );

my $rv = $sth->execute() or die $DBI::errstr;

while(my @row = $sth->fetchrow_array())
{
readingsBeginUpdate($hash);
readingsBulkUpdate($hash,"state","T: ".sprintf('%.1f', $row[0]));
readingsBulkUpdate($hash,"temperature",sprintf('%.2f', $row[0]));
readingsBulkUpdate($hash,"humidity",sprintf('%i', $row[1]));
readingsBulkUpdate($hash,"dewpoint",sprintf('%.2f', $row[2]));
readingsBulkUpdate($hash,"batteryStatus",sprintf('%i', $row[3]));
readingsEndUpdate($hash,1);
}
$dbh->disconnect();
return;
}

sub KLW_DeviceUpdateLoop($) {
my ($hash) = @_;
my $pollingInterval = $attr{$hash->{NAME}}{pollingInterval} || 300;
KLW_Get($hash);
InternalTimer(gettimeofday()+$pollingInterval, "KLW_DeviceUpdateLoop", $hash, 0);
return;
}

sub KLW_Undef($) {
my ($hash) = @_;
RemoveInternalTimer($hash);
return;
}

1;