Pi-Hole : Statistiken in Fhem anzeigen

Begonnen von Solala0815, 02 Juli 2023, 09:57:03

Vorheriges Thema - Nächstes Thema

Solala0815

Moin,
wollte dieses Wochenende PiHole in FHEM integrieren und bin nach
dem gleichnamigen Thema in Codesnipsel vorgegangen.
Den Code den ich verwendet habe ist von "Benni" aus #44, in die 99_myUtils.pm wurde der Code aus #33 verwendet.
Die Anzeige über Updates funktioniert, leider werden keine weiteren Daten angezeigt.

Scheiter tut das ganze an der Eingabe des Tokens, die Eingabe
set pihole storeKeyValue pihole-token <Token>wird mit "Unknown argument storeKeyValue, choose one of disable enable attrTemplate" quittiert.
Es wurden auch andere Schreibweisen versucht, keine führte zum Erfolg.
Hoffe ihr könnt Licht in die Dunkelheit bringen wie ich den Token hinterlegen kann.
LG Tom


MadMax-FHEM

Warum nach Codeschnipsel verschoben?
Ja du hast aus Codeschnipsel "geklaut" aber in CodeSchnipsel stehen funktionierende Schnipsel...

EDIT: ok, war wohl andersrum? Egal...

Warum einen EXTRA Thread und nicht dort gefragt, wo du "geklaut" hast?

Gibst du das einfach per FhemWeb ein (verm.), was steht denn neben dem Device in der "DropDown" Box?

Wie wäre es mit einem list des Devices?

Ja du schreibst wo du es her hast...
...aber auch bei "copy/paste" kann was schief laufen...

Schon mal einen fhem Restart gemacht?
Refresh der Device-Detail-Seite nach dem Anlegen?

Gruß, Joachim
FHEM PI3B+ Bullseye: HM-CFG-USB, 40x HM, ZWave-USB, 13x ZWave, EnOcean-PI, 15x EnOcean, HUE/deCONZ, CO2, ESP-Multisensor, Shelly, alexa-fhem, ...
FHEM PI2 Buster: HM-CFG-USB, 25x HM, ZWave-USB, 4x ZWave, EnOcean-PI, 3x EnOcean, Shelly, ha-bridge, ...
FHEM PI3 Buster (Test)

Solala0815

Hallo MadMax-FHEM,

im Device steht unter set nur "attrTemplate, disable, enable"
das war mein erster Gedanke. ;-)
Anschließend Eingabe im FhemWeb.

Wie gewünscht der Code:
defmod pihole HTTPMOD none 60
attr pihole alias Pi-Hole
attr pihole devStateIcon {piholeDevStateIcon($name)}
attr pihole enforceGoodReadingNames 1
attr pihole event-on-change-reading .*
attr pihole get01ExtractAllJSON 1
attr pihole get01Name summary
attr pihole get01Poll 1
attr pihole get01URL %%api_url%%?summaryRaw&%%auth%%
attr pihole get02ExtractAllJSON 1
attr pihole get02Name versions
attr pihole get02Poll 1
attr pihole get02PollDelay 3600
attr pihole get02URL %%api_url%%?versions&%%auth%%
attr pihole get03JSON status
attr pihole get03Name FTL_status
attr pihole get03URL %%api_url%%?status&%%auth%%
attr pihole get04JSON type
attr pihole get04Name FTL_type
attr pihole get04URL %%api_url%%?type&%%auth%%
attr pihole get05JSON version
attr pihole get05Name FTL_version
attr pihole get05URL %%api_url%%?version&%%auth%%
attr pihole group System
attr pihole icon it_raspberry_logo
attr pihole replacement01Mode text
attr pihole replacement01Regex %%auth%%
attr pihole replacement01Value auth=%%pihole-token%%
attr pihole replacement02Mode key
attr pihole replacement02Regex %%pihole-token%%
attr pihole replacement02Value pihole-token
attr pihole replacement03Mode text
attr pihole replacement03Regex %%api_url%%
attr pihole replacement03Value %%base_url%%/api.php
attr pihole replacement04Mode text
attr pihole replacement04Regex %%base_url%%
attr pihole replacement04Value http://%%ip%%/admin
attr pihole replacement05Mode text
attr pihole replacement05Regex %%ip%%
attr pihole replacement05Value 192.168.100.10
attr pihole room Allgemein->Netzwerk,Uebersicht
attr pihole set01ExtractAllJSON 1
attr pihole set01Hint 10,60,180,300,600,900
attr pihole set01Max 900
attr pihole set01Min 10
attr pihole set01Name disable
attr pihole set01ParseResponse 1
attr pihole set01URL %%api_url%%?disable=$val&%%auth%%
attr pihole set02ExtractAllJSON 1
attr pihole set02Name enable
attr pihole set02NoArg 1
attr pihole set02ParseResponse 1
attr pihole set02URL %%api_url%%?enable&%%auth%%
attr pihole stateFormat status
attr pihole userReadings gravity_last_updated_abstime:gravity_last_updated_absolute.* {strftime('%Y-%m-%d %H:%M:%S', localtime(ReadingsNum($name,'gravity_last_updated_absolute',0)))}
attr pihole verbose 3

setstate pihole status
setstate pihole 2023-07-02 09:51:51 FTL_branch master
setstate pihole 2023-07-02 09:51:51 FTL_current v5.23
setstate pihole 2023-07-02 09:51:51 FTL_latest v5.23
setstate pihole 2023-07-02 09:51:51 FTL_update 0
setstate pihole 2023-07-02 09:51:51 core_branch master
setstate pihole 2023-07-02 09:51:51 core_current v5.17.1
setstate pihole 2023-07-02 09:51:51 core_latest v5.17.1
setstate pihole 2023-07-02 09:51:51 core_update 0
setstate pihole 2023-07-02 09:51:51 web_branch master
setstate pihole 2023-07-02 09:51:51 web_current v5.20.1
setstate pihole 2023-07-02 09:51:51 web_latest v5.20.1
setstate pihole 2023-07-02 09:51:51 web_update 0

Noch schnell auf Verbose 5
2023.07.02 10:11:00 5: pihole: HandleSendQueue found no usable entry in queue
2023.07.02 10:11:00 5: pihole: HandleSendQueue called from ReadCallback, qlen = 0
2023.07.02 10:11:00 4: pihole: Read response to get01 didn't match any Reading
2023.07.02 10:11:00 5: pihole: Read starts parsing response to get01 with defined readings:
2023.07.02 10:11:00 3: pihole: no parsed JSON structure available
2023.07.02 10:11:00 5: pihole: ExtractReading for context get, num 01 - no individual parse definition
2023.07.02 10:11:00 5: pihole: CheckAuth decided no authentication required
2023.07.02 10:11:00 5: pihole: Read callback sets LAST_REQUEST to get01
2023.07.02 10:11:00 5: pihole: ExtractSid called, context get, num 01
2023.07.02 10:11:00 4: pihole: extracted JSON values to internal
2023.07.02 10:11:00 5: pihole: JSON Flatter called : prefix , ref is ARRAY(0x564254dc93b0)
2023.07.02 10:11:00 4: pihole: BodyDecode is not decoding the response body (charset not found, bodyDecode defaults to none)
[]
2023.07.02 10:11:00 5: pihole: Read callback: body
Server: lighttpd/1.4.63, body length 2
Date: Sun, 02 Jul 2023 10:11:00 GMT
Connection: close
Content-Length: 2
Referrer-Policy: same-origin
X-Permitted-Cross-Domain-Policies: none
Content-Security-Policy: default-src 'self' 'unsafe-inline';
X-Content-Type-Options: nosniff
X-XSS-Protection: 0
X-Frame-Options: DENY
X-Pi-hole: The Pi-hole Web interface is working!
Content-type: application/json
Set-Cookie: PHPSESSID=fkp497674vtqf0gij2t2p7bgaf; path=/; HttpOnly; SameSite=Strict
Pragma: no-cache
Cache-Control: no-store, no-cache, must-revalidate
Expires: Thu, 19 Nov 1981 08:52:00 GMT
header: HTTP/1.0 200 OK
2023.07.02 10:11:00 4: pihole: Read callback: request type was get01 retry 0,
2023.07.02 10:11:00 5: pihole: ReadCallback called from __ANON__
2023.07.02 10:11:00 5: pihole: GetUpdate will skip versions, delay not over
2023.07.02 10:11:00 5: pihole: GetUpdate checks if poll required for versions (02)
2023.07.02 10:11:00 4: pihole: HandleSendQueue sends get01 with timeout 2 to http://192.168.100.10/admin/api.php?summaryRaw&auth=, No Data, No Header
2023.07.02 10:11:00 5: pihole: Replace: match for type get01, regex (?^:%%ip%%), mode text, value 192.168.100.10, input: %%api_url%%?summaryRaw&%%auth%%, result is http://192.168.100.10/admin/api.php?summaryRaw&auth=
2023.07.02 10:11:00 5: pihole: Replace called for type get01, regex (?^:%%ip%%), mode text, value 192.168.100.10 input: http://%%ip%%/admin/api.php?summaryRaw&auth=
2023.07.02 10:11:00 5: pihole: Replace: match for type get01, regex (?^:%%base_url%%), mode text, value http://%%ip%%/admin, input: %%api_url%%?summaryRaw&%%auth%%, result is http://%%ip%%/admin/api.php?summaryRaw&auth=
2023.07.02 10:11:00 5: pihole: Replace called for type get01, regex (?^:%%base_url%%), mode text, value http://%%ip%%/admin input: %%base_url%%/api.php?summaryRaw&auth=
2023.07.02 10:11:00 5: pihole: Replace: match for type get01, regex (?^:%%api_url%%), mode text, value %%base_url%%/api.php, input: %%api_url%%?summaryRaw&%%auth%%, result is %%base_url%%/api.php?summaryRaw&auth=
2023.07.02 10:11:00 5: pihole: Replace called for type get01, regex (?^:%%api_url%%), mode text, value %%base_url%%/api.php input: %%api_url%%?summaryRaw&auth=
2023.07.02 10:11:00 5: pihole: Replace: match for type get01, regex (?^:%%pihole-token%%), mode key, value pihole-token, input: %%api_url%%?summaryRaw&%%auth%%, result is %%api_url%%?summaryRaw&auth=
2023.07.02 10:11:00 5: pihole: Replace: key pihole-token value is
2023.07.02 10:11:00 4: pihole: ReadKeyValue could not find key pihole-token in file
2023.07.02 10:11:00 5: pihole: ReadKeyValue tries to read value for pihole-token from file
2023.07.02 10:11:00 5: pihole: Replace called for type get01, regex (?^:%%pihole-token%%), mode key, value pihole-token input: %%api_url%%?summaryRaw&auth=%%pihole-token%%
2023.07.02 10:11:00 5: pihole: Replace: match for type get01, regex (?^:%%auth%%), mode text, value auth=%%pihole-token%%, input: %%api_url%%?summaryRaw&%%auth%%, result is %%api_url%%?summaryRaw&auth=%%pihole-token%%
2023.07.02 10:11:00 5: pihole: Replace called for type get01, regex (?^:%%auth%%), mode text, value auth=%%pihole-token%% input: %%api_url%%?summaryRaw&%%auth%%
2023.07.02 10:11:00 5: pihole: HandleSendQueue called from AddToSendQueue, qlen = 1
2023.07.02 10:11:00 5: pihole: AddToQueue adds type get01 to URL %%api_url%%?summaryRaw&%%auth%%, no data, no headers, retry 0, initial queue len: 0
2023.07.02 10:11:00 4: pihole: GetUpdate will request summary
2023.07.02 10:11:00 5: pihole: GetUpdate checks if poll required for summary (01)
2023.07.02 10:11:00 4: pihole: UpdateTimer called from GetUpdate with cmd next sets timer to call update function in 60.0 sec at 10:12:00.869, interval 60
2023.07.02 10:11:00 4: pihole: GetUpdate called (update)
2023.07.02 10:10:49 1: ===================

und wenn ich dieses ausführe kommen Daten zurück
http://<SERVER>/admin/api.php?summary&auth=<TOKEN>

Solala0815

und bei Verbose 3 kommt nur diese Meldung
2023.07.02 10:22:01 3: pihole: no parsed JSON structure available
2023.07.02 10:21:42 1: ===================
2023.07.02 10:21:24 1: 

MadMax-FHEM

Also ich sag mal so:
ich habe EXAKT DEINE gepostete DEF genommen und ich bekomme es per DropDown angeboten...

Wie aktuell ist dein fhem?

Gruß, Joachim
FHEM PI3B+ Bullseye: HM-CFG-USB, 40x HM, ZWave-USB, 13x ZWave, EnOcean-PI, 15x EnOcean, HUE/deCONZ, CO2, ESP-Multisensor, Shelly, alexa-fhem, ...
FHEM PI2 Buster: HM-CFG-USB, 25x HM, ZWave-USB, 4x ZWave, EnOcean-PI, 3x EnOcean, Shelly, ha-bridge, ...
FHEM PI3 Buster (Test)

Solala0815

Läuft auf Proxmox und wurde vor ca. 4 Monaten aufgesetzt.
Gestern oder Vorgestern ein Update gefahren.
Heute ein Update-Check sagt "nichts zu tun".

MadMax-FHEM

Dann würde ich mal ins Unterforum zu HTTPMOD verschieben, weil wie geschrieben: als RawDef eingefügt und mir wird der Menüpunkt angezeigt...

Zitat von: help HTTPMODModule: 98_HTTPMOD.pm Maintainer: StefanStrobel Forum: Sonstiges

Steht/stand etwas im fhem Log beim Anlegen?
Evtl. noch mal löschen und neu anlegen...

Gruß, Joachim
FHEM PI3B+ Bullseye: HM-CFG-USB, 40x HM, ZWave-USB, 13x ZWave, EnOcean-PI, 15x EnOcean, HUE/deCONZ, CO2, ESP-Multisensor, Shelly, alexa-fhem, ...
FHEM PI2 Buster: HM-CFG-USB, 25x HM, ZWave-USB, 4x ZWave, EnOcean-PI, 3x EnOcean, Shelly, ha-bridge, ...
FHEM PI3 Buster (Test)

Solala0815

Joachim, herzlichen Dank für deine Hilfe.
Einen schönen Sonntag.

LG Tom

PS: wird ins 98_HTTPMOD verschoben.

Solala0815

#8
Moin,
es gibt ein kleines Problem mit der eingabe eines Passwortes.
Die Vermutung besteht dass es mit
98_HTTPMOD.pmzusammenhägt oder eine Lösung gibt.

Solala0815

Moin,
habe einen Raspi neu aufgesetzt und FHEM installiert.
Auch hier wir mir bei der Installation des piHole-Device
keine Eingabe des Passwortes angeboten.
Fehlt evtl. eine Zusatzinstalation ?

MadMax-FHEM

Steht denn was im Log?

Welche Plattform?
HW/OS

Welche Version von HTTPMOD?
Bei mir:
Zitat von: version98_HTTPMOD.pm         27065 2023-01-15 17:33:44Z StefanStrobel

Gruß, Joachim
FHEM PI3B+ Bullseye: HM-CFG-USB, 40x HM, ZWave-USB, 13x ZWave, EnOcean-PI, 15x EnOcean, HUE/deCONZ, CO2, ESP-Multisensor, Shelly, alexa-fhem, ...
FHEM PI2 Buster: HM-CFG-USB, 25x HM, ZWave-USB, 4x ZWave, EnOcean-PI, 3x EnOcean, Shelly, ha-bridge, ...
FHEM PI3 Buster (Test)

JoWiemann

Zitat von: Solala0815 am 02 Juli 2023, 09:57:03Scheiter tut das ganze an der Eingabe des Tokens, die Eingabe
set pihole storeKeyValue pihole-token <Token>wird mit "Unknown argument storeKeyValue, choose one of disable enable attrTemplate" quittiert.

Hallo Tom,

das set ... storeKeyValue ist erst verfügbar wenn attr enableControlSet aktiviert worden ist. Ab featurelevel > 5.9 von HTTPMOD ist das per default aktiviert. Also, entweder hast Du enableControlSet deaktiviert oder das Modul HTTPMOD ist nicht aktuell.

Grüße Jörg
Jörg Wiemann

Slave: RPi B+ mit 512 MB, COC (868 MHz), CUL V3 (433.92MHz SlowRF); FHEMduino, Aktuelles FHEM

Master: CubieTruck; Debian; Aktuelles FHEM

Solala0815

Danke JoWiemann,
das war es. Habe es bei PiHole eingetragen und es läuft.
Raspberry wurde gestern neu aufgesetzt, FHEM6.2 installiert und upgedatet.
Der Proxmox wurde vor 4 Monaten augesetzt und immer wieder alle Programme aktuell gehalten.

LG Tom