Nästa grej då, känner att jag behöver fråga för jag förstår inte riktigt några förmodligen grundläggande saker varken med VB.NET eller Newtonsofts Json-funktioner.
Ställer man en fråga till HUEn´s API om vilka lampor som finns så får man ett som i kodrutan där nere.
Uppbyggnaden är väl först ett ID som motsvarar en lampa i detta fallet.
Sen har varje ID´t några grupper med värden, eller hur man nu uttrycker sig.
Lampan med ID 4 har brightness satt till 80, syns i grupp state.
Iallafall, den här strängen med data vill jag plocka in och hacka upp i variabler/arrayer. (<-- detta kanske är fel metod? Jag läser en del om "Objects"?)
Eftersom jag vill att koden ska vara lite dynamisk så vill jag inte skriva hårt vilka lampor som finns eller lägen de stödjer.
Så om jag kan fylla på en array med IDn, sen en array med värdet för brightness på samma position som ID´t (om VB.NET stödjer att få ut arraypositioner?)
Största problemet är att få ihop arraye/listan med ID´n.
Jag har importerat Newtonsoft.Json och Newtonsoft.Json.Linq. Så jag har tillgång till deras funktioner.
Och jag tror att jag ska "DeSerializea". Blir dock inte klok på "hjälpen" som finns.
Kod: Markera allt
{
"4": {
"state": {
"on": true,
"bri": 80,
"hue": 5672,
"sat": 217,
"effect": "none",
"xy": [
0.5475,
0.3924
],
"ct": 500,
"alert": "none",
"colormode": "xy",
"mode": "homeautomation",
"reachable": true
},
"swupdate": {
"state": "noupdates",
"lastinstall": "2021-09-17T16:30:56"
},
"type": "Extended color light",
"name": "Fönsterlampa 2",
"modelid": "LCT012",
"manufacturername": "Signify Netherlands B.V.",
"productname": "Hue color candle",
"capabilities": {
"certified": true,
"control": {
"mindimlevel": 2000,
"maxlumen": 450,
"colorgamuttype": "C",
"colorgamut": [
[
0.6915,
0.3083
],
[
0.17,
0.7
],
[
0.1532,
0.0475
]
],
"ct": {
"min": 153,
"max": 500
}
},
"streaming": {
"renderer": true,
"proxy": true
}
},
"config": {
"archetype": "tableshade",
"function": "mixed",
"direction": "omnidirectional",
"startup": {
"mode": "powerfail",
"configured": true
}
},
"uniqueid": "00:17:88:01:03:b8:cc:a6-0b",
"swversion": "1.88.1",
"swconfigid": "AE68C57D",
"productid": "Philips-LCT012-1-E14ECLv1"
},
"5": {
"state": {
"on": true,
"bri": 90,
"hue": 5672,
"sat": 217,
"effect": "none",
"xy": [
0.5475,
0.3924
],
"ct": 500,
"alert": "none",
"colormode": "xy",
"mode": "homeautomation",
"reachable": true
},
"swupdate": {
"state": "noupdates",
"lastinstall": "2020-06-11T15:54:21"
},
"type": "Extended color light",
"name": "Fönsterlampa 1",
"modelid": "LCT012",
"manufacturername": "Signify Netherlands B.V.",
"productname": "Hue color candle",
"capabilities": {
"certified": true,
"control": {
"mindimlevel": 2000,
"maxlumen": 450,
"colorgamuttype": "C",
"colorgamut": [
[
0.6915,
0.3083
],
[
0.17,
0.7
],
[
0.1532,
0.0475
]
],
"ct": {
"min": 153,
"max": 500
}
},
"streaming": {
"renderer": true,
"proxy": true
}
},
"config": {
"archetype": "tableshade",
"function": "mixed",
"direction": "omnidirectional",
"startup": {
"mode": "powerfail",
"configured": true
}
},
"uniqueid": "00:17:88:01:03:b8:c8:86-0b",
"swversion": "1.88.1",
"swconfigid": "AE68C57D",
"productid": "Philips-LCT012-1-E14ECLv1"
},
"6": {
"state": {
"on": true,
"bri": 77,
"hue": 8402,
"sat": 140,
"effect": "none",
"xy": [
0.4575,
0.4099
],
"ct": 366,
"alert": "select",
"colormode": "xy",
"mode": "homeautomation",
"reachable": true
},
"swupdate": {
"state": "noupdates",
"lastinstall": "2020-06-11T15:55:59"
},
"type": "Extended color light",
"name": "Bordslampa",
"modelid": "LCT015",
"manufacturername": "Signify Netherlands B.V.",
"productname": "Hue color lamp",
"capabilities": {
"certified": true,
"control": {
"mindimlevel": 1000,
"maxlumen": 806,
"colorgamuttype": "C",
"colorgamut": [
[
0.6915,
0.3083
],
[
0.17,
0.7
],
[
0.1532,
0.0475
]
],
"ct": {
"min": 153,
"max": 500
}
},
"streaming": {
"renderer": true,
"proxy": true
}
},
"config": {
"archetype": "pendantround",
"function": "mixed",
"direction": "omnidirectional",
"startup": {
"mode": "powerfail",
"configured": true
}
},
"uniqueid": "00:17:88:01:03:fb:cb:c5-0b",
"swversion": "1.88.1",
"swconfigid": "76B74E79",
"productid": "Philips-LCT015-1-A19ECLv5"
},
"8": {
"state": {
"on": false,
"bri": 254,
"ct": 343,
"alert": "select",
"colormode": "ct",
"mode": "homeautomation",
"reachable": true
},
"swupdate": {
"state": "noupdates",
"lastinstall": "2020-06-11T16:08:47"
},
"type": "Color temperature light",
"name": "Hallspot",
"modelid": "LTW013",
"manufacturername": "Signify Netherlands B.V.",
"productname": "Hue ambiance spot",
"capabilities": {
"certified": true,
"control": {
"mindimlevel": 1000,
"maxlumen": 250,
"ct": {
"min": 153,
"max": 454
}
},
"streaming": {
"renderer": false,
"proxy": false
}
},
"config": {
"archetype": "spotbulb",
"function": "functional",
"direction": "downwards",
"startup": {
"mode": "powerfail",
"configured": true
}
},
"uniqueid": "00:17:88:01:04:27:a5:f9-0b",
"swversion": "1.88.1",
"swconfigid": "02C0CF1A",
"productid": "Philips-LTW013-1-GU10CTv1"
},
"10": {
"state": {
"on": true,
"bri": 89,
"hue": 4830,
"sat": 237,
"effect": "none",
"xy": [
0.5786,
0.3818
],
"ct": 500,
"alert": "select",
"colormode": "xy",
"mode": "homeautomation",
"reachable": true
},
"swupdate": {
"state": "noupdates",
"lastinstall": "2022-01-20T17:06:36"
},
"type": "Extended color light",
"name": "Skrivbordslampa",
"modelid": "LCL001",
"manufacturername": "Signify Netherlands B.V.",
"productname": "Hue lightstrip plus",
"capabilities": {
"certified": true,
"control": {
"mindimlevel": 40,
"maxlumen": 1600,
"colorgamuttype": "C",
"colorgamut": [
[
0.6915,
0.3083
],
[
0.17,
0.7
],
[
0.1532,
0.0475
]
],
"ct": {
"min": 153,
"max": 500
}
},
"streaming": {
"renderer": true,
"proxy": true
}
},
"config": {
"archetype": "huelightstrip",
"function": "mixed",
"direction": "omnidirectional",
"startup": {
"mode": "powerfail",
"configured": true
}
},
"uniqueid": "00:17:88:01:08:d6:ce:e6-0b",
"swversion": "1.93.11",
"swconfigid": "2435DF32",
"productid": "Philips-LCL001-1-LedStripsv4"
},
"11": {
"state": {
"on": true,
"bri": 91,
"hue": 5672,
"sat": 217,
"effect": "none",
"xy": [
0.5475,
0.3924
],
"ct": 500,
"alert": "none",
"colormode": "xy",
"mode": "homeautomation",
"reachable": true
},
"swupdate": {
"state": "noupdates",
"lastinstall": "2020-08-19T16:04:38"
},
"type": "Extended color light",
"name": "Sov-taklampa",
"modelid": "LCT015",
"manufacturername": "Signify Netherlands B.V.",
"productname": "Hue color lamp",
"capabilities": {
"certified": true,
"control": {
"mindimlevel": 1000,
"maxlumen": 806,
"colorgamuttype": "C",
"colorgamut": [
[
0.6915,
0.3083
],
[
0.17,
0.7
],
[
0.1532,
0.0475
]
],
"ct": {
"min": 153,
"max": 500
}
},
"streaming": {
"renderer": true,
"proxy": true
}
},
"config": {
"archetype": "sultanbulb",
"function": "mixed",
"direction": "omnidirectional",
"startup": {
"mode": "powerfail",
"configured": true
}
},
"uniqueid": "00:17:88:01:03:fb:cb:cd-0b",
"swversion": "1.88.1",
"swconfigid": "76B74E79",
"productid": "Philips-LCT015-1-A19ECLv5"
},
"12": {
"state": {
"on": true,
"bri": 77,
"hue": 8402,
"sat": 140,
"effect": "none",
"xy": [
0.4575,
0.4099
],
"ct": 366,
"alert": "select",
"colormode": "xy",
"mode": "homeautomation",
"reachable": true
},
"swupdate": {
"state": "noupdates",
"lastinstall": "2020-08-23T16:14:26"
},
"type": "Extended color light",
"name": "Bordslampa ",
"modelid": "LCT012",
"manufacturername": "Signify Netherlands B.V.",
"productname": "Hue color candle",
"capabilities": {
"certified": true,
"control": {
"mindimlevel": 2000,
"maxlumen": 450,
"colorgamuttype": "C",
"colorgamut": [
[
0.6915,
0.3083
],
[
0.17,
0.7
],
[
0.1532,
0.0475
]
],
"ct": {
"min": 153,
"max": 500
}
},
"streaming": {
"renderer": true,
"proxy": true
}
},
"config": {
"archetype": "tableshade",
"function": "mixed",
"direction": "omnidirectional",
"startup": {
"mode": "powerfail",
"configured": true
}
},
"uniqueid": "00:17:88:01:03:ba:a6:95-0b",
"swversion": "1.88.1",
"swconfigid": "AE68C57D",
"productid": "Philips-LCT012-1-E14ECLv1"
},
"13": {
"state": {
"on": true,
"bri": 91,
"hue": 5672,
"sat": 217,
"effect": "none",
"xy": [
0.5475,
0.3924
],
"ct": 500,
"alert": "select",
"colormode": "xy",
"mode": "homeautomation",
"reachable": true
},
"swupdate": {
"state": "noupdates",
"lastinstall": "2020-08-23T16:14:22"
},
"type": "Extended color light",
"name": "Vägglampa",
"modelid": "LCT012",
"manufacturername": "Signify Netherlands B.V.",
"productname": "Hue color candle",
"capabilities": {
"certified": true,
"control": {
"mindimlevel": 2000,
"maxlumen": 450,
"colorgamuttype": "C",
"colorgamut": [
[
0.6915,
0.3083
],
[
0.17,
0.7
],
[
0.1532,
0.0475
]
],
"ct": {
"min": 153,
"max": 500
}
},
"streaming": {
"renderer": true,
"proxy": true
}
},
"config": {
"archetype": "wallshade",
"function": "mixed",
"direction": "omnidirectional",
"startup": {
"mode": "powerfail",
"configured": true
}
},
"uniqueid": "00:17:88:01:03:b8:d3:af-0b",
"swversion": "1.88.1",
"swconfigid": "AE68C57D",
"productid": "Philips-LCT012-1-E14ECLv1"
},
"14": {
"state": {
"on": true,
"bri": 47,
"hue": 57686,
"sat": 223,
"effect": "none",
"xy": [
0.4522,
0.2192
],
"ct": 356,
"alert": "select",
"colormode": "xy",
"mode": "homeautomation",
"reachable": true
},
"swupdate": {
"state": "noupdates",
"lastinstall": "2020-09-02T16:12:38"
},
"type": "Extended color light",
"name": "Bänkstrip",
"modelid": "LST002",
"manufacturername": "Signify Netherlands B.V.",
"productname": "Hue lightstrip plus",
"capabilities": {
"certified": true,
"control": {
"mindimlevel": 40,
"maxlumen": 1600,
"colorgamuttype": "C",
"colorgamut": [
[
0.6915,
0.3083
],
[
0.17,
0.7
],
[
0.1532,
0.0475
]
],
"ct": {
"min": 153,
"max": 500
}
},
"streaming": {
"renderer": true,
"proxy": true
}
},
"config": {
"archetype": "huelightstrip",
"function": "mixed",
"direction": "omnidirectional",
"startup": {
"mode": "powerfail",
"configured": true
}
},
"uniqueid": "00:17:88:01:04:8c:45:cc-0b",
"swversion": "1.88.1",
"swconfigid": "8EF6FE80",
"productid": "Philips-LST002-1-LedStripsv3"
},
"16": {
"state": {
"on": true,
"bri": 167,
"hue": 5672,
"sat": 217,
"effect": "none",
"xy": [
0.5475,
0.3924
],
"ct": 500,
"alert": "select",
"colormode": "xy",
"mode": "homeautomation",
"reachable": true
},
"swupdate": {
"state": "noupdates",
"lastinstall": "2022-07-01T16:44:26"
},
"type": "Extended color light",
"name": "Hallstrip",
"modelid": "LCL001",
"manufacturername": "Signify Netherlands B.V.",
"productname": "Hue lightstrip plus",
"capabilities": {
"certified": true,
"control": {
"mindimlevel": 40,
"maxlumen": 1600,
"colorgamuttype": "C",
"colorgamut": [
[
0.6915,
0.3083
],
[
0.17,
0.7
],
[
0.1532,
0.0475
]
],
"ct": {
"min": 153,
"max": 500
}
},
"streaming": {
"renderer": true,
"proxy": true
}
},
"config": {
"archetype": "huelightstrip",
"function": "mixed",
"direction": "omnidirectional",
"startup": {
"mode": "powerfail",
"configured": true
}
},
"uniqueid": "00:17:88:01:09:0f:c3:c4-0b",
"swversion": "1.93.11",
"swconfigid": "2435DF32",
"productid": "Philips-LCL001-1-LedStripsv4"
},
"17": {
"state": {
"on": true,
"bri": 206,
"hue": 65149,
"sat": 254,
"effect": "none",
"xy": [
0.6802,
0.3028
],
"ct": 500,
"alert": "select",
"colormode": "xy",
"mode": "homeautomation",
"reachable": true
},
"swupdate": {
"state": "noupdates",
"lastinstall": "2021-09-17T16:31:19"
},
"type": "Extended color light",
"name": "Hue outdoor spot 1",
"modelid": "LCS001",
"manufacturername": "Signify Netherlands B.V.",
"productname": "Hue outdoor spot",
"capabilities": {
"certified": true,
"control": {
"mindimlevel": 100,
"maxlumen": 650,
"colorgamuttype": "C",
"colorgamut": [
[
0.6915,
0.3083
],
[
0.17,
0.7
],
[
0.1532,
0.0475
]
],
"ct": {
"min": 153,
"max": 500
}
},
"streaming": {
"renderer": true,
"proxy": true
}
},
"config": {
"archetype": "groundspot",
"function": "decorative",
"direction": "upwards",
"startup": {
"mode": "powerfail",
"configured": true
}
},
"uniqueid": "00:17:88:01:04:53:3e:b2-0b",
"swversion": "1.88.1",
"swconfigid": "5290BE03",
"productid": "ENA-LCS001-1-LilySpikev1"
},
"18": {
"state": {
"on": true,
"bri": 206,
"hue": 47018,
"sat": 254,
"effect": "none",
"xy": [
0.1532,
0.0502
],
"ct": 500,
"alert": "select",
"colormode": "xy",
"mode": "homeautomation",
"reachable": true
},
"swupdate": {
"state": "noupdates",
"lastinstall": "2021-09-17T16:31:08"
},
"type": "Extended color light",
"name": "Hue outdoor spot 2",
"modelid": "LCS001",
"manufacturername": "Signify Netherlands B.V.",
"productname": "Hue outdoor spot",
"capabilities": {
"certified": true,
"control": {
"mindimlevel": 100,
"maxlumen": 650,
"colorgamuttype": "C",
"colorgamut": [
[
0.6915,
0.3083
],
[
0.17,
0.7
],
[
0.1532,
0.0475
]
],
"ct": {
"min": 153,
"max": 500
}
},
"streaming": {
"renderer": true,
"proxy": true
}
},
"config": {
"archetype": "groundspot",
"function": "decorative",
"direction": "upwards",
"startup": {
"mode": "powerfail",
"configured": true
}
},
"uniqueid": "00:17:88:01:04:53:19:9f-0b",
"swversion": "1.88.1",
"swconfigid": "5290BE03",
"productid": "ENA-LCS001-1-LilySpikev1"
},
"19": {
"state": {
"on": true,
"bri": 204,
"hue": 65149,
"sat": 254,
"effect": "none",
"xy": [
0.6802,
0.3028
],
"ct": 500,
"alert": "select",
"colormode": "xy",
"mode": "homeautomation",
"reachable": true
},
"swupdate": {
"state": "noupdates",
"lastinstall": "2021-09-17T16:31:01"
},
"type": "Extended color light",
"name": "Hue outdoor spot 3",
"modelid": "LCS001",
"manufacturername": "Signify Netherlands B.V.",
"productname": "Hue outdoor spot",
"capabilities": {
"certified": true,
"control": {
"mindimlevel": 100,
"maxlumen": 650,
"colorgamuttype": "C",
"colorgamut": [
[
0.6915,
0.3083
],
[
0.17,
0.7
],
[
0.1532,
0.0475
]
],
"ct": {
"min": 153,
"max": 500
}
},
"streaming": {
"renderer": true,
"proxy": true
}
},
"config": {
"archetype": "groundspot",
"function": "decorative",
"direction": "upwards",
"startup": {
"mode": "powerfail",
"configured": true
}
},
"uniqueid": "00:17:88:01:04:53:19:9a-0b",
"swversion": "1.88.1",
"swconfigid": "5290BE03",
"productid": "ENA-LCS001-1-LilySpikev1"
},
"20": {
"state": {
"on": true,
"bri": 77,
"hue": 8417,
"sat": 140,
"effect": "none",
"xy": [
0.4573,
0.41
],
"ct": 366,
"alert": "select",
"colormode": "ct",
"mode": "homeautomation",
"reachable": true
},
"swupdate": {
"state": "noupdates",
"lastinstall": "2022-09-01T18:34:19"
},
"type": "Extended color light",
"name": "Hue color lamp 1",
"modelid": "LCT015",
"manufacturername": "Signify Netherlands B.V.",
"productname": "Hue color lamp",
"capabilities": {
"certified": true,
"control": {
"mindimlevel": 1000,
"maxlumen": 806,
"colorgamuttype": "C",
"colorgamut": [
[
0.6915,
0.3083
],
[
0.17,
0.7
],
[
0.1532,
0.0475
]
],
"ct": {
"min": 153,
"max": 500
}
},
"streaming": {
"renderer": true,
"proxy": true
}
},
"config": {
"archetype": "sultanbulb",
"function": "mixed",
"direction": "omnidirectional",
"startup": {
"mode": "safety",
"configured": true
}
},
"uniqueid": "00:17:88:01:03:fd:c2:45-0b",
"swversion": "1.88.1",
"swconfigid": "76B74E79",
"productid": "Philips-LCT015-1-A19ECLv5"
},
"21": {
"state": {
"on": true,
"alert": "select",
"mode": "homeautomation",
"reachable": true
},
"swupdate": {
"state": "noupdates",
"lastinstall": "2022-11-15T17:12:28"
},
"type": "On/Off plug-in unit",
"name": "Hue Smart plug 1",
"modelid": "LOM001",
"manufacturername": "Signify Netherlands B.V.",
"productname": "Hue Smart plug",
"capabilities": {
"certified": true,
"control": {},
"streaming": {
"renderer": false,
"proxy": false
}
},
"config": {
"archetype": "plug",
"function": "functional",
"direction": "omnidirectional",
"startup": {
"mode": "powerfail",
"configured": true
}
},
"uniqueid": "00:17:88:01:08:9d:58:df-0b",
"swversion": "1.76.10",
"swconfigid": "5C3EFAF7",
"productid": "SmartPlug_OnOff_v01-00_01"
}
}