I just don't understand tables...

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
Sarcas
Posts: 86
Joined: Wednesday 11 October 2017 8:50
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1ß
Location: Friesland
Contact:

I just don't understand tables...

Post by Sarcas »

I'm pulling a JSON from my HUE bridge, and I want to get all the scene names. At some point i do

Code: Select all

        if (triggerItem.isHTTPResponse) then
            if (triggerItem.isJSON) then
                local scenes = domoticz.utils.fromJSON(triggerItem.data)
                domoticz.utils.dumpTable(scenes)
And I seem to have the table. But I can't figure out how to extract the names! It is driving me nuts :/

This is the JSON:

Code: Select all

{
	"errors": [],
	"data": [
		{
			"actions": [
				{
					"action": {
						"color": {
							"xy": {
								"x": 0.4134,
								"y": 0.4353
							}
						},
						"dimming": {
							"brightness": 98.82
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "19994fd9-6b88-402d-bdbe-9e043de92264",
						"rtype": "light"
					}
				},
				{
					"action": {
						"color": {
							"xy": {
								"x": 0.4849,
								"y": 0.4339
							}
						},
						"dimming": {
							"brightness": 98.82
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "7bdb92ec-67c5-476e-9b55-16d0c1a79d78",
						"rtype": "light"
					}
				},
				{
					"action": {
						"dimming": {
							"brightness": 98.82
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "88518ddc-815f-4678-81e9-dc78106f7fcb",
						"rtype": "light"
					}
				},
				{
					"action": {
						"dimming": {
							"brightness": 98.82
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "4854b1dc-1d5e-4687-a739-a342243665dc",
						"rtype": "light"
					}
				},
				{
					"action": {
						"color_temperature": {
							"mirek": 345
						},
						"dimming": {
							"brightness": 98.82
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "335fe0eb-0e58-4692-98b5-bd52234ce134",
						"rtype": "light"
					}
				},
				{
					"action": {
						"dimming": {
							"brightness": 98.82
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "a9cfee40-4965-4ba9-b7f8-703ad9908f04",
						"rtype": "light"
					}
				},
				{
					"action": {
						"color": {
							"xy": {
								"x": 0.4351,
								"y": 0.4367
							}
						},
						"dimming": {
							"brightness": 98.82
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "6350304b-f8a7-4eef-857c-09d3135c13ab",
						"rtype": "light"
					}
				},
				{
					"action": {
						"color": {
							"xy": {
								"x": 0.5247,
								"y": 0.4185
							}
						},
						"dimming": {
							"brightness": 98.82
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "e1ba9364-3dc2-4d41-9f73-f5fe642b366e",
						"rtype": "light"
					}
				},
				{
					"action": {
						"color": {
							"xy": {
								"x": 0.4351,
								"y": 0.4367
							}
						},
						"dimming": {
							"brightness": 98.82
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "5f7c8e88-9761-45b0-8c9e-b0b295469807",
						"rtype": "light"
					}
				},
				{
					"action": {
						"color": {
							"xy": {
								"x": 0.4532,
								"y": 0.4353
							}
						},
						"dimming": {
							"brightness": 98.82
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "73ad6912-f565-41b5-8388-95d4b163bc54",
						"rtype": "light"
					}
				},
				{
					"action": {
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "346aa237-ac87-41f2-8c89-fb1b4bb243c1",
						"rtype": "light"
					}
				}
			],
			"group": {
				"rid": "50bffcb4-b71d-48b7-811b-ae9b0c2120a7",
				"rtype": "room"
			},
			"id": "84cbd57a-20fd-46c1-8c56-b09e25e0270d",
			"id_v1": "/scenes/ZOnJesjdEW06e45",
			"metadata": {
				"image": {
					"rid": "a23f4a96-2c68-4655-acda-c29661f8b6ac",
					"rtype": "public_image"
				},
				"name": "Midzomerzon woonkamer"
			},
			"palette": {
				"color": [
					{
						"color": {
							"xy": {
								"x": 0.4145,
								"y": 0.4353
							}
						},
						"dimming": {
							"brightness": 100
						}
					},
					{
						"color": {
							"xy": {
								"x": 0.4446,
								"y": 0.4359
							}
						},
						"dimming": {
							"brightness": 100
						}
					},
					{
						"color": {
							"xy": {
								"x": 0.486,
								"y": 0.4335
							}
						},
						"dimming": {
							"brightness": 100
						}
					},
					{
						"color": {
							"xy": {
								"x": 0.5247,
								"y": 0.4185
							}
						},
						"dimming": {
							"brightness": 98.82
						}
					}
				],
				"color_temperature": [
					{
						"color_temperature": {
							"mirek": 345
						},
						"dimming": {
							"brightness": 98.82
						}
					}
				],
				"dimming": [
					{
						"brightness": 98.82
					}
				]
			},
			"speed": 0.626984126984127,
			"type": "scene"
		},
		{
			"actions": [
				{
					"action": {
						"color_temperature": {
							"mirek": 153
						},
						"dimming": {
							"brightness": 100
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "19994fd9-6b88-402d-bdbe-9e043de92264",
						"rtype": "light"
					}
				},
				{
					"action": {
						"color_temperature": {
							"mirek": 153
						},
						"dimming": {
							"brightness": 100
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "7bdb92ec-67c5-476e-9b55-16d0c1a79d78",
						"rtype": "light"
					}
				},
				{
					"action": {
						"dimming": {
							"brightness": 100
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "88518ddc-815f-4678-81e9-dc78106f7fcb",
						"rtype": "light"
					}
				},
				{
					"action": {
						"dimming": {
							"brightness": 100
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "4854b1dc-1d5e-4687-a739-a342243665dc",
						"rtype": "light"
					}
				},
				{
					"action": {
						"color_temperature": {
							"mirek": 250
						},
						"dimming": {
							"brightness": 100
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "335fe0eb-0e58-4692-98b5-bd52234ce134",
						"rtype": "light"
					}
				},
				{
					"action": {
						"dimming": {
							"brightness": 100
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "a9cfee40-4965-4ba9-b7f8-703ad9908f04",
						"rtype": "light"
					}
				},
				{
					"action": {
						"color_temperature": {
							"mirek": 153
						},
						"dimming": {
							"brightness": 100
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "6350304b-f8a7-4eef-857c-09d3135c13ab",
						"rtype": "light"
					}
				},
				{
					"action": {
						"color_temperature": {
							"mirek": 153
						},
						"dimming": {
							"brightness": 100
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "e1ba9364-3dc2-4d41-9f73-f5fe642b366e",
						"rtype": "light"
					}
				},
				{
					"action": {
						"color_temperature": {
							"mirek": 153
						},
						"dimming": {
							"brightness": 100
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "5f7c8e88-9761-45b0-8c9e-b0b295469807",
						"rtype": "light"
					}
				},
				{
					"action": {
						"color_temperature": {
							"mirek": 153
						},
						"dimming": {
							"brightness": 100
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "73ad6912-f565-41b5-8388-95d4b163bc54",
						"rtype": "light"
					}
				},
				{
					"action": {
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "346aa237-ac87-41f2-8c89-fb1b4bb243c1",
						"rtype": "light"
					}
				}
			],
			"group": {
				"rid": "50bffcb4-b71d-48b7-811b-ae9b0c2120a7",
				"rtype": "room"
			},
			"id": "e8466160-978e-4cb1-8505-7de0940b4d88",
			"id_v1": "/scenes/CoC-IjUuHUoQGLC",
			"metadata": {
				"image": {
					"rid": "7fd2ccc5-5749-4142-b7a5-66405a676f03",
					"rtype": "public_image"
				},
				"name": "Energie woonkamer"
			},
			"palette": {
				"color": [],
				"color_temperature": [
					{
						"color_temperature": {
							"mirek": 153
						},
						"dimming": {
							"brightness": 100
						}
					}
				],
				"dimming": [
					{
						"brightness": 100
					}
				]
			},
			"speed": 0.6031746031746031,
			"type": "scene"
		},
		{
			"actions": [
				{
					"action": {
						"color_temperature": {
							"mirek": 345
						},
						"dimming": {
							"brightness": 98.82
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "9fd4b75d-07bc-49f0-b1b2-a6c3bfd09df6",
						"rtype": "light"
					}
				}
			],
			"group": {
				"rid": "340c2ffa-e636-4617-9e7b-aa9ced655900",
				"rtype": "room"
			},
			"id": "d0aa2324-fe49-4a58-aac4-a4fdb89bd664",
			"id_v1": "/scenes/LlTkAm0vb40ORrZ",
			"metadata": {
				"image": {
					"rid": "a23f4a96-2c68-4655-acda-c29661f8b6ac",
					"rtype": "public_image"
				},
				"name": "Midzomerzon"
			},
			"palette": {
				"color": [
					{
						"color": {
							"xy": {
								"x": 0.4145,
								"y": 0.4353
							}
						},
						"dimming": {
							"brightness": 100
						}
					},
					{
						"color": {
							"xy": {
								"x": 0.4446,
								"y": 0.4359
							}
						},
						"dimming": {
							"brightness": 100
						}
					},
					{
						"color": {
							"xy": {
								"x": 0.486,
								"y": 0.4335
							}
						},
						"dimming": {
							"brightness": 100
						}
					},
					{
						"color": {
							"xy": {
								"x": 0.5247,
								"y": 0.4185
							}
						},
						"dimming": {
							"brightness": 98.82
						}
					}
				],
				"color_temperature": [
					{
						"color_temperature": {
							"mirek": 345
						},
						"dimming": {
							"brightness": 98.82
						}
					}
				],
				"dimming": []
			},
			"speed": 0.626984126984127,
			"type": "scene"
		},
		{
			"actions": [
				{
					"action": {
						"color_temperature": {
							"mirek": 370
						},
						"dimming": {
							"brightness": 29.92
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "19994fd9-6b88-402d-bdbe-9e043de92264",
						"rtype": "light"
					}
				},
				{
					"action": {
						"color_temperature": {
							"mirek": 370
						},
						"dimming": {
							"brightness": 29.92
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "7bdb92ec-67c5-476e-9b55-16d0c1a79d78",
						"rtype": "light"
					}
				}
			],
			"group": {
				"rid": "08e2638b-4185-4f19-ac50-ace98359242d",
				"rtype": "zone"
			},
			"id": "94215465-4ee6-468d-aeb0-59d4f04f37f1",
			"id_v1": "/scenes/FvDRobd55Wtzuj3",
			"metadata": {
				"image": {
					"rid": "8c74b9ba-6e89-4083-a2a7-b10a1e566fed",
					"rtype": "public_image"
				},
				"name": "GedimdTV"
			},
			"palette": {
				"color": [],
				"color_temperature": [
					{
						"color_temperature": {
							"mirek": 370
						},
						"dimming": {
							"brightness": 29.92
						}
					}
				],
				"dimming": []
			},
			"speed": 0.6031746031746031,
			"type": "scene"
		},
		{
			"actions": [
				{
					"action": {
						"color": {
							"xy": {
								"x": 0.4144,
								"y": 0.4352
							}
						},
						"dimming": {
							"brightness": 32.28
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "19994fd9-6b88-402d-bdbe-9e043de92264",
						"rtype": "light"
					}
				},
				{
					"action": {
						"color": {
							"xy": {
								"x": 0.4849,
								"y": 0.4339
							}
						},
						"dimming": {
							"brightness": 31.1
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "7bdb92ec-67c5-476e-9b55-16d0c1a79d78",
						"rtype": "light"
					}
				},
				{
					"action": {
						"dimming": {
							"brightness": 28.74
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "88518ddc-815f-4678-81e9-dc78106f7fcb",
						"rtype": "light"
					}
				},
				{
					"action": {
						"dimming": {
							"brightness": 53.94
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "4854b1dc-1d5e-4687-a739-a342243665dc",
						"rtype": "light"
					}
				},
				{
					"action": {
						"color_temperature": {
							"mirek": 345
						},
						"dimming": {
							"brightness": 50.39
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "335fe0eb-0e58-4692-98b5-bd52234ce134",
						"rtype": "light"
					}
				},
				{
					"action": {
						"dimming": {
							"brightness": 52.36
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "a9cfee40-4965-4ba9-b7f8-703ad9908f04",
						"rtype": "light"
					}
				},
				{
					"action": {
						"color": {
							"xy": {
								"x": 0.4446,
								"y": 0.4359
							}
						},
						"dimming": {
							"brightness": 70.08
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "6350304b-f8a7-4eef-857c-09d3135c13ab",
						"rtype": "light"
					}
				},
				{
					"action": {
						"color": {
							"xy": {
								"x": 0.5247,
								"y": 0.4185
							}
						},
						"dimming": {
							"brightness": 70.08
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "e1ba9364-3dc2-4d41-9f73-f5fe642b366e",
						"rtype": "light"
					}
				},
				{
					"action": {
						"color": {
							"xy": {
								"x": 0.4446,
								"y": 0.4359
							}
						},
						"dimming": {
							"brightness": 70.08
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "5f7c8e88-9761-45b0-8c9e-b0b295469807",
						"rtype": "light"
					}
				},
				{
					"action": {
						"color": {
							"xy": {
								"x": 0.4446,
								"y": 0.4359
							}
						},
						"dimming": {
							"brightness": 70.08
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "73ad6912-f565-41b5-8388-95d4b163bc54",
						"rtype": "light"
					}
				},
				{
					"action": {
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "346aa237-ac87-41f2-8c89-fb1b4bb243c1",
						"rtype": "light"
					}
				}
			],
			"group": {
				"rid": "50bffcb4-b71d-48b7-811b-ae9b0c2120a7",
				"rtype": "room"
			},
			"id": "5eda3a7a-3c3d-4c66-9344-574b5950d9de",
			"id_v1": "/scenes/0d-wc38zy0iDdXJ",
			"metadata": {
				"name": "TV kijken"
			},
			"palette": {
				"color": [
					{
						"color": {
							"xy": {
								"x": 0.4144,
								"y": 0.4352
							}
						},
						"dimming": {
							"brightness": 32.28
						}
					},
					{
						"color": {
							"xy": {
								"x": 0.4446,
								"y": 0.4359
							}
						},
						"dimming": {
							"brightness": 70.08
						}
					},
					{
						"color": {
							"xy": {
								"x": 0.486,
								"y": 0.4335
							}
						},
						"dimming": {
							"brightness": 100
						}
					},
					{
						"color": {
							"xy": {
								"x": 0.5247,
								"y": 0.4185
							}
						},
						"dimming": {
							"brightness": 70.08
						}
					}
				],
				"color_temperature": [
					{
						"color_temperature": {
							"mirek": 345
						},
						"dimming": {
							"brightness": 50.39
						}
					}
				],
				"dimming": [
					{
						"brightness": 53.94
					}
				]
			},
			"speed": 0.6031746031746031,
			"type": "scene"
		},
		{
			"actions": [
				{
					"action": {
						"color": {
							"xy": {
								"x": 0.4162,
								"y": 0.4341
							}
						},
						"dimming": {
							"brightness": 57.87
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "19994fd9-6b88-402d-bdbe-9e043de92264",
						"rtype": "light"
					}
				},
				{
					"action": {
						"color": {
							"xy": {
								"x": 0.4801,
								"y": 0.4309
							}
						},
						"dimming": {
							"brightness": 57.87
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "7bdb92ec-67c5-476e-9b55-16d0c1a79d78",
						"rtype": "light"
					}
				},
				{
					"action": {
						"dimming": {
							"brightness": 57.87
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "88518ddc-815f-4678-81e9-dc78106f7fcb",
						"rtype": "light"
					}
				},
				{
					"action": {
						"dimming": {
							"brightness": 57.87
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "4854b1dc-1d5e-4687-a739-a342243665dc",
						"rtype": "light"
					}
				},
				{
					"action": {
						"color_temperature": {
							"mirek": 454
						},
						"dimming": {
							"brightness": 57.87
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "335fe0eb-0e58-4692-98b5-bd52234ce134",
						"rtype": "light"
					}
				},
				{
					"action": {
						"dimming": {
							"brightness": 57.87
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "a9cfee40-4965-4ba9-b7f8-703ad9908f04",
						"rtype": "light"
					}
				},
				{
					"action": {
						"color": {
							"xy": {
								"x": 0.5862,
								"y": 0.3575
							}
						},
						"dimming": {
							"brightness": 57.87
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "6350304b-f8a7-4eef-857c-09d3135c13ab",
						"rtype": "light"
					}
				},
				{
					"action": {
						"color": {
							"xy": {
								"x": 0.644,
								"y": 0.3348
							}
						},
						"dimming": {
							"brightness": 57.87
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "e1ba9364-3dc2-4d41-9f73-f5fe642b366e",
						"rtype": "light"
					}
				},
				{
					"action": {
						"color": {
							"xy": {
								"x": 0.5862,
								"y": 0.3575
							}
						},
						"dimming": {
							"brightness": 57.87
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "5f7c8e88-9761-45b0-8c9e-b0b295469807",
						"rtype": "light"
					}
				},
				{
					"action": {
						"color": {
							"xy": {
								"x": 0.5246,
								"y": 0.3864
							}
						},
						"dimming": {
							"brightness": 57.87
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "73ad6912-f565-41b5-8388-95d4b163bc54",
						"rtype": "light"
					}
				},
				{
					"action": {
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "346aa237-ac87-41f2-8c89-fb1b4bb243c1",
						"rtype": "light"
					}
				}
			],
			"group": {
				"rid": "50bffcb4-b71d-48b7-811b-ae9b0c2120a7",
				"rtype": "room"
			},
			"id": "58c47c9f-0be5-4153-b55f-55ced07c2a93",
			"id_v1": "/scenes/tySCOV9CzuL74DG",
			"metadata": {
				"image": {
					"rid": "4f2ed241-5aea-4c9d-8028-55d2b111e06f",
					"rtype": "public_image"
				},
				"name": "Savanne zonsondergang Woonkamer"
			},
			"palette": {
				"color": [
					{
						"color": {
							"xy": {
								"x": 0.644,
								"y": 0.3348
							}
						},
						"dimming": {
							"brightness": 57.87
						}
					},
					{
						"color": {
							"xy": {
								"x": 0.5862,
								"y": 0.3575
							}
						},
						"dimming": {
							"brightness": 57.87
						}
					},
					{
						"color": {
							"xy": {
								"x": 0.5246,
								"y": 0.3864
							}
						},
						"dimming": {
							"brightness": 57.87
						}
					},
					{
						"color": {
							"xy": {
								"x": 0.4801,
								"y": 0.4309
							}
						},
						"dimming": {
							"brightness": 57.87
						}
					},
					{
						"color": {
							"xy": {
								"x": 0.4162,
								"y": 0.4341
							}
						},
						"dimming": {
							"brightness": 57.87
						}
					}
				],
				"color_temperature": [
					{
						"color_temperature": {
							"mirek": 454
						},
						"dimming": {
							"brightness": 57.87
						}
					}
				],
				"dimming": [
					{
						"brightness": 57.87
					}
				]
			},
			"speed": 0.6031746031746031,
			"type": "scene"
		},
		{
			"actions": [
				{
					"action": {
						"dimming": {
							"brightness": 31.5
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "c29aca61-5837-40db-83e6-83c8364f2e63",
						"rtype": "light"
					}
				},
				{
					"action": {
						"dimming": {
							"brightness": 31.5
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "d69b7726-36a3-4807-b6ba-4a1b745113b5",
						"rtype": "light"
					}
				},
				{
					"action": {
						"color": {
							"xy": {
								"x": 0.5862,
								"y": 0.3575
							}
						},
						"dimming": {
							"brightness": 31.5
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "298d101e-6ce0-4958-a2a4-599c9ec53976",
						"rtype": "light"
					}
				},
				{
					"action": {
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "04a80a2a-5f63-47a3-ad96-ae8a5d3d90b6",
						"rtype": "light"
					}
				}
			],
			"group": {
				"rid": "18e73928-9b82-4b67-8fe9-8e2376eba8a2",
				"rtype": "room"
			},
			"id": "442ea7bc-30d7-40cb-91f2-b9c2b2ed27e3",
			"id_v1": "/scenes/OneVSugFC8c06ju",
			"metadata": {
				"image": {
					"rid": "4f2ed241-5aea-4c9d-8028-55d2b111e06f",
					"rtype": "public_image"
				},
				"name": "Savanne zonsondergang slaapkamer"
			},
			"palette": {
				"color": [
					{
						"color": {
							"xy": {
								"x": 0.644,
								"y": 0.3348
							}
						},
						"dimming": {
							"brightness": 57.87
						}
					},
					{
						"color": {
							"xy": {
								"x": 0.5862,
								"y": 0.3575
							}
						},
						"dimming": {
							"brightness": 57.87
						}
					},
					{
						"color": {
							"xy": {
								"x": 0.5246,
								"y": 0.3864
							}
						},
						"dimming": {
							"brightness": 57.87
						}
					},
					{
						"color": {
							"xy": {
								"x": 0.4801,
								"y": 0.4309
							}
						},
						"dimming": {
							"brightness": 57.87
						}
					},
					{
						"color": {
							"xy": {
								"x": 0.4162,
								"y": 0.4341
							}
						},
						"dimming": {
							"brightness": 57.87
						}
					}
				],
				"color_temperature": [
					{
						"color_temperature": {
							"mirek": 455
						},
						"dimming": {
							"brightness": 57.87
						}
					}
				],
				"dimming": [
					{
						"brightness": 31.5
					}
				]
			},
			"speed": 0.6031746031746031,
			"type": "scene"
		},
		{
			"actions": [
				{
					"action": {
						"dimming": {
							"brightness": 56.69
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "c29aca61-5837-40db-83e6-83c8364f2e63",
						"rtype": "light"
					}
				},
				{
					"action": {
						"dimming": {
							"brightness": 56.69
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "d69b7726-36a3-4807-b6ba-4a1b745113b5",
						"rtype": "light"
					}
				},
				{
					"action": {
						"color_temperature": {
							"mirek": 447
						},
						"dimming": {
							"brightness": 56.69
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "298d101e-6ce0-4958-a2a4-599c9ec53976",
						"rtype": "light"
					}
				},
				{
					"action": {
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "04a80a2a-5f63-47a3-ad96-ae8a5d3d90b6",
						"rtype": "light"
					}
				}
			],
			"group": {
				"rid": "18e73928-9b82-4b67-8fe9-8e2376eba8a2",
				"rtype": "room"
			},
			"id": "d05f1cc9-60b7-40d3-9fc8-34a898370eae",
			"id_v1": "/scenes/mUQ92vzhBqKzyio",
			"metadata": {
				"image": {
					"rid": "a1f7da49-d181-4328-abea-68c9dc4b5416",
					"rtype": "public_image"
				},
				"name": "Ontspannen slaapkamer"
			},
			"palette": {
				"color": [],
				"color_temperature": [
					{
						"color_temperature": {
							"mirek": 447
						},
						"dimming": {
							"brightness": 56.69
						}
					}
				],
				"dimming": [
					{
						"brightness": 56.69
					}
				]
			},
			"speed": 0.5,
			"type": "scene"
		},
		{
			"actions": [
				{
					"action": {
						"dimming": {
							"brightness": 100
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "c29aca61-5837-40db-83e6-83c8364f2e63",
						"rtype": "light"
					}
				},
				{
					"action": {
						"dimming": {
							"brightness": 100
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "d69b7726-36a3-4807-b6ba-4a1b745113b5",
						"rtype": "light"
					}
				},
				{
					"action": {
						"color_temperature": {
							"mirek": 346
						},
						"dimming": {
							"brightness": 100
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "298d101e-6ce0-4958-a2a4-599c9ec53976",
						"rtype": "light"
					}
				},
				{
					"action": {
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "04a80a2a-5f63-47a3-ad96-ae8a5d3d90b6",
						"rtype": "light"
					}
				}
			],
			"group": {
				"rid": "18e73928-9b82-4b67-8fe9-8e2376eba8a2",
				"rtype": "room"
			},
			"id": "f014405b-0db3-45b1-aee3-3caedc047be8",
			"id_v1": "/scenes/2Ho-YWuhEJM4JWk",
			"metadata": {
				"image": {
					"rid": "e101a77f-9984-4f61-aac8-15741983c656",
					"rtype": "public_image"
				},
				"name": "Lezen slaapkamer"
			},
			"palette": {
				"color": [],
				"color_temperature": [
					{
						"color_temperature": {
							"mirek": 346
						},
						"dimming": {
							"brightness": 100
						}
					}
				],
				"dimming": [
					{
						"brightness": 100
					}
				]
			},
			"speed": 0.5,
			"type": "scene"
		},
		{
			"actions": [
				{
					"action": {
						"dimming": {
							"brightness": 100
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "c29aca61-5837-40db-83e6-83c8364f2e63",
						"rtype": "light"
					}
				},
				{
					"action": {
						"dimming": {
							"brightness": 100
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "d69b7726-36a3-4807-b6ba-4a1b745113b5",
						"rtype": "light"
					}
				},
				{
					"action": {
						"color_temperature": {
							"mirek": 233
						},
						"dimming": {
							"brightness": 100
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "298d101e-6ce0-4958-a2a4-599c9ec53976",
						"rtype": "light"
					}
				},
				{
					"action": {
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "04a80a2a-5f63-47a3-ad96-ae8a5d3d90b6",
						"rtype": "light"
					}
				}
			],
			"group": {
				"rid": "18e73928-9b82-4b67-8fe9-8e2376eba8a2",
				"rtype": "room"
			},
			"id": "8f61adba-c206-4272-8f02-d041271694fb",
			"id_v1": "/scenes/R5HF5Z2bRko6j9U",
			"metadata": {
				"image": {
					"rid": "b90c8900-a6b7-422c-a5d3-e170187dbf8c",
					"rtype": "public_image"
				},
				"name": "Concentreren slaapkamer"
			},
			"palette": {
				"color": [],
				"color_temperature": [
					{
						"color_temperature": {
							"mirek": 233
						},
						"dimming": {
							"brightness": 100
						}
					}
				],
				"dimming": [
					{
						"brightness": 100
					}
				]
			},
			"speed": 0.5,
			"type": "scene"
		},
		{
			"actions": [
				{
					"action": {
						"dimming": {
							"brightness": 100
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "c29aca61-5837-40db-83e6-83c8364f2e63",
						"rtype": "light"
					}
				},
				{
					"action": {
						"dimming": {
							"brightness": 100
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "d69b7726-36a3-4807-b6ba-4a1b745113b5",
						"rtype": "light"
					}
				},
				{
					"action": {
						"color_temperature": {
							"mirek": 156
						},
						"dimming": {
							"brightness": 100
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "298d101e-6ce0-4958-a2a4-599c9ec53976",
						"rtype": "light"
					}
				},
				{
					"action": {
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "04a80a2a-5f63-47a3-ad96-ae8a5d3d90b6",
						"rtype": "light"
					}
				}
			],
			"group": {
				"rid": "18e73928-9b82-4b67-8fe9-8e2376eba8a2",
				"rtype": "room"
			},
			"id": "1944673f-5aac-44fb-87aa-7b863aed00bd",
			"id_v1": "/scenes/iusALJs7SFwx2Mg",
			"metadata": {
				"image": {
					"rid": "7fd2ccc5-5749-4142-b7a5-66405a676f03",
					"rtype": "public_image"
				},
				"name": "Energie slaapkamer"
			},
			"palette": {
				"color": [],
				"color_temperature": [
					{
						"color_temperature": {
							"mirek": 156
						},
						"dimming": {
							"brightness": 100
						}
					}
				],
				"dimming": [
					{
						"brightness": 100
					}
				]
			},
			"speed": 0.5,
			"type": "scene"
		},
		{
			"actions": [
				{
					"action": {
						"on": {
							"on": false
						}
					},
					"target": {
						"rid": "c29aca61-5837-40db-83e6-83c8364f2e63",
						"rtype": "light"
					}
				},
				{
					"action": {
						"on": {
							"on": false
						}
					},
					"target": {
						"rid": "d69b7726-36a3-4807-b6ba-4a1b745113b5",
						"rtype": "light"
					}
				},
				{
					"action": {
						"color": {
							"xy": {
								"x": 0.6493,
								"y": 0.3234
							}
						},
						"dimming": {
							"brightness": 12.2
						},
						"on": {
							"on": true
						}
					},
					"target": {
						"rid": "298d101e-6ce0-4958-a2a4-599c9ec53976",
						"rtype": "light"
					}
				},
				{
					"action": {
						"on": {
							"on": false
						}
					},
					"target": {
						"rid": "04a80a2a-5f63-47a3-ad96-ae8a5d3d90b6",
						"rtype": "light"
					}
				}
			],
			"group": {
				"rid": "18e73928-9b82-4b67-8fe9-8e2376eba8a2",
				"rtype": "room"
			},
			"id": "f86eac66-a915-45c2-918d-5e032fc74957",
			"id_v1": "/scenes/K1PUZJig0dydb3J",
			"metadata": {
				"name": "Nacht slaapkamer"
			},
			"palette": {
				"color": [
					{
						"color": {
							"xy": {
								"x": 0.6501,
								"y": 0.3234
							}
						},
						"dimming": {
							"brightness": 100
						}
					}
				],
				"color_temperature": [],
				"dimming": []
			},
			"speed": 0.6031746031746031,
			"type": "scene"
		}
	]
}
Someone please save me from the madnes ...

thx
--

Domoticz on rPi4 - RFXCOM RFXtrx433 USB - ZW090 Z-Stick Gen5 EU - IKEA Tradfri - Philips HUE - YouLess meter - SolarEdge
User avatar
waltervl
Posts: 6691
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: I just don't understand tables...

Post by waltervl »

That is a big JSON ;)
What is the path to the name value or logic you are looking for? Should start with data.....
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Sarcas
Posts: 86
Joined: Wednesday 11 October 2017 8:50
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1ß
Location: Friesland
Contact:

Re: I just don't understand tables...

Post by Sarcas »

Yeah, it confuses the hell out of me. I need to learn and read about tables, but haven't found the right text yet.
Anyhow, this is the little script I have made, just to test things out.

Code: Select all

return {
    on = {
        devices = {
            2418 -- virtual test button
        },
        httpResponses = {
            'HUE_SCENES'
        }
    },

    logging = {
        level = domoticz.LOG_INFO,
        marker = 'HUE_SCENES',
    },

    execute = function(domoticz,triggerItem)

        local myHueBridgeIp     = '192.168.8.177'
        local myHueApiKey       = '<here is my api>'
        local myHueTestscene    = '84cbd57a-20fd-46c1-8c56-b09e25e0270d'

        if (triggerItem.isDevice) then
            domoticz.log('Trigger is device')

            domoticz.openURL({
                url = 'https://' .. myHueBridgeIp .. '/clip/v2/resource/scene',
                method = 'GET',
                callback = 'HUE_SCENES',
                headers = {
                    ['hue-application-key'] = myHueApiKey
                }
            })
        end

        if (triggerItem.isHTTPResponse) then
            if (triggerItem.isJSON) then
                local scenes = domoticz.utils.fromJSON(triggerItem.data)
                domoticz.utils.dumpTable(scenes)

                for i, scene in pairs(scenes) do
                    domoticz.log('scene.name = ' .. scenes.name )  -- werkt niet. wat wel?! 
                end

            else
                domoticz.log('noJSON',triggerItem.data)
            end
        end
    end
}
And the data I want (to start with) is the NAME. See screenshot.
Screenshot 2022-02-08 181711.png
Screenshot 2022-02-08 181711.png (205.81 KiB) Viewed 601 times
Extra info here (HUE API docs)

thanks!
--

Domoticz on rPi4 - RFXCOM RFXtrx433 USB - ZW090 Z-Stick Gen5 EU - IKEA Tradfri - Philips HUE - YouLess meter - SolarEdge
User avatar
waltervl
Posts: 6691
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: I just don't understand tables...

Post by waltervl »

I am also no expert so bare with me...
the path to the name is data.actions[].metadata.name

So try this, it should list all your scenes names

Code: Select all

if (triggerItem.isJSON) then
	local result_table = triggerItem.json.data -- giving table with all actions
	local tc = #result_table -- counting number of actions

	for i = 1, tc do  -- go through all actions
	    domoticz.log('scene name' .. i .. ' = ' .. result_table[i].metadata.name )
        end
end
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Sarcas
Posts: 86
Joined: Wednesday 11 October 2017 8:50
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1ß
Location: Friesland
Contact:

Re: I just don't understand tables...

Post by Sarcas »

Works!
Happy!

And I kinda understand what is going on. I'll have to read about tables, and what .json.data is and why, and all of that. I guess I have to level up 😁

Thanks for the help!
--

Domoticz on rPi4 - RFXCOM RFXtrx433 USB - ZW090 Z-Stick Gen5 EU - IKEA Tradfri - Philips HUE - YouLess meter - SolarEdge
Sarcas
Posts: 86
Joined: Wednesday 11 October 2017 8:50
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1ß
Location: Friesland
Contact:

Re: I just don't understand tables...

Post by Sarcas »

Works!
Happy!

And I kinda understand what is going on. I'll have to read about tables, and what .json.data is and why, and all of that. I guess I have to level up 😁

Thanks for the help!
--

Domoticz on rPi4 - RFXCOM RFXtrx433 USB - ZW090 Z-Stick Gen5 EU - IKEA Tradfri - Philips HUE - YouLess meter - SolarEdge
User avatar
waltervl
Posts: 6691
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: I just don't understand tables...

Post by waltervl »

Good luck with the rest :-)
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest