45 lines
1.5 KiB
Python
45 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""
|
|
Created on Sun Jun 23 14:23:26 2024
|
|
|
|
Token für InfluxDB: iNCmNir9eX0cPcM7N-srOq2wYfAdXRL6zzdqovPFYHGblzXWD-Q5fASrkj2aVKyy3bXHtdyNwf_WosrHNvMcVw==
|
|
|
|
@author: sven
|
|
"""
|
|
import requests
|
|
|
|
def send_request(vdat):
|
|
# GET http://homeassistant.local:8123/api/history/period
|
|
response = ''
|
|
# vondatum = "2024-06-20T14:08:00.0000+00:00"
|
|
# bisdatum = vdat
|
|
# vdat = '"' + vdat + '"'
|
|
|
|
try:
|
|
hostaddress="http://homeassistant.local:8123/api/history/period/"
|
|
|
|
url=hostaddress+vdat
|
|
|
|
response = requests.get(
|
|
url=url, #"http://homeassistant.local:8123/api/history/period",
|
|
params={
|
|
vdat: "null",
|
|
"filter_entity_id": "sensor.id_4_odometer",
|
|
},
|
|
headers={
|
|
"Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiI1ZmNhNDVkZWQ1Mzg0MDZmOTY0NWVjOTI0MDNmYTEwNiIsImlhdCI6MTcxODk3Nzg5NiwiZXhwIjoyMDM0MzM3ODk2fQ.BGuVaCR9UM4O_LqYlcLd4LRLM8F_Vwnb9oU_xwh0Wew",
|
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
},
|
|
data={
|
|
},
|
|
)
|
|
return response
|
|
|
|
# print('Response HTTP Status Code: {status_code}'.format(
|
|
# status_code=response.status_code))
|
|
# print('Response HTTP Response Body: {content}'.format(
|
|
# content=response.content))
|
|
except requests.exceptions.RequestException:
|
|
print('HTTP Request failed')
|