23 lines
942 B
Python
23 lines
942 B
Python
import requests
|
|
|
|
url = "http://14.4.4.20:8123/api/template"
|
|
key = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIzZWUyNTE1MDk0NGU0ZjRjYmJkMGM1MWI5MThmY2EzYiIsImlhdCI6MTc0NjgxMDM3NSwiZXhwIjoyMDYyMTcwMzc1fQ.Le6M7WL63nxtLTxccFacQR5GVUY5C-a_zGtmXT_uaz4"
|
|
|
|
headers = {
|
|
"Authorization": f"Bearer {key}",
|
|
"Content-Type": "application/json"
|
|
}
|
|
|
|
tests = [
|
|
"{{ states('sensor.st_00158555_temperature') | float | round(1) }} °F",
|
|
"{{ '%.1f' | format(states('sensor.st_00158555_temperature') | float) }} °F",
|
|
"{{ states('sensor.st_00158555_wind_speed') | float | round(1) }} mph",
|
|
"{{ '%.1f' | format(states('sensor.st_00158555_wind_speed') | float) }} mph",
|
|
"{{ states('sensor.st_00158555_humidity') | float | round(1) }} %",
|
|
"{{ '%.1f' | format(states('sensor.st_00158555_humidity') | float) }} %",
|
|
]
|
|
|
|
for t in tests:
|
|
res = requests.post(url, headers=headers, json={"template": t})
|
|
print(f"{t} => {res.text}")
|