To say i’m lost is an understatement.
I have some JSON data which i believe is correctly formatted:
{
"port": 1,
"state": 1,
"link_status": 6,
"TxGoodPkt": 145382505,
"TxBadPkt": 0,
"RxGoodPkt": 354555444,
"RxBadPkt": 0
},
{
"port": 2,
"state": 1,
"link_status": 6,
"TxGoodPkt": 141498890,
"TxBadPkt": 0,
"RxGoodPkt": 62863391,
"RxBadPkt": 0
},
{
"port": 3,
"state": 1,
"link_status": 0,
"TxGoodPkt": 0,
"TxBadPkt": 0,
"RxGoodPkt": 0,
"RxBadPkt": 0
},
{
"port": 4,
"state": 1,
"link_status": 0,
"TxGoodPkt": 0,
"TxBadPkt": 0,
"RxGoodPkt": 0,
"RxBadPkt": 0
},
{
"port": 5,
"state": 1,
"link_status": 0,
"TxGoodPkt": 0,
"TxBadPkt": 0,
"RxGoodPkt": 0,
"RxBadPkt": 0
},
{
"port": 6,
"state": 1,
"link_status": 0,
"TxGoodPkt": 0,
"TxBadPkt": 0,
"RxGoodPkt": 0,
"RxBadPkt": 0
},
{
"port": 7,
"state": 1,
"link_status": 6,
"TxGoodPkt": 1090698305,
"TxBadPkt": 0,
"RxGoodPkt": 628825401,
"RxBadPkt": 0
},
{
"port": 8,
"state": 1,
"link_status": 6,
"TxGoodPkt": 617099708,
"TxBadPkt": 0,
"RxGoodPkt": 915982349,
"RxBadPkt": 0
}
]
I would like to extract just the port 1, link status data to a sensor attribute.
I have so far:
- platform: file
file_path: /config/python_scripts/log10.json
name: tplinkswitch
value_template: '{{ value_json["1"][1]["link_status"]}}'
All help is appreciated.