Browse Source

## 2022-11-07

* updated README.md
* fix unlimited decimal places in median calculation
FloKra 1 year ago
parent
commit
b5b480f9cf
3 changed files with 68 additions and 10 deletions
  1. 5 0
      CHANGELOG.md
  2. 60 7
      README.md
  3. 3 3
      jeelinklog/jeelinklog.py

+ 5 - 0
CHANGELOG.md

@@ -2,6 +2,11 @@
 
 ## 2022-11-07
 
+* updated README.md
+* fix unlimited decimal places in median calculation
+
+## 2022-11-07
+
 * updated README.md
 
 ## 2022-08-02

+ 60 - 7
README.md

@@ -12,8 +12,34 @@ Requires Python 3 (default on Debian/RaspberryOS Buster or Bullseye).
 - copy folder __jeelinklog__ to /home/pi
 - edit config files as needed. A minimum of 1 sensor must be configured before starting, so leave one from the examples there, configure it as desired and then find out the ID of your sensor and edit it afterwards. 
 - test if it works:
-    - cd /home/pi
-    - ./jeelinklog.py -v
+    ```
+    cd /home/pi
+    ./jeelinklog.py -v  (start in verbose mode)
+    ```
+	- put batteries in one sensor - you should see some output showing sensor data. 
+	- Find your sensor ID: 
+	    - either look on the verbose output and find the one stating __Batt_New: 1__ 
+	    - or have a look in the logfile __/home/pi/logs/jeelinklog/jeelink_new_sensors.log__ 
+	    - or check the subfolder __/home/pi/logs/jeelinklog/new__ - here JeelinkLog will create a file for each sensor received with "Batt_New flag on". Filename = LaCrosse ID. 
+	- exit verbose mode (ctrl+C)
+	- Configure Sensor ID in jeelinklog_sensors.yml
+	- delete corresponding files in __/home/pi/logs/jeelinklog/new__ and __/home/pi/logs/jeelinklog/unknown__
+	
+- install systemd service:
+	```
+	cd /home/pi/jeelinklog
+	sudo cp jeelinklog.service /lib/systemd/system
+	sudo systemctl daemon-reload
+	sudo systemctl enable jeelinklog.service
+	sudo systemctl start jeelinklog.service
+	```
+	
+- check if service is running: 
+	```
+    sudo systemctl status jeelinklog.service
+    ```
+
+
 
 ## Configuration
 The configuration is split in the following files: 
@@ -28,8 +54,8 @@ __jeelinklog_influxdb.yml__ format:
     temphum:                            instance name used in sensor configuration
         host: localhost
         port: 8086
-        username: jeelinklog            comment out if authentication is not used
-        password: password              comment out if authentication is not used
+        username: jeelinklog            [optional] comment out if authentication is not used
+        password: password              [optional] comment out if authentication is not used
         database: TempHum               InfluxDB database name - must already exist
         measurement: TempHum            InfluxDB measurement name, will be added automatically if it does not already exist
         fieldnames:
@@ -48,9 +74,9 @@ __jeelinklog_sensors.yml__ format:
 
     Aussen:                             Sensor name
         LaCrosseID: 1                   LaCrosse Sensor ID, randomly generated on battery change
-        DomoticzIdx: 94                 Sensor ID in Domoticz (deprecated)
-        Topic_Temp: "Test/Atemp"        additional MQTT topic to publish temperature values of that sensor
-        Topic_Hum: "Test/Ahum"          additional MQTT topic to publish humidity values of that sensor
+        DomoticzIdx: 94                 [optional] Sensor ID in Domoticz (deprecated)
+        Topic_Temp: "Test/Atemp"        [optional] additional MQTT topic to publish temperature values of that sensor
+        Topic_Hum: "Test/Ahum"          [optional] additional MQTT topic to publish humidity values of that sensor
         InfluxDB_Instance: TempHum      InfluxDB instance name to use (as set in jeelinklog_influxdb.yml)
         isOutsideTempSensor: true       true or false
 
@@ -63,6 +89,33 @@ __isOutsideTempSensor: true__ will include that sensor in mean/average outside t
 You can add as many sensors as you need. 
 Please mind correct indenting in YAML files!
 
+## MQTT output
+All data is published to ``LaCrosse/`` topic-prefix (can be configured in jeelinklog.ini). 
+
+    [mqtt]
+    topic_prefix = LaCrosse
+
+For sensors with a configured ``Topic_Temp`` and/or ``Topic_Hum`` in ``jeelinklog_sensors.yml``, values will be published to these topics additionally. 
+
+Outside temperature/humidity (mean/average of multiple sensors if configured) is published to topics set in ``jeelinklog.ini``: 
+
+    [mqtt]
+    topic_prefix_outside_temphum = wetter/atemphum
+    # additional single topics for outside temp/hum
+    topic_outside_temp = wetter/atemp
+    topic_outside_hum = wetter/ahum
+
+Example output: 
 
+| Topic     | Payload  |
+|-----------|----------|
+| LaCrosse/Sensorname/temperature | 20.2 |
+| LaCrosse/Sensorname/humidity | 56 |
+| LaCrosse/Sensorname/battery | OK |
+| LaCrosse/Sensorname/batteryNew | NO |
+| LaCrosse/Sensorname/availability | available |
+| LaCrosse/Sensorname/lastUpdate | 2022-11-08 09:22:42 |
+| LaCrosse/Sensorname/json | {"temperature":20.2, "humidity":56, "battery":"OK"} |
+| LaCrosse/Sensorname/TempHumText | 20.2° 56% |
 
 

+ 3 - 3
jeelinklog/jeelinklog.py

@@ -400,7 +400,7 @@ try:
                             print("unknown sensor ID " + str(addr))
                                         
                     if verbosemode:
-                        print("addr: " + str(addr) + " = 0x" + str(addrhex) + "   batt_new: " + str(batt_new) + "   type: " + str(type) + "   batt_low: " + str(batt_low) + "   temp: " + str(temp) + "   hum: " + str(hum) + "   Name: " + str(currentsensor_name))
+                        print("LaCrosse-ID: " + str(addr) + " = 0x" + str(addrhex) + "   Type: " + str(type) + "   Batt_New: " + str(batt_new) + "   Batt_Low: " + str(batt_low) + "   Temp: " + str(temp) + "   Hum: " + str(hum) + "   Name: " + str(currentsensor_name))
                         print()
                     
                     #if senddata:
@@ -733,8 +733,8 @@ try:
                 out_hum_avg = int(round(sum_out_sensors_hum / count_used_out_sensors))
                 
                 # median
-                out_temp_median = statistics.median(out_sensors_temp_median_values)
-                out_hum_median = statistics.median(out_sensors_hum_median_values)
+                out_temp_median = round(statistics.median(out_sensors_temp_median_values), 1)
+                out_hum_median = int(statistics.median(out_sensors_hum_median_values))
                 
                 out_temp_publishvalue = out_temp_avg
                 out_hum_publishvalue = out_hum_avg