Re: Spritpreise aus Website in Openhab integrieren
Verfasst: 18. Jan 2022 21:52
Ja, das ist aber quasi die Definition für http1 in grün. Kannst Du mal die genaue Definition für den Cache spritmonitor aus der http.cfg posten?
Code: Alles auswählen
UID: http:url:89e7050e8d
label: Austria
thingTypeUID: http:url
configuration:
authMode: BASIC
ignoreSSLErrors: false
baseURL: https://api.e-control.at/sprit/1.0/search/gas-stations/by-address?latitude=48&longitude=16&fuelType=SUP&includeClosed=false
password: keins
delay: 0
stateMethod: GET
refresh: 30
commandMethod: GET
contentType: application/json
timeout: 3000
bufferSize: 2048
username: irgendwas
channels:
- id: Adresse
channelTypeUID: http:string
label: Adresse
description: ""
configuration:
stateTransformation: jsonpath:$.[0].location.address
- id: Preis
channelTypeUID: http:string
label: Preis
description: ""
configuration:
stateTransformation: JSONPATH:$.[0].prices[0].amount
- id: Tankstellenname
channelTypeUID: http:string
label: Tankstellenname
description: ""
configuration:
stateTransformation: JSONPATH:$.[0].name
- id: Adresse5
channelTypeUID: http:string
label: Adresse5
description: null
configuration:
stateTransformation: jsonpath:$.[1].location.address
- id: Preis5
channelTypeUID: http:string
label: Preis5
description: null
configuration:
stateTransformation: JSONPATH:$.[1].prices[0].amount
- id: Tankstellenname5
channelTypeUID: http:string
label: Tankstellenname5
description: null
configuration:
stateTransformation: JSONPATH:$.[1].name
Code: Alles auswählen
Thing http:url:spritmonitor "Spritmonitor" [
baseURL="https://api.e-control.at/sprit/1.0/search/gas-stations/by-address?latitude=xx.xxx&longitude=xx.xxxx&fuelType=SUP&includeClosed=false",
refresh=60] {
Channels:
Type string : Ts_1 "TS" [ stateTransformation="JSONPATH:$.[0].name" ]
Type string : Ts_Adresse_1 "Adresse" [ stateTransformation="JSONPATH:$.[0].location.address" ]
Type string : Ts_Preis_1 "Preis" [ stateTransformation="JSONPATH:$.[0].prices[0].amount" ]
Type string : Ts_2 "TS" [ stateTransformation="JSONPATH:$.[1].name" ]
Type string : Ts_Adresse_2 "Adresse" [ stateTransformation="JSONPATH:$.[1].location.address" ]
Type string : Ts_Preis_2 "Preis" [ stateTransformation="JSONPATH:$.[1].prices[0].amount" ]
Type string : Ts_3 "TS" [ stateTransformation="JSONPATH:$.[2].name" ]
Type string : Ts_Adresse_3 "Adresse" [ stateTransformation="JSONPATH:$.[2].location.address" ]
Type string : Ts_Preis_3 "Preis" [ stateTransformation="JSONPATH:$.[2].prices[0].amount" ]
Type string : Ts_4 "TS" [ stateTransformation="JSONPATH:$.[3].name" ]
Type string : Ts_Adresse_4 "Adresse" [ stateTransformation="JSONPATH:$.[3].location.address" ]
Type string : Ts_Preis_4 "Preis" [ stateTransformation="JSONPATH:$.[3].prices[0].amount" ]
Type string : Ts_5 "TS" [ stateTransformation="JSONPATH:$.[4].name" ]
Type string : Ts_Adresse_5 "Adresse" [ stateTransformation="JSONPATH:$.[4].location.address" ]
Type string : Ts_Preis_5 "Preis" [ stateTransformation="JSONPATH:$.[4].prices[0].amount" ]
}
Code: Alles auswählen
// SPRITMONITOR
String Tankstelle_Name_1 "[%s]" {channel="http:url:spritmonitor:Ts_1"}
String Tankstelle_Adresse_1 "[%s]" {channel="http:url:spritmonitor:Ts_Adresse_1"}
String Tankstelle_Preis_1 "[%s]" {channel="http:url:spritmonitor:Ts_Preis_1"}
String Tankstelle_Name_2 "[%s]" {channel="http:url:spritmonitor:Ts_2"}
String Tankstelle_Adresse_2 "[%s]" {channel="http:url:spritmonitor:Ts_Adresse_2"}
String Tankstelle_Preis_2 "[%s]" {channel="http:url:spritmonitor:Ts_Preis_2"}
String Tankstelle_Name_3 "[%s]" {channel="http:url:spritmonitor:Ts_3"}
String Tankstelle_Adresse_3 "[%s]" {channel="http:url:spritmonitor:Ts_Adresse_3"}
String Tankstelle_Preis_3 "[%s]" {channel="http:url:spritmonitor:Ts_Preis_3"}
String Tankstelle_Name_4 "[%s]" {channel="http:url:spritmonitor:Ts_4"}
String Tankstelle_Adresse_4 "[%s]" {channel="http:url:spritmonitor:Ts_Adresse_4"}
String Tankstelle_Preis_4 "[%s]" {channel="http:url:spritmonitor:Ts_Preis_4"}
String Tankstelle_Name_5 "[%s]" {channel="http:url:spritmonitor:Ts_5"}
String Tankstelle_Adresse_5 "[%s]" {channel="http:url:spritmonitor:Ts_Adresse_5"}
String Tankstelle_Preis_5 "[%s]" {channel="http:url:spritmonitor:Ts_Preis_5"}