Seite 1 von 1

ALLNET ALL4176 via HTTP in OH3.x konfigurieren

Verfasst: 28. Apr 2023 11:32
von Homer-S
Hallo zusammen,
ich bin meinem Umzug von 2.5 auf 3.4.3 fast fertig, es fehlen nur noch SMA Wechselrichter und die hier zu behandelnde ALL4176

Ich habe von @branchweiler den Post (viewtopic.php?p=39758&sid=0f9b01b2dca27 ... e5e#p39758) gefunden, aber ich bekomme es leider nicht hin und es sind zu viele Blockaden im Moment da, die ich gerne mit eurer Hilfe auflösen würde

Im OH2 ist das meine laufende Konfiguration:

Items:

Code: Alles auswählen

 /* ALL4176 im Serverschrank */
Switch ALL4176_Relais1        "SRV-Proxmox"      <switchoffice>   (gKE_Technikraum)    { http=">[ON:POST:http://192.168.100.229/xml/jsonswitch.php?id=1&set=1{Authorization=Basic aG9tZXI6Y2RlM1ZGUiQ=}] >[OFF:POST:http://192.168.100.229/xml/jsonswitch.php?id=1&set=0{Authorization=Basic aG9tZXI6Y2RlM1ZGUiQ=}]" }
Switch ALL4176_Relais1Status  "Relais 1 [%s]"               { http="<[ALL4176_StatusCache:1000:JS(ALL4176switch_1.js)]" }
Switch ALL4176_Relais2        "Leer"      <switchoffice>   (gKE_Technikraum)    { http=">[ON:POST:http://192.168.100.229/xml/jsonswitch.php?id=2&set=1{Authorization=Basic aG9tZXI6Y2RlM1ZGUiQ=}] >[OFF:POST:http://192.168.100.229/xml/jsonswitch.php?id=2&set=0{Authorization=Basic aG9tZXI6Y2RlM1ZGUiQ=}]" }
Switch ALL4176_Relais2Status  "Relais 2 [%s]"               { http="<[ALL4176_StatusCache:1000:JS(ALL4176switch_2.js)]" }
Switch ALL4176_Relais3        "Switch Zyxel"      <switchoffice>   (gKE_Technikraum)    { http=">[ON:POST:http://192.168.100.229/xml/jsonswitch.php?id=3&set=1{Authorization=Basic aG9tZXI6Y2RlM1ZGUiQ=}] >[OFF:POST:http://192.168.100.229/xml/jsonswitch.php?id=3&set=0{Authorization=Basic aG9tZXI6Y2RlM1ZGUiQ=}]" }
Switch ALL4176_Relais3Status  "Relais 3 [%s]"               { http="<[ALL4176_StatusCache:1000:JS(ALL4176switch_3.js)]" }
Switch ALL4176_Relais4        "Fritz Repeater"      <switchoffice>  (gKE_Technikraum)     { http=">[ON:POST:http://192.168.100.229/xml/jsonswitch.php?id=4&set=1{Authorization=Basic aG9tZXI6Y2RlM1ZGUiQ=}] >[OFF:POST:http://192.168.100.229/xml/jsonswitch.php?id=4&set=0{Authorization=Basic aG9tZXI6Y2RlM1ZGUiQ=}]" }
Switch ALL4176_Relais4Status  "Relais 4 [%s]"               { http="<[ALL4176_StatusCache:1000:JS(ALL4176switch_4.js)]" }
Switch ALL4176_Relais5        "Switch Cisco"      <switchoffice>  (gKE_Technikraum)    { http=">[ON:POST:http://192.168.100.229/xml/jsonswitch.php?id=5&set=1{Authorization=Basic aG9tZXI6Y2RlM1ZGUiQ=}] >[OFF:POST:http://192.168.100.229/xml/jsonswitch.php?id=5&set=0{Authorization=Basic aG9tZXI6Y2RlM1ZGUiQ=}]" }
Switch ALL4176_Relais5Status  "Relais 5 [%s]"               { http="<[ALL4176_StatusCache:1000:JS(ALL4176switch_5.js)]" }
Switch ALL4176_Relais6        "Video Card"      <switchoffice>   (gKE_Technikraum)    { http=">[ON:POST:http://192.168.100.229/xml/jsonswitch.php?id=6&set=1{Authorization=Basic aG9tZXI6Y2RlM1ZGUiQ=}] >[OFF:POST:http://192.168.100.229/xml/jsonswitch.php?id=6&set=0{Authorization=Basic aG9tZXI6Y2RlM1ZGUiQ=}]" }
Switch ALL4176_Relais6Status  "Relais 6 [%s]"               { http="<[ALL4176_StatusCache:1000:JS(ALL4176switch_6.js)]" }

Number:ElectricPotential ALL4176_Voltage   "Voltage [%.2f V]"    <ownvoltage>   (gKE_Technikraum)    { http="<[ALL4176_StatusCache:10000:JSONPATH($[?(@.id == '14')].value)]" }
Number:ElectricCurrent   ALL4176_Current   "Current [%.2f A]"    <ownvoltage>   (gKE_Technikraum)    { http="<[ALL4176_StatusCache:10000:JSONPATH($[?(@.id == '15')].value)]" }
Number:Power             ALL4176_Power     "IT Power [%.2f W]"   <ownvoltage>   (gKE_Technikraum,gStromverbrauchmessung)    { http="<[ALL4176_StatusCache:10000:JSONPATH($[?(@.id == '16')].value)]" }
Number:Frequency         ALL4176_Frequency "Frequency [%.2f Hz]" <ownvoltage>   (gKE_Technikraum)    { http="<[ALL4176_StatusCache:10000:JSONPATH($[?(@.id == '18')].value)]" }
Dazu gibt es diese RULE:

Code: Alles auswählen

rule "Update ALL4176 Relais status from hardware"
when
    Item ALL4176_Relais1Status changed or
    Item ALL4176_Relais2Status changed or
    Item ALL4176_Relais3Status changed or
    Item ALL4176_Relais4Status changed or
    Item ALL4176_Relais5Status changed or
    Item ALL4176_Relais6Status changed or
    Time cron "0 */1 * * * ?"
then
    if(ALL4176_Relais1Status.state != ALL4176_Relais1.state)   { ALL4176_Relais1.postUpdate(ALL4176_Relais1Status.state) }
    if(ALL4176_Relais2Status.state != ALL4176_Relais2.state)   { ALL4176_Relais2.postUpdate(ALL4176_Relais2Status.state) }
    if(ALL4176_Relais3Status.state != ALL4176_Relais3.state)   { ALL4176_Relais3.postUpdate(ALL4176_Relais3Status.state) }
    if(ALL4176_Relais4Status.state != ALL4176_Relais4.state)   { ALL4176_Relais4.postUpdate(ALL4176_Relais4Status.state) }
    if(ALL4176_Relais5Status.state != ALL4176_Relais5.state)   { ALL4176_Relais5.postUpdate(ALL4176_Relais5Status.state) }
    if(ALL4176_Relais6Status.state != ALL4176_Relais6.state)   { ALL4176_Relais6.postUpdate(ALL4176_Relais6Status.state) }
end
unter transform Folder jeweils eine js Datei
Dateiname: ALL4176switch_x.js wobei x von 1-6 gezählt wird
mit diesem Inhalt:

Code: Alles auswählen

(function(dataString) {
    var data = JSON.parse(dataString);
    var value = 'UNDEF';
    for (var i = 0; i < data.length; i++) {
        if (data[i].id == '1') {
            value = data[i].value;
            break;
        }
    }
    if (value != 'UNDEF') {
        if (value == '0.00') {
            value = 'OFF';
        } else {
            value = 'ON';
        }
    }
    return value;
})(input)
unter services Folder:
http.cfg

Code: Alles auswählen

ALL4176_StatusCache.url=http://192.168.100.229/xml/json.php?mode=all{Authorization=Basic aG9tZXI6Y2RlM1ZGUiQ=}
ALL4176_StatusCache.updateInterval=1000

Unter OH3 habe ich ein HTTP Thing angelegt und ich kann die Ports auch mit dem verlinkten Item schalten, aber ich bekomme weder den Status des Switch stabil hin (ändert sich immer wieder auf NULL) und die Verbrauchswerte hab ich noch gar keine Idee

Code: Alles auswählen

UID: http:url:doseserverschrank
label: HTTP_Dose_Serverschrank
thingTypeUID: http:url
configuration:
  authMode: BASIC
  ignoreSSLErrors: false
  baseURL: http://192.168.100.229/xml/jsonswitch.php
  password: abcdefg
  delay: 0
  stateMethod: GET
  refresh: 30
  commandMethod: POST
  contentType: application/json
  timeout: 3000
  bufferSize: 2048
  username: hans
channels:
  - id: dose1
    channelTypeUID: http:switch
    label: Dose1 Server
    description: ""
    configuration:
      onValue: "1"
      offValue: "0"
      stateExtension: ?id=1
      commandExtension: ?id=1&set=%2$s
  - id: dose2
    channelTypeUID: http:switch
    label: Dose2 RPi-Keller
    description: null
    configuration:
      onValue: "1"
      offValue: "0"
      stateExtension: ?id=2
      commandExtension: ?id=2&set=%2$s
  - id: dose3
    channelTypeUID: http:switch
    label: Dose3 SWITCH-Zyxel
    description: null
    configuration:
      onValue: "1"
      offValue: "0"
      stateExtension: ?id=3
      commandExtension: ?id=3&set=%2$s
      stateTransformation: JSONPATH:$.result.status
  - id: dose4
    channelTypeUID: http:switch
    label: Dose4 Repeater
    description: null
    configuration:
      onValue: "1"
      offValue: "0"
      stateExtension: ?id=4
      commandExtension: ?id=4&set=%2$s
      stateTransformation: JSONPATH:$.result.status
  - id: dose5
    channelTypeUID: http:switch
    label: Dose5 SWITCH-Cisco
    description: null
    configuration:
      onValue: "1"
      offValue: "0"
      stateExtension: ?id=5
      commandExtension: ?id=5&set=%2$s
      stateTransformation: JSONPATH:$.result.status
  - id: dose6
    channelTypeUID: http:switch
    label: Dose6 Videocard
    description: null
    configuration:
      onValue: "1"
      offValue: "0"
      stateExtension: ?id=6
      commandExtension: ?id=6&set=%2$s
      stateTransformation: JSONPATH:$.result.status

Ich hoffe ihr habt eine Idee wie man das zum Laufen bekommt.
Danke

Re: ALLNET ALL4176 via HTTP in OH3.x konfigurieren

Verfasst: 28. Apr 2023 12:22
von Homer-S
Vielleicht sollte ich noch dazu schreiben, dass mir das wichtigste die Daten der Steckdose wären, also mit Prio 1:
das Item:
Number:Power ALL4176_Power "IT Power [%.2f W]"

Re: ALLNET ALL4176 via HTTP in OH3.x konfigurieren

Verfasst: 28. Apr 2023 14:18
von Homer-S
Ein halbes JUHU.
Die Powerwerte etc hab ich ausgelsen bekommen. Falls es jemand nochmal braucht:

Code: Alles auswählen

UID: http:url:doseserverschrankdaten
label: HTTP_Dose_Serverschrank_Daten
thingTypeUID: http:url
configuration:
  authMode: BASIC
  ignoreSSLErrors: false
  baseURL: http://192.168.100.229/xml/json.php?mode=all
  delay: 0
  stateMethod: GET
  refresh: 30
  commandMethod: GET
  contentType: application/json
  timeout: 3000
  bufferSize: 2048
channels:
  - id: power
    channelTypeUID: http:number
    label: Dose Power
    description: ""
    configuration:
      stateTransformation: JSONPATH:$[?(@.id == '16')].value

Jetzt gehts nur noch um die Statusanzeigen

Wie bekomme ich das : realisiert?

{ http="<[ALL4176_StatusCache:1000:JS(ALL4176switch_1.js)]" }

Re: ALLNET ALL4176 via HTTP in OH3.x konfigurieren

Verfasst: 28. Apr 2023 16:10
von Homer-S
Es ist gelöst,

manchmal hilft es wenn man sich die Fragestellung deutlich aufschreibt.
Wie markiert man das als Solved?

Der Lösungstrick ist, die Base URL genereller zu stellen und in den channels die beiden Wege Command und Status anders abzufragen

Re: ALLNET ALL4176 via HTTP in OH3.x konfigurieren

Verfasst: 28. Apr 2023 16:55
von udo1toni
Ja, manchmal hilft es auch, nur die eigenen Gedanken niederzuschreiben :)

Die Rule solltest Du eigentlich nicht brauchen.

Re: ALLNET ALL4176 via HTTP in OH3.x konfigurieren

Verfasst: 28. Apr 2023 17:36
von Homer-S
udo1toni hat geschrieben: 28. Apr 2023 16:55 Die Rule solltest Du eigentlich nicht brauchen.
Korrekt!

Das kann OH3 mittlerweile in einem Kanal, meine Blockade war wirklich die unterschiedlichen x.php adressen ...