Feb-03-2023, 07:33 PM
Hi,
I'm trying to get the info for a JSON file in to a script.
Many thanks
I'm trying to get the info for a JSON file in to a script.
def onMessagetoonSceneinfo(self, Connection, Response): Domoticz.Debug("onMessagetoonSceneinfo called") if 'states' in Response: for state in Response['states']['state']: self.scenes[state['id'][0]] = int(state['tempValue'][0])But this gives the following error
Error:2023-02-03 20:25:06.213 Error: for state in Response['states']['state']:
2023-02-03 20:25:06.213 Error: TypeError: list indices must be integers or slices, not str
The output of the JSON files is as followsOutput:{
"states": [
{
"state": [
{
"id": [
"0"
],
"tempValue": [
"2000"
],
"dhw": [
"1"
]
},
{
"id": [
"1"
],
"tempValue": [
"1900"
],
"dhw": [
"1"
]
},
{
"id": [
"2"
],
"tempValue": [
"1700"
Who can help me with thisMany thanks