###########################################
# $Id: mqtt2.template 18592 2019-02-14 06:27:39Z Beta-User $
#
# Comments start with #. Empty lines are ignored.
# Syntax of one entry: name: line, one optional filter: line, zero or more par: lines,  FHEM-Commands
# filter:INTERNAL=VALUE (optional)
# par: name of the parameter; comment; perl_code (optional)
# perl_code returns a value for the parameter, or undef.
# If undef, the user has to specify them (the comment is shown to the user)

###########################################
name:0_00_General_Info
filter:TYPE=HTTPMOD
desc: Forum <a href="https://forum.fhem.de/index.php/topic,97694.0.html">link</a> for suggestions or bug reports on httpmod-template


#################################
#Clever Tanken
#
#Single station prices, Forum: https://forum.fhem.de/index.php/topic,94640.msg873905.html#msg873905
name:A_01a_clever_tanken_single_station
filter:TYPE=HTTPMOD
desc: Get prices for a single gas station.<br>Define a HTTPMOD device like <br>defmod DEVICE HTTPMOD http://www.clever-tanken.de/tankstelle_details/29092 1800 <br>Change station ID to your needs <br><a href="https://forum.fhem.de/index.php/topic,94640.msg873905.html#msg873905">Source: Forum</a>
attr DEVICE userattr reading01Name reading01Regex reading02Name reading02Regex reading03Name reading03Regex readingOExpr
attr DEVICE enableControlSet 1
attr DEVICE reading01Name Diesel
attr DEVICE reading01Regex SpritsortenController[^0-9]+([0-9,]+)[^0-9]+Diesel
attr DEVICE reading02Name SuperE10
attr DEVICE reading02Regex SpritsortenController[^0-9]+([0-9,]+)[^0-9]+Super E10
attr DEVICE reading03Name SuperE5
attr DEVICE reading03Regex SpritsortenController[^0-9]+([0-9,]+)[^0-9]+Super E5
attr DEVICE readingOExpr $val =~ tr/,/./;;$val
attr DEVICE stateFormat E5: SuperE5 € / E10: SuperE10 € / D: Diesel €
attr DEVICE timeout 10
attr DEVICE verbose 2
attr DEVICE model A_01a_clever_tanken_single_station

#defmod FileLogSpritE5 FileLog ./log/SpritE5-%Y.log TankeJetRueckmarsdorfer:SuperE5:.*|DEVICE:SuperE5:.*

#Station overview, one product, Forum: https://forum.fhem.de/index.php/topic,94640.msg873841.html#msg873841
name:A_01a_clever_tanken_multi_station
filter:TYPE=HTTPMOD
desc: Get prices for one product as environment search.<br>Define a HTTPMOD device like <br>defmod DEVICE HTTPMOD https://www.clever-tanken.de/tankstelle_liste?spritsorte=3&r=10&ort=52152  1800 <br>Change PLZ, radius and product to your needs <br><a href="https://forum.fhem.de/index.php/topic,94640.msg873841.html#msg873841">Source: Forum</a>
attr DEVICE reading01Name Tankstellenname
attr DEVICE reading01Regex <div class=\"row fuel-station-location-name\">(.*)<\/div>
attr DEVICE reading01RegOpt g
attr DEVICE reading02Name Preis
attr DEVICE reading02Regex <div class=\"price\">(.*)<sup>
attr DEVICE reading02RegOpt g
attr DEVICE reading03Name Strasse
attr DEVICE reading03Regex <div id=\"fuel-station-location-street\">(.*)<\/div>
attr DEVICE reading03RegOpt g
attr DEVICE reading04Name Ort
attr DEVICE reading04Regex <div id=\"fuel-station-location-city\"> (.*)<\/div>       
attr DEVICE reading04RegOpt g
attr DEVICE reading05Name Entfernung
attr DEVICE reading05Regex <div >(.*)<\/div>
attr DEVICE reading05RegOpt g 
attr DEVICE model A_01a_clever_tanken_multi_station

#German weather warnings from DWD, Forum: https://forum.fhem.de/index.php/topic,45176.msg905879.html#msg905879
name:A_02a_DWD_weather_warnings
filter:TYPE=HTTPMOD
desc: Get weather warnings from DWD.<br>Define a HTTPMOD device like <br>defmod Wetterwarner HTTPMOD https://www.dwd.de/DWD/warnungen/warnapp/json/warnings.json 0 <br>Change region to your needs <br><a href="https://forum.fhem.de/index.php/topic,45176.msg906203.html#msg906203">Source: Forum</a>
par:REGIONCODE;Get region code from https://www.dwd.de/DE/leistungen/opendata/help/warnungen/cap_warncellids_csv.csv?__blob=publicationFile&v=3;{ undef }
attr DEVICE enableControlSet 1
attr DEVICE extractAllJSON 1
attr DEVICE extractAllJSONFilter REGIONCODE
attr DEVICE readingEncode UTF-8
attr DEVICE preProcessRegex s/warnWetter..............|\);;|\t|\n|\r//g
attr DEVICE model A_02a_DWD_weather_warnings

#German river water levels, Wiki: https://wiki.fhem.de/wiki/Flusspegel
name:A_02d_pegelonline
filter:TYPE=HTTPMOD
desc: Get water level infor for german rivers from www.pegelonline.wsv.de.<br>Define a HTTPMOD device like <br>defmod Pegelstaende HTTPMOD https://www.pegelonline.wsv.de/webservices/rest-api/v2/stations/070b1eb4-3872-4e07-b2e5-e25fd9251b93/W/currentmeasurement.json 3600<br>Change station argument to your needs <br><a href="https://wiki.fhem.de/wiki/Flusspegel">Source: Wiki</a><br><a href="https://forum.fhem.de/index.php/topic,97560.msg908176.html#msg908176">Source: Forum</a>
attr DEVICE enableControlSet 1
attr DEVICE extractAllJSON 1
attr DEVICE event-on-change-reading value,stateMnwMhw,stateNswHsw,timestamp,trend
attr DEVICE event-on-update-reading value
attr DEVICE sortby 1
attr DEVICE stateFormat {sprintf("%.0f",ReadingsVal("DEVICE","value",0))}
attr DEVICE timeout 5
attr DEVICE model A_02d_pegelonline

#Austrian weather, Forum: https://forum.fhem.de/index.php/topic,94110.msg868080.html#msg868080; enhanced by JoeALLb: https://forum.fhem.de/index.php/topic,97694.msg912164.html#msg912164
name:A_02m_ORF_weather
filter:TYPE=HTTPMOD
desc: Get austrian weather.<br>Define a HTTPMOD device like <br>defmod weatherORF HTTPMOD none 1800 <br>You will be asked to provide a MAINURL like https://wetter.orf.at/steiermark/ and a stationname like grazuniversitaet<br><a href="https://forum.fhem.de/index.php/topic,97694.msg912164.html#msg912164">Source: Enhanced version in FHEM Forum</a>
par:MAINURL;First part of the URL. Example: https://wetter.orf.at/steiermark/;{ AttrVal("DEVICE","get02URL","") =~ m,(https://wetter.orf.at/[^/]+[/]).*, ? $1 : undef }
par:STATIONNAME;Name of the respective weather station as written in the last part of the URL. Examples: grazuniversitaet or innerestadt;{ AttrVal("DEVICE","get01URL","") =~ m,https://wetter.orf.at/[^/]+[/]([^/]+)[/], ? $1 : undef }
attr DEVICE userattr get01Name get01Poll:0,1 get01URL get02-1Name get02-2Name get02-3Name get02-4Name get02-5Name get02-6Name get02-7Name get02-8Name get02Name get02Poll:0,1 get02Regex get02URL reading01-1Name reading01-2Name reading01-3Name reading01-4Name reading01-5Name reading01Regex
attr DEVICE enableControlSet 1
attr DEVICE get01Name Wetterdaten
attr DEVICE get01Poll 1
attr DEVICE get01URL MAINURLSTATIONNAME/
attr DEVICE get02-1Name sunRise
attr DEVICE get02-2Name sunSet
attr DEVICE get02-3Name moonPhase
attr DEVICE get02-4Name moonRise
attr DEVICE get02-5Name moonSet
attr DEVICE get02-6Name dayLength
attr DEVICE get02-7Name dawn
attr DEVICE get02-8Name dusk
#attr DEVICE get02-9Name weather
attr DEVICE get02Name Astro-Daten
attr DEVICE get02Poll 1
attr DEVICE get02Regex Sonnenaufgang um <\/span>(.*)<s[\w\W]*Sonnenuntergang um <\/span>(.*)<s\p{Any}*?Mondphase:\s?([^\.]+)[\w\W]*Mondaufgang um\s?<\/span>(\d\d:\d\d)<s[\w\W]*Monduntergang um <\/span>(\d\d:\d\d)<s[\w\W]*Tagesl[^>]+>(\d\d:\d\d)&[\w\W]*Morgen<\/span>: <\/span>(\d\d:\d\d)&[\w\W]*Abend:<\/span><\/span>(\d\d:\d\d)
attr DEVICE get02URL MAINURL
attr DEVICE reading01Regex (?s)Temperatur.*?.*?>.*?(?<temperature>[\d,]+)&thinsp.*?Taupunkt.*?.*?>.*?(?<taupunkt>[\d,]+)&thinsp.*?Wind.*?>\n\s*(?<wind>[^<]+)\s<abbr.*?Windspitzen.*?>\n\s*(?<windspitzen>[^<]+)\s<abbr.*?Luftdruck.*?>\n\s*(?<luftdruck>[^<]+)\s<abbr.*?Luftfeuchtigkeit.*?>\n\s*(?<humidity>[^<]+)\s<abbr.*?Sonnenschein.*?>\n\s*(?<sonne>[^<]+)\s<abbr.*?Niederschlag.*?>\n\s*(?<rain>[^<\n]+).*?</p.*?(?<messwerte>Messwerte[^<\n]+)
attr DEVICE room Wetter
attr DEVICE stateFormat W: wind, H: humidity%rH, T: temperature°C
attr DEVICE model A_02m_ORF_weather

#Geschwindigkeitsüberwachung, Forum: https://forum.fhem.de/index.php/topic,90014.msg824805.html#msg824805
name:A_03a_blitzer
filter:TYPE=HTTPMOD
desc: Get austrian weather.<br>Define a HTTPMOD device like <br>defmod DEVICE HTTPMOD https://cdn2.atudo.net/api/1.0/vl.php?type=0,1,2,3,4,5,6&box=52.xxxxxx,8.xxxxxx,53.xxxxxx,9.xxxxxx 0 <br>Change city to your needs <br><a href="https://forum.fhem.de/index.php/topic,90014.msg824805.html#msg824805">Source: Forum</a>
attr DEVICE userattr getData getHeader1 getHeader2 getURL reading01DeleteIfUnmatched reading01JSON reading01Name reading01Regex reading02Name reading02RegOpt reading02Regex reading03JSON reading03Name readingEncode requestHeader1 requestHeader2 setParseResponse:0,1
attr DEVICE enableControlSet 1
attr DEVICE extractAllJSON 1
attr DEVICE getHeader1 Content-Type: application/json
attr DEVICE getHeader2 Accept: */*
attr DEVICE readingEncode utf8
attr DEVICE model A_03a_blitzer


#homebridge-videodoorbell, Forum: https://forum.fhem.de/index.php/topic,94291.msg870289.html#msg870289
name:A_02c_homebridge_videodoorbell
filter:TYPE=HTTPMOD
desc: Controll your homebridge-videodoorbell.<br>Define a HTTPMOD device like <br>define Video_Doorbell HTTPMOD none 0 <br><a href="https://forum.fhem.de/index.php/topic,94291.msg870289.html#msg870289">Source: Forum</a>
par:IP_PORT;Enter IP:Port as configured in your doorbell, like 123.456.7.8:5005;{undef }
attr DEVICE get01Name klingel2homekitget
attr DEVICE get01URL http://IP_PORT/
attr DEVICE get01Data ding=dong&dong=ding
attr DEVICE get01Header02 User-Agent: curl/7.38.0
attr DEVICE get01Header04 Accept: */*
attr DEVICE get01Header06 Content-Type: application/x-www-form-urlencoded
attr DEVICE set01Name klingel2homekitset
attr DEVICE set01URL http://IP_PORT/
attr DEVICE set01Data ding=dong&dong=ding
attr DEVICE set01Header02 User-Agent: curl/7.38.0
attr DEVICE set01Header04 Accept: */*
attr DEVICE set01Header06 Content-Type: application/x-www-form-urlencoded
attr DEVICE set01NoArg 1
attr DEVICE model A_02c_homebridge_videodoorbell

#################################
#HP Printers
#
# Forum: https://forum.fhem.de/index.php/topic,90601.msg874683.html#msg874683
#
# Printer config
name:B_01a_hp_printer_config
filter:TYPE=HTTPMOD
desc: Get configuration of your hp printer.<br>Define a HTTPMOD device like <br>defmod DEVICE HTTPMOD http://192.168.5.43/DevMgmt/ProductConfigDyn.xml 3600 <br>Change IP to your needs <br><a href="https://forum.fhem.de/index.php/topic,90601.msg874683.html#msg874683">Source: Forum</a>
attr DEVICE userattr reading01Name reading01XPath-Strict reading02Name reading02XPath-Strict reading03Name reading03XPath-Strict reading04Name reading04XPath-Strict reading05Name reading05XPath-Strict
attr DEVICE httpVersion 1.1
attr DEVICE reading01Name Model
attr DEVICE reading01XPath-Strict //dd:MakeAndModel/text()
attr DEVICE reading02Name Serial_Number
attr DEVICE reading02XPath-Strict //dd:SerialNumber/text()
attr DEVICE reading03Name Firmware_Date
attr DEVICE reading03XPath-Strict //dd:Date/text()
attr DEVICE reading04Name Total_Memory
attr DEVICE reading04XPath-Strict //dd:TotalMemory/text()
attr DEVICE reading05Name Available_Memory
attr DEVICE reading05XPath-Strict //dd:AvailableMemory/text()
attr DEVICE stateFormat Modell: Model SN: Serial_Number
attr DEVICE userReadings Memory_Usage {100-(ReadingsNum("DEVICE","Available_Memory","")/2.56)}
attr DEVICE model B_01a_hp_printer_config

# Printer cartridge states
name:B_01a_hp_printer_cartridge_status
filter:TYPE=HTTPMOD
desc: Get cartridge states of your hp printer.<br>Define a HTTPMOD device like <br>defmod DEVICE HTTPMOD http://192.168.5.43/DevMgmt/ProductConfigDyn.xml 3600 <br>Change IP to your needs <br><a href="https://forum.fhem.de/index.php/topic,90601.msg874683.html#msg874683">Source: Forum</a>
attr DEVICE userattr reading01Name reading01XPath-Strict reading02Name reading02XPath-Strict reading03Name reading03XPath-Strict reading04Name reading04XPath-Strict
attr DEVICE httpVersion 1.1
attr DEVICE reading01Name Cyan
attr DEVICE reading01XPath-Strict //ccdyn:ConsumableInfo[2]/dd:ConsumablePercentageLevelRemaining/text()
attr DEVICE reading02Name Magenta
attr DEVICE reading02XPath-Strict //ccdyn:ConsumableInfo[3]/dd:ConsumablePercentageLevelRemaining/text()
attr DEVICE reading03Name Yellow
attr DEVICE reading03XPath-Strict //ccdyn:ConsumableInfo[4]/dd:ConsumablePercentageLevelRemaining/text()
attr DEVICE reading04Name Black
attr DEVICE reading04XPath-Strict //ccdyn:ConsumableInfo[1]/dd:ConsumablePercentageLevelRemaining/text()
attr DEVICE stateFormat C: Cyan% M: Magenta% Y: Yellow% B: Black%
attr DEVICE model B_01a_hp_printer_cartridge_status

# Printer statistics
name:B_01a_hp_printer_statistics
filter:TYPE=HTTPMOD
desc: Get cartridge states of your hp printer.<br>Define a HTTPMOD device like <br>defmod DEVICE HTTPMOD http://192.168.5.43/DevMgmt/ProductUsageDyn.xml 3600<br>Change IP to your needs <br><a href="https://forum.fhem.de/index.php/topic,90601.msg874683.html#msg874683">Source: Forum</a>
attr DEVICE userattr reading01Name reading01XPath-Strict reading02Name reading02XPath-Strict reading03Name reading03XPath-Strict reading04Name reading04XPath-Strict reading05Name reading05XPath-Strict reading06Name reading06XPath-Strict reading07Name reading07XPath-Strict reading08Name reading08XPath-Strict
attr DEVICE httpVersion 1.1
attr DEVICE reading01Name Pages_Total
attr DEVICE reading01XPath-Strict //pudyn:PrinterSubunit/dd:TotalImpressions/text()
attr DEVICE reading02Name Pages_Monochrome
attr DEVICE reading02XPath-Strict //pudyn:PrinterSubunit/dd:MonochromeImpressions/text()
attr DEVICE reading03Name Pages_Color
attr DEVICE reading03XPath-Strict //pudyn:PrinterSubunit/dd:ColorImpressions/text()
attr DEVICE reading04Name Pages_Duplex
attr DEVICE reading04XPath-Strict //pudyn:PrinterSubunit/dd:DuplexSheets/text()
attr DEVICE reading05Name Jam_Events
attr DEVICE reading05XPath-Strict //pudyn:PrinterSubunit/dd:JamEvents/text()
attr DEVICE reading06Name Mispick_Events
attr DEVICE reading06XPath-Strict //pudyn:PrinterSubunit/dd:MispickEvents/text()
attr DEVICE reading07Name ADF_Image_Scans
attr DEVICE reading07XPath-Strict //pudyn:ScannerEngineSubunit/dd:AdfImages/text()
attr DEVICE reading08Name Flatbed_Image_Scans
attr DEVICE reading08XPath-Strict //pudyn:ScannerEngineSubunit/dd:FlatbedImages/text()
attr DEVICE stateFormat Total: Pages_Total Monochrome: Pages_Monochrome Color: Pages_Color
attr DEVICE model B_01a_hp_printer_statistics

# Printer status
name:B_01a_hp_printer_status
filter:TYPE=HTTPMOD
desc: Get status of your hp printer.<br>Define a HTTPMOD device like <br>defmod DEVICE HTTPMOD http://192.168.5.43/DevMgmt/ProductStatusDyn.xml 60 <br>Change IP to your needs <br><a href="https://forum.fhem.de/index.php/topic,90601.msg874683.html#msg874683">Source: Forum</a>
attr DEVICE userattr reading01Name reading01XPath-Strict
attr DEVICE httpVersion 1.1
attr DEVICE reading01Name Status
attr DEVICE reading01XPath-Strict //psdyn:LocString[@lang='de']/text()
attr DEVICE stateFormat Status
attr DEVICE model B_01a_hp_printer_status


#################################
#Epson Printers
#
# Forum: https://forum.fhem.de/index.php/topic,90601.msg872234.html#msg872234

# Printer cartridge states
name:B_01b_epson_printer_cartridge_status
filter:TYPE=HTTPMOD
desc: Get cartridge states of your Epson printer.<br>Define a HTTPMOD device like <br>defmod DEVICE HTTPMOD http://192.168.188.25/PRESENTATION/HTML/TOP/PRTINFO.HTML 3600<br>Change IP to your needs <br><a href="https://forum.fhem.de/index.php/topic,90601.msg874683.html#msg874683">Source: Forum</a>
attr DEVICE reading01Name Yellow
attr DEVICE reading01Regex Ink_Y.*?='([\d]+)'
attr DEVICE reading02Name Cyan
attr DEVICE reading02Regex Ink_C.*?='([\d]+)'
attr DEVICE reading03Name Magenta
attr DEVICE reading03Regex Ink_M.*?='([\d]+)'
attr DEVICE reading04Name Black
attr DEVICE reading04Regex Ink_B.*?='([\d]+)'
attr DEVICE stateFormat C: Cyan% M: Magenta% Y: Yellow% B: Black%
attr DEVICE model B_01b_epson_printer_cartridge_status

#################################
#Brother Printers
#
# Forum: https://forum.fhem.de/index.php/topic,97483.msg908461.html#msg908461

# Printer cartridge states
name:B_01c_brother_printer_cartridge_status
filter:TYPE=HTTPMOD
desc: Get cartridge states of your Brother printer.<br>Define a HTTPMOD device like <br>defmod DEVICE HTTPMOD http://192.168.178.6/general/information.html 3600<br>Change IP to your needs <br><a href="https://forum.fhem.de/index.php/topic,97483.msg908461.html#msg908461">Source: Forum</a><br>Tested with MFC-9142CDN, should work with DCP-9015 CDW DCP-9020 HL-3140 CW HL-3150 CDN HL-3170 MFC-9130 MFC-9140 MFC-9330 MFC-9340
attr DEVICE userattr reading01Name reading01Regex reading02Name reading02Regex reading03Name reading03Regex reading04Name reading04Regex
attr DEVICE httpVersion 1.1
attr DEVICE reading01Name Yellow
attr DEVICE reading01Regex \(Y\)\*\*.{9}\((\d{1,3}\.\d{1,2})%\)
attr DEVICE reading02Name Cyan
attr DEVICE reading02Regex \(C\)\*\*.{9}\((\d{1,3}\.\d{1,2})%\)
attr DEVICE reading03Name Magenta
attr DEVICE reading03Regex \(M\)\*\*.{9}\((\d{1,3}\.\d{1,2})%\)
attr DEVICE reading04Name Black
attr DEVICE reading04Regex \(BK\)\*\*.{9}\((\d{1,3}\.\d{1,2})%\)
attr DEVICE room Steuerung->Unused_Devices
attr DEVICE stateFormat C: Cyan% M: Magenta% Y: Yellow% B: Black%
attr DEVICE reading05Name Status
attr DEVICE reading05RegOpt gm
attr DEVICE reading05Regex <th>1<\/th><td>(.*?)<
attr DEVICE model B_01c_brother_printer_cartridge_status

#RESOL Solaranlage, Forum: https://forum.fhem.de/index.php/topic,86678.0.html
name:C_01a_resol_solar
filter:TYPE=HTTPMOD
desc: Get data from your RESOL solar installation<br>Define a HTTPMOD device like <br>define Solar HTTPMOD http://192.178.002.112/dl2/live/data 300 <br><a href="https://forum.fhem.de/index.php/topic,86678.0.html">Source: Forum</a>
attr DEVICE userattr reading01Name reading01Regex reading02Name reading02Regex reading03Name reading03Regex reading04Name reading04Regex reading05Name reading05Regex reading06Name reading06Regex timeout
attr DEVICE group A_Energy
attr DEVICE reading01Name Temperatur_Sensor1
attr DEVICE reading01Regex Temperatur Sensor 1:[^0-9]+([0-9\.]+)
attr DEVICE reading02Name Temperatur_Sensor2
attr DEVICE reading02Regex Temperatur Sensor 2:[^0-9]+([0-9\.]+)
attr DEVICE reading03Name Temperatur_Sensor3
attr DEVICE reading03Regex Temperatur Sensor 3[^0-9]+([0-9\.]+)
attr DEVICE reading04Name Temperatur_Sensor4
attr DEVICE reading04Regex Temperatur Sensor 4[^0-9]+([0-9\.]+)
attr DEVICE reading05Name Drehzahl_Pumpe
attr DEVICE reading05Regex Drehzahl Pumpe 1[^0-9]+([0-9\.]+)
attr DEVICE reading06Name Betriebsstunden
attr DEVICE reading06Regex Betriebsstunden Relais 1[^0-9]+([0-9\.]+)
attr DEVICE room 01 Heizungsraum
attr DEVICE stateFormat Dachtemperatur: Temperatur_Sensor1 Drehzahl Pumpe: Drehzahl_Pumpe Laufzeit Heute: Tageslaufzeit
attr DEVICE timeout 5ercent="([\d\.]+)
attr DEVICE model C_01a_resol_solar

