für meine Torsteuerung habe ich die Übertragung von der Elektronik zu OpenHAB hinbekommen. Dabei benutze ich auch einen Switch als item, um anzuzeigen, ob die Batterie geladen wird. Jetzt will ich umgekehrt die Änderungen dieses Switches an die Elektronik übertragen und scheitere. Mit dem Befehl http://gate/data bekomme ich Daten im JSON Format, die ich in Openhab eingelesen bekomme. Um jetzt die Ladung der Batterie ein- und auszuschalten gibt es die Befehle http://gate/chargeon und http://gate/chargeoff. Dafür habe ich eine MAP Transformation gccharge.map im transform Ordner angelegt. MAP Transformation ist installiert.
Code: Alles auswählen
ON=chargeon
OFF=chargeoff
1=chargeon
0=chargeoff
Code: Alles auswählen
UID: http:url:f5bfdebcea
label: GateController
thingTypeUID: http:url
configuration:
authMode: BASIC
ignoreSSLErrors: false
baseURL: http://gate
delay: 0
stateMethod: GET
refresh: 60
commandMethod: GET
contentType: application/json
timeout: 3000
bufferSize: 2048
channels:
- id: last-failure
channelTypeUID: http:request-date-time
label: Last Failure
configuration: {}
- id: last-success
channelTypeUID: http:request-date-time
label: Last Success
configuration: {}
- id: gatecontrollerstatus
channelTypeUID: http:string
label: status
description: ""
configuration:
stateExtension: /data
- id: gatecontrollerpowervoltage
channelTypeUID: http:number
label: Power Voltage
description: ""
configuration:
stateTransformation: JSONPATH:$.PowerVoltage
- id: gatecontrollerbatteryvoltag
channelTypeUID: http:number
label: Battery Voltage
description: ""
configuration:
stateExtension: /data
stateTransformation: JSONPATH:$.BatteryVoltage
- id: gatecontrollermovement
channelTypeUID: http:number
label: Movement
description: ""
configuration:
stateExtension: /data
stateTransformation: JSONPATH:$.Mode
- id: gatecontrollerlightbarrier
channelTypeUID: http:switch
label: Lichtschranke
description: ""
configuration:
onValue: "1"
offValue: "0"
stateExtension: /data
stateTransformation: JSONPATH:$.LightBarrier
- id: gatecontrollercontact
channelTypeUID: http:switch
label: Torkontakt
description: ""
configuration:
onValue: "1"
offValue: "0"
stateExtension: /data
stateTransformation: JSONPATH:$.GateClosed
- id: gatecontrollercharging
channelTypeUID: http:switch
label: Batterieladung
description: ""
configuration:
onValue: "1"
commandTransformation: MAP(gccharge.map):$s
offValue: "0"
stateExtension: /data
stateTransformation: JSONPATH:$.BatteryCharge
commandExtension: /%2$s
- id: gatecontrollerbatteryenabled
channelTypeUID: http:switch
label: Batterie aktiv
description: ""
configuration:
onValue: "1"
offValue: "0"
stateExtension: /data
stateTransformation: JSONPATH:$.BatteryEnabled
Ich habe nun versucht, die Transformation zu überprüfen, indem ich ein item mit der Transformation generiert habe:
Code: Alles auswählen
String TorStatus_Test "Map: [MAP(gccharge.map):%s]" <text> (gGateController) {channel="http:url:f5bfdebcea:gatecontrollercharging"}
Code: Alles auswählen
Switch GateController_BC "Batterieladung [%s]" <switch> (gGateController) {channel="http:url:f5bfdebcea:gatecontrollercharging"}