Metainformationen zur Seite

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen RevisionVorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
plugins:foshkplugin:foshkplugin_generic_version [2024/02/09 12:01] Oliver Engelplugins:foshkplugin:foshkplugin_generic_version [2024/04/15 19:32] (aktuell) Oliver Engel
Zeile 74: Zeile 74:
   * changed: all incoming get-requests will be URL-decoded now   * changed: all incoming get-requests will be URL-decoded now
   * new: enable signal quality acquisition on supported consoles with Export\ADD_SIGNAL = True (default: False)   * new: enable signal quality acquisition on supported consoles with Export\ADD_SIGNAL = True (default: False)
 +  * new: with the option FWD_OPTION = blacklist=False, the additional values for spread and signal quality are forwarded in Ecowitt format for this specific forward
 +  * new: Introduction of a naming scheme for beta versions ("Beta YYMMDD") - displayed at startup, in the log files and on the web pages generated by FOSHKplugin
 +  * new: ADD_SCRIPT - offers the possibility to integrate data from third party devices - see https://foshkplugin.phantasoft.de/generic#script
 +  * changed: postroot.sh - check Pillow installation fixed (newer versions named pillow instead of Pillow) - LoxBerry only
 +  * changed: sed is now working globally in postinstall.sh & postupgrade.sh - LoxBerry only
 +  * new: enable debug mode if file debug.enable found in the config directory\\ enable debug mode with bin/service.sh debug-enable and disable with bin/service.sh debug-disable - LoxBerry only
 +  * changed: **changed default SUN_COEF from 0.8 to 0.92** - should fit better for Germany (too little sunshine recorded: decrease value; too much: increase)
 +  * changed: all sun related values (e.g. sunshine, srsum, sunhours, ...) are only transmitted if solarradiation is present
 +  * improved: better integration with Home Assistant (MQTT discovery) - see [[https://foshkplugin.phantasoft.de/generic#hass|https://foshkplugin.phantasoft.de/generic#hass]]
  
  
Zeile 330: Zeile 339:
 | /FOSHKplugin/recoverW4L  | Restore the original Weather4Loxone configuration before "patching"  | | /FOSHKplugin/recoverW4L  | Restore the original Weather4Loxone configuration before "patching"  |
 | /FOSHKplugin/rebootWS  | reboot the connected weather station (Config\REBOOT_ENABLE has to be True)  | | /FOSHKplugin/rebootWS  | reboot the connected weather station (Config\REBOOT_ENABLE has to be True)  |
-| /FOSHKplugin/restartPlugin  | restart the running FISHKplugin service (Config\RESTART_ENABLE has to be True)  |+| /FOSHKplugin/restartPlugin  | restart the running FOSHKplugin service (Config\RESTART_ENABLE has to be True)  |
 | /observations/current/json/units=m | Feedback of a WU-compatible data record with metric values (°C, kmh, mm, hPa)  | | /observations/current/json/units=m | Feedback of a WU-compatible data record with metric values (°C, kmh, mm, hPa)  |
 | /observations/current/json/units=e | Feedback of the WU-compatible data record with imperial values (°F, mph, in, inHg)  | | /observations/current/json/units=e | Feedback of the WU-compatible data record with imperial values (°F, mph, in, inHg)  |
Zeile 2938: Zeile 2947:
 \\ \\
 These values are only available via UDP and getvalue as well as in forwards of type UDP, BANNER, TAGFILE, MQTT and InfluxDB. If these values are also to be sent with a forward in Ecowitt format, an additional <code syntaxhighlighter-pre>FWD_OPTION = blacklist=False</code> must be entered in the forward configuration in the config file for the corresponding forward.\\ These values are only available via UDP and getvalue as well as in forwards of type UDP, BANNER, TAGFILE, MQTT and InfluxDB. If these values are also to be sent with a forward in Ecowitt format, an additional <code syntaxhighlighter-pre>FWD_OPTION = blacklist=False</code> must be entered in the forward configuration in the config file for the corresponding forward.\\
 +
 +++++
 +
 +----
 +
 +{{anchor:script}}
 +
 +++++ Provide additional data from third-party devices globally for weather services (script) |
 +
 +**Provide additional data from third-party devices globally for weather services (script)**
 +
 +With the FWD_EXEC function, it has long been possible to modify the output line for a forward shortly before it is actually sent to the respective weather station service using a script. This script only works on a forward-specific basis and must therefore be set up for each individual forward.\\
 +However, if, for example, you want to use the data from an Luftdaten.info fine dust sensor as data from a virtual WH45/WH46 for sending to several services, you would have to set up a separate script for each individual service.\\
 +And depending on the target format or FWD_TYPE (Ecowitt format, WU, Awekas, Ambient Weather etc.), this script must also have different content.\\
 +\\
 +As of v0.10, ADD_SCRIPT can be used to define a global script that receives the data originally coming from the weather station and makes it modifiable. After the change, FOSHKplugin receives the modified or extended data back and only then starts to process this data for each individual forward.\\
 +This means that there is a centralised data manipulation option that is valid for all output formats.\\
 +\\
 +Example:\\
 +The particulate matter sensor from Luftdaten.info can be queried locally via a web interface. The link http://ip-address/data.json (where ip-address corresponds to the IP address of the sensor) returns a JSON file with the values, which can be parsed and processed very easily using standard on-board tools.\\
 +\\
 +JSON - depending on the software version of the device, however, the structure of the JSON may be different:\\
 +<code syntaxhighlighter-pre>
 +{
 +   "software_version":"NRZ-2020-133",
 +   "age":"28",
 +   "sensordatavalues":[
 +      {
 +         "value_type":"SDS_P1",
 +         "value":"8.25"
 +      },
 +      {
 +         "value_type":"SDS_P2",
 +         "value":"3.03"
 +      },
 +      {
 +         "value_type":"samples",
 +         "value":"5051440"
 +      },
 +      {
 +         "value_type":"min_micro",
 +         "value":"28"
 +      },
 +      {
 +         "value_type":"max_micro",
 +         "value":"20098"
 +      },
 +      {
 +         "value_type":"interval",
 +         "value":"145000"
 +      },
 +      {
 +         "value_type":"signal",
 +         "value":"-73"
 +      }
 +   ]
 +}
 +</code>
 +
 +SDS_P1 corresponds here to the PM10 value and SDS_P2 to the PM2.5 value.\\
 +The WH45 recognises the keys tf_co2 (temperature in °F), humi_co2 (humidity), pm25_co2 (the PM2.5 value), pm25_24h_co2 (the 24h mean value of PM2.5), pm10_co2 (PM10 value), pm10_24h_co2 (24h mean value PM10) in Ecowitt format, co2 (CO2) and co2_24h (24h average CO2). If we do not have a real WH45/WH46 ourselves, we can use the PM10 and PM2.5 values of the luftdaten.info sensor and emulate a WH45 - at least partially - by using the WH45/WH46 keys.\\
 +We therefore assign the value of SDS_P2 to the pm25_co2 key and the value of SDS_P1 to the pm10_co2 key using a script.\\
 +\\
 +For a better understanding, here is the sequence of the individual steps:\\
 +1. FOSHKplugin receives the general weather data from the console\\
 +2. When the data is received, the configured script is started, which executes the following steps:\\
 +2.1 Query foreign data - the values must come from somewhere\\
 +2.2 merge with the real data from the weather station\\
 +2.3 Return to FOSHKplugin\\
 +3. FOSHKplugin sends the merged data to all configured weather services\\
 +\\
 +Here is the example script that executes the complete point 2:\\
 +<code syntaxhighlighter-pre>
 +#!/bin/bash
 +# complements the output line of FOSHKplugin with values of the particulate matter sensor from Luftdaten.info and emulates a WH41
 +# the channel number of the virtual WH41 is defined via the variable WH41
 +# depending on the output format, the output strings must be modified - in Ecowitt format, the individual components are combined
 +# using an "&" - used here
 +# needs curl and jq - install with sudo apt-get install curl jq
 +# general help: https://foshkplugin.phantasoft.de/generic#exec
 +
 +# define the local ip address of the Sensor
 +ADR=192.168.15.229
 +
 +# define the channel number of the virtual WH41; 9 = emulate WH45 instead
 +WH41=9
 +
 +#JSON=`cat luftdaten2.json`
 +JSON=`curl -s http://${ADR}/data.json`
 +
 +# the original output data from FOSHKplugin
 +instr="$@"
 +
 +# PM2.5
 +pm2=`echo ${JSON}|jq ".sensordatavalues[1].value"|sed 's/\"//g'`
 +if [ ! -z "${pm2}" ]; then 
 +  if [ "${WH41}" = "9" ]; then pm2string="&pm25_co2=${pm2}"; else pm2string="&pm25_ch${WH41}=${pm2}"; fi
 +fi
 +
 +# PM10
 +pm1=`echo ${JSON}|jq ".sensordatavalues[0].value"|sed 's/\"//g'`
 +if [ ! -z "${pm1}" ]; then
 +  if [ "${WH41}" = "9" ]; then pm1string="&pm10_co2=${pm1}"; else pm1string="&pm10_ch${WH41}=${pm1}"; fi
 +fi
 +
 +# temp in °C - must be converted to °F - F = (C*9/5)+32 -
 +temp=`echo ${JSON}|jq ".sensordatavalues[2].value"|sed 's/\"//g'`
 +temp=`echo "scale=2; (${temp}*9/5)+32"|bc`
 +if [ ! -z "${temp}" ]; then
 +  if [ "${WH41}" = "9" ]; then tempstring="&tf_co2=${temp}"; else tempstring="&tf_ch${WH41}=${temp}"; fi
 +fi
 +
 +# pressure - not supported by WH41, WH45, WH46 - you could override the original pressure from wether station
 +# not used
 +pressure=`echo ${JSON}|jq ".sensordatavalues[3].value"|sed 's/\"//g'`
 +if [ ! -z "${pressure}" ]; then 
 +  if [ "${WH41}" = "9" ]; then pressurestring="&tf_pressure=${pressure}"; else pressurestring="&pressure_ch${WH41}=${pressure}"; fi
 +fi
 +
 +#humidity
 +humidity=`echo ${JSON}|jq ".sensordatavalues[4].value"|sed 's/\"//g'`
 +if [ ! -z "${humidity}" ]; then
 +  if [ "${WH41}" = "9" ]; then humiditystring="&humi_co2=${humidity}"; else humiditystring="&humidity_ch${WH41}=${humidity}"; fi
 +fi
 +
 +# merge the original string with the new components
 +echo "${instr}${pm2string}${pm1string}${tempstring}${humiditystring}"
 +</code>
 +
 +The script here is somewhat more extensive because it can provide data for either a WH41 or WH45.\\
 +\\
 +For installation/configuration:\\
 +1. save the enclosed file as addLDdata.sh in the installation directory of FOSHKplugin (/opt/FOSHKplugin/)\\
 +2. customise addLDdata.sh - adjust the IP address of your particulate matter sensor at ADR\\
 +3. make the script executable: chmod ug+x addLDdata.sh\\
 +4. make sure that the required tools are available: sudo apt-get install curl jq\\
 +5. manual test of the script: ./addLDdata.sh - a line like &pm25_co2=8.15&pm10_co2=17.17&tf_co2=31.55&humi_co2=87.72 should then be displayed\\
 +6. customise the forward to PWSDashboard - the line FWD_EXEC = ./addLDdata.sh must be added in the relevant forward\\
 +7. restart FOSHKplugin - sudo service foshkplugin restart\\
 +\\
 +<WRAP center round important 100%>
 +**Attention!**\\
 +**This is a very powerful feature that should be used with caution. Errors in the script can lead to trouble with the target weather service or even to the failure of FOSHKplugin.**\\
 +**As an immediate measure, always insert an exit line in the script below the shebang "#!/bin/bash" in the event of any unclear errors - then the script will continue to be started by FOSHKplugin, but will no longer cause any mischief.**\\
 +**Scripts should be well tested - even under conditions that are not intended - ideally locally. A text line can be specified as a parameter to which the additional keys and values are appended.**\\
 +**The SND log file logs the script call and any errors detected.**
 +</WRAP>
 +
 +++++
 +
 +----
 +
 +{{anchor:hass}}
 +
 +++++ Further processing of data from FOSHKplugin in Home Assistant |
 +
 +**Further processing of data from FOSHKplugin in Home Assistant**
 +
 +There are various ways of integrating data from an Ecowitt weather station into Home Assistant.\\
 +\\
 +The easiest way to do this is via the Ecowitt integration contained in the core of HA. This provides most of the keys of the current Ecowitt weather stations.\\
 +However, the additional keys generated by FOSHKplugin are of course not processed and therefore do not end up in HA.\\
 +\\
 +Another option - if an MQTT broker is available - is to transmit the data via [[https://foshkplugin.phantasoft.de/generic#mqtt|MQTT]].\\
 +However, this entails longer configuration work because you have to make an entry in a YAML for each desired data point the Home Assistant:\\
 +
 +<code syntaxhighlighter-pre>
 +mqtt:
 +  sensor:
 +  - state_topic: "GW2000/tc_co2"
 +    name: "WH45 Temperature"
 +    unit_of_measurement: "°C"
 +    device_class: "temperature"
 +    icon: "mdi:thermometer"
 +</code>
 +
 +This is very time-consuming (with 200 or even 450 topics).\\
 +\\
 +With v0.10, FOSHKplugin now also supports the MQTT discovery of Home Assistant.\\
 +HA automatically finds FOSHKplugin as a device with all entities without the need for any configuration measures. Icon, unit and device class are already pre-assigned.\\
 +A forward block in the configuration file foshkplugin.conf should look something like this:\\
 +
 +<code syntaxhighlighter-pre>
 +[Forward-60]
 +FWD_TYPE = MQTTMET
 +FWD_CMT = MQTT-Forward of metric values to LoxBerry
 +FWD_URL = 192.168.15.236:1883@homeassistant/FOSHKplugin
 +FWD_ENABLE = True
 +FWD_OPTION = MQTTCYCLE=5,hass=True,devname=GW1000-Test,minmax=False,status=False,dtime_format="%d.%m.%Y %H:%M:%S",diagnostic=False
 +FWD_SID = MQTT-username
 +FWD_PWD = MQTT-password
 +FWD_STATUS = True
 +</code>
 +
 +MQTTMET should be selected as the forward type FWD_TYPE for metric values - MQTTIMP should be selected accordingly for imperial measurement systems.\\
 +The destination - i.e. the MQTT broker together with the desired hierarchy - must be specified in the FWD_URL. The structure of the address is MQTTipaddress:port@topic-hierarchy%prefix. A prefix "%prefix" is optional and therefore does not have to be specified.\\
 +In the FWD_OPTION line, at least hass=True must be entered to activate auto-discovery. The name of the device is defined with devame=name (default: FOSHKplugin).\\
 +By default, FOSHKplugin only sends the data to the broker when the value changes. In addition, an interval in minutes can be entered via MQTTCYCLE in which ALL topics - regardless of value changes - are sent to the broker.\\
 +With an interval of 0, ALL topics are sent at every send interval.\\
 +To minimise data transfer, I recommend entering an interval of 10 or 5 minutes for regular operation.\\
 +If the MQTT broker requires a login, the credentials can be configured with FWD_SID (user name) and FWD_PWD (password).\\
 +\\
 +By default, all values including the min/max values (if configured) are transmitted via MQTT. To prevent the transmission of the min/max values, minmax=False can be set as an additional option in FWD_OPTION. If the status messages from FOSHKplugin are also to be made available via MQTT, FWD_STATUS should be set to True. Alternatively, this option can also be specified as status=True in FWD_OPTION.\\
 +The time format for the output of timestamps (e.g. lightning_time and all min/max times) can be defined with dtime_format. For possible formatting options, see the recipe [[plugins:foshkplugin:foshkplugin_generic_version#dt_format|Adjust the output format for date and time (from v0.10)]]. If dtime_format is missing in FWD_OPTION, the central setting Config\DT_FORMAT is used instead.\\
 +If the sensor data is to be separated from the diagnostic data (info data, battery and signal values), this can be realised via the additional option diagnostic=True in the FWD_OPTION. Two separate cards for sensor data and diagnostic data are then generated in the Home Assistant. If diagnostic=False is set or the diagnostic option is missing within the FWD_OPTION, all data is displayed together in one card.\\
 +\\
 +<WRAP center round important 100%>
 +**Attention!**\\  **The spelling of the options is case-sensitive - only "MQTTCYCLE", "hass", "devname" "minmax", "status", "dtime_format" and "diagnostic" apply.**\\  **The hierarchy and the device name must not contain any special characters, umlauts or spaces (these are automatically removed).**
 +</WRAP>
 +
 +In Home Assistant, select and configure the MQTT integration (address, port and credentials if necessary) under Settings/Devices&Services using the "ADD INTEGRATION" button at the bottom right:\\
 +\\
 +\\
 +{{:plugins:foshkplugin:mqtt-config.png?direct&400|}}
 +\\
 +\\
 +You will then find the MQTT button under the configured integrations, which already shows 1 recognised device:\\
 +\\
 +\\
 +{{:plugins:foshkplugin:mqtt-configured.png?direct&400|}}
 +\\
 +\\
 +After clicking on the MQTT button, information about this integration appears, such as the number of devices and the number of entities in this integration:\\
 +\\
 +\\
 +{{:plugins:foshkplugin:mqtt-entries.png?direct&400|}}
 +\\
 +\\
 +In the device info you can finally see all information about the FOSHKplugin device and change it if necessary:\\
 +\\
 +\\
 +{{:plugins:foshkplugin:mqtt-device.png?direct&400|}}
 +\\
 +\\
 +All data points generated by FOSHKplugin should now be available within Home Assistant for further use and visualisation.\\
 +\\
 +{{:plugins:foshkplugin:homeassistantfoshkplugin.png?direct&400|}}
 +\\
 +\\
 +**Advantages of the connection via FOSHKplugin and MQTT**
 +  * Signal quality values of the sensors are transmitted (if the console supports the http/JSON API)
 +  * Additional values available such as wind chill, dew point (also for all indoor sensors), spread, feelslike, heat index, AQI for WH41/43/45/46, 10min average for wind speed and direction, max. gust of the last 10 minutes, brightness (lux), cloud height, sunshine duration, air pressure trend and change 1h/3h, if EVAL_VALUES is active
 +  * Any values from other sensors can be integrated
 +  * Availability of min/max values with respective times
 +  * Warnings (thunderstorm, storm, leakage, CO2, station or sensor failure, battery warning, interval warning, update) are available directly in Home Assistant
 +
 +**Note:**\\
 +The [[https://mqtt-explorer.com/|MQTT Explorer]], which is available for various platforms, is an extremely helpful tool for analysing any problems or for a general basic understanding of MQTT.\\
 +
  
 ++++ ++++