Hi im trying to send a Json state to HA from a Python Script
what I get from the PolluCom is:
{
"body": {
"header": {
"access_no": 13,
"identification": "0x00, 0x34, 0x54, 0x12",
"manufacturer": "SEN",
"medium": "0x4",
"sign": "0x0, 0x0",
"status": "0x0",
"type": "0x72",
"version": "0x19"
},
"records": [
{
"function": "FunctionType.INSTANTANEOUS_VALUE",
"type": "VIFUnit.ENERGY_WH",
"unit": "MeasureUnit.WH",
"value": 17847000
},
{
"function": "FunctionType.INSTANTANEOUS_VALUE",
"type": "VIFUnit.VOLUME",
"unit": "MeasureUnit.M3",
"value": 2334.95000000000027284841053187847137451171875
},
{
"function": "FunctionType.INSTANTANEOUS_VALUE",
"type": "VIFUnit.VOLUME_FLOW",
"unit": "MeasureUnit.M3_H",
"value": 0.25100000000000000088817841970012523233890533447265625
},
{
"function": "FunctionType.INSTANTANEOUS_VALUE",
"type": "VIFUnit.POWER_W",
"unit": "MeasureUnit.W",
"value": 3366
},
{
"function": "FunctionType.INSTANTANEOUS_VALUE",
"type": "VIFUnit.FLOW_TEMPERATURE",
"unit": "MeasureUnit.C",
"value": 33.39999999999999857891452847979962825775146484375
},
{
"function": "FunctionType.INSTANTANEOUS_VALUE",
"type": "VIFUnit.RETURN_TEMPERATURE",
"unit": "MeasureUnit.C",
"value": 21.7000000000000028421709430404007434844970703125
},
{
"function": "FunctionType.INSTANTANEOUS_VALUE",
"type": "VIFUnit.TEMPERATURE_DIFFERENCE",
"unit": "MeasureUnit.K",
"value": 11.6929999999999996163069226895458996295928955078125
},
{
"function": "FunctionType.INSTANTANEOUS_VALUE",
"type": "VIFUnit.FABRICATION_NO",
"unit": "MeasureUnit.NONE",
"value": 345412
},
{
"function": "FunctionType.INSTANTANEOUS_VALUE",
"type": "VIFUnitExt.CUSTOMER_LOCATION",
"unit": "MeasureUnit.NONE",
"value": 345412
},
{
"function": "FunctionType.MORE_RECORDS_FOLLOW",
"type": "None",
"unit": "None",
"value": null
}
]
},
"head": {
"a": "0x0",
"c": "0x8",
"crc": "0x72",
"length": "0x42",
"start": "0x68",
"stop": "0x16"
}
}
<Response [400]>
what I have in the Python script
print(frame.to_JSON())
url = "http://192.168.178.99:8123/api/states/sensor.waermemengenzaehler2"
token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiI3Yjc1NzlmNzExZmU0NmIzYmFlOTA5ZDg1ZDM1NTg3ZSIsImlhdCI6MTY2NTgyNTc5NiwiZXhwIjoxOTgxMTg1Nzk2fQ.sK5bXp82$
headers = { "Authorization": "Bearer " + token, 'content-type': 'application/json', }
res = requests.post(url, headers=headers,data =frame.to_JSON() )
print(res)
does anyone see what Ive done wrong ?