Hardware Setup
Philip Light HTTP Requests
http://10.0.2.16/api/newdeveloper/lights
Code Block | ||||
---|---|---|---|---|
| ||||
{
"1": {
"state": {
"on": true,
"bri": 144,
"hue": 13088,
"sat": 212,
"effect": "none",
"xy": [
0.5128,
0.4147
],
"ct": 467,
"alert": "none",
"colormode": "hs",
"reachable": true
},
"type": "Extended color light",
"name": "Hue Lamp 1",
"modelid": "LCT001",
"uniqueid": "00:17:88:01:00:b6:c6:f0-0b",
"swversion": "66009663",
"pointsymbol": {
"1": "none",
"2": "none",
"3": "none",
"4": "none",
"5": "none",
"6": "none",
"7": "none",
"8": "none"
}
},
"2": {
"state": {
"on": true,
"bri": 144,
"hue": 13088,
"sat": 212,
"effect": "none",
"xy": [
0.5128,
0.4147
],
"ct": 467,
"alert": "none",
"colormode": "ct",
"reachable": true
},
"type": "Extended color light",
"name": "Hue Lamp 2",
"modelid": "LCT001",
"uniqueid": "00:17:88:01:00:b9:38:7c-0b",
"swversion": "66009663",
"pointsymbol": {
"1": "none",
"2": "none",
"3": "none",
"4": "none",
"5": "none",
"6": "none",
"7": "none",
"8": "none"
}
},
"3": {
"state": {
"on": true,
"bri": 144,
"hue": 13088,
"sat": 212,
"effect": "none",
"xy": [
0.5128,
0.4147
],
"ct": 467,
"alert": "none",
"colormode": "hs",
"reachable": true
},
"type": "Extended color light",
"name": "Hue Lamp 3",
"modelid": "LCT001",
"uniqueid": "00:17:88:01:00:b9:38:5c-0b",
"swversion": "66009663",
"pointsymbol": {
"1": "none",
"2": "none",
"3": "none",
"4": "none",
"5": "none",
"6": "none",
"7": "none",
"8": "none"
}
}
} |
http://10.0.2.16/api/newdeveloper/lights/1/state
Code Block | ||||
---|---|---|---|---|
| ||||
{"on":true} |
Queries
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<Query> <Find format="all"> <PhilipLightModel> <LightNumber eq="1"/> </PhilipLightModel> </Find> </Query> |
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<Namespace Name="Atomiton">
<Domain Name="Lights">
<PhilipLightBaseURI>http://10.0.2.16/api/newdeveloper</PhilipLightBaseURI>
<Macro Name="ExecuteQuery">
<Argument>
<QueryString>
<Query/>
</QueryString>
</Argument>
<Result>
<OnRequest>
<Target>[:RuntimeParams.FacetIDName:]</Target>
<Process>
<Message>
<Value>[:$Macro.Argument.QueryString:]</Value>
</Message>
</Process>
</OnRequest>
</Result>
</Macro>
<Macro Name="AddLight">
<Argument>
<LightNumber/>
<On/>
<bri/>
<hue/>
<sat/>
</Argument>
<Result>
<ExecuteQuery>
<QueryString>
<DeleteAll>
<PhilipLightModel>
<LightNumber eq="[:$Macro.Argument.LightNumber:]"/>
</PhilipLightModel>
</DeleteAll>
<Create>
<PhilipLightModel>
<LightNumber>[:$Macro.Argument.LightNumber:]</LightNumber>
<state>
<On>[:$Macro.Argument.On:]</On>
<bri>[:$Macro.Argument.bri:]</bri>
<hue>[:$Macro.Argument.hue:]</hue>
<sat>[:$Macro.Argument.sat:]</sat>
</state>
</PhilipLightModel>
</Create>
</QueryString>
</ExecuteQuery>
</Result>
</Macro>
<Def Name="PhilipLightState">
<Boolean Name="On"/>
<Integer Name="bri"/>
<Integer Name="hue"/>
<Integer Name="sat"/>
<String Name="effect"/>
<Double Name="xy" cardinality="2"/>
<Integer Name="ct"/>
<String Name="alert"/>
<String Name="colormode"/>
<Boolean Name="reachable"/>
</Def>
<Def Name="PointSymbol">
<String name="1" default="none"/>
<String name="2" default="none"/>
<String name="3" default="none"/>
<String name="4" default="none"/>
<String name="5" default="none"/>
<String name="6" default="none"/>
<String name="7" default="none"/>
<String name="8" default="none"/>
</Def>
<ThingFacet Name="PhilipLightFacet">
<String Name="LightNumber"/>
<PhilipLightState Name="state" KnownBy="PhilipLightActionUsingCurl"/>
<String Name="Type"/>
<String Name="Name"/>
<String Name="modelid"/>
<String Name="uniqueid"/>
<String Name="swversion"/>
<PointSymbol Name="Pointsymbol"/>
<AA>[:#o#Event.Argument:]</AA>
<Ontrue>{"on":true}</Ontrue>
<Onfalse>"on":false</Onfalse>
<Action Name="PhilipLightActionUsingCurl">
<Workflow Limit="1" Live="1" Timeout="-1">
<Task name="Main" While="True">
<Event name="Argument" as="ActionArgument"/>
<Invoke name="SetState" waitFor="ActionArgument"
execute="curl -X PUT -d '{"on":[%:[:AA:].state.On.Value:%]}' [:PhilipLightBaseURI:]/lights/[%:[:AA:].LightNumber.Value:%]/state"/>
<Log Message="[:Invoke.SetState:]"/>
<Output name="Result" as="ActionResult">
<Value>
<state>
[%:[:AA:].state.On.Value:%]
</state>
</Value>
</Output>
</Task>
</Workflow>
</Action>
</ThingFacet>
<ThingFacet Name="PhilipLightManagerFacet">
<String Name="LoadLights" KnownBy="LoadLightsAction"/>
<Action Name="LoadLightsAction">
<Workflow Limit="1" Live="1" Timeout="-1">
<Task Name="Main" While="True">
<Event Name="Argument" as="ActionArgument"/>
<Invoke Name="GetLights" waitFor="ActionArgument" Get="[:PhilipLightBaseURI:]/lights"/>
<Log Message="Lights Loaded...[:Invoke.GetLights.Message.Value:]"/>
<Invoke Name="ParseGetLightsResult">
<FacetScript>
<AddLight>
<LightNumber>1</LightNumber>
<On>[:Invoke.GetLights.Message.Value.1.State.On:]</On>
<bri>[:Invoke.GetLights.Message.Value.1.State.bri:]</bri>
<hue>[:Invoke.GetLights.Message.Value.1.State.hue:]</hue>
<sat>[:Invoke.GetLights.Message.Value.1.State.sat:]</sat>
</AddLight>
<AddLight>
<LightNumber>2</LightNumber>
<On>[:Invoke.GetLights.Message.Value.2.State.On:]</On>
<bri>[:Invoke.GetLights.Message.Value.2.State.bri:]</bri>
<hue>[:Invoke.GetLights.Message.Value.2.State.hue:]</hue>
<sat>[:Invoke.GetLights.Message.Value.2.State.sat:]</sat>
</AddLight>
<AddLight>
<LightNumber>3</LightNumber>
<On>[:Invoke.GetLights.Message.Value.3.State.On:]</On>
<bri>[:Invoke.GetLights.Message.Value.3.State.bri:]</bri>
<hue>[:Invoke.GetLights.Message.Value.3.State.hue:]</hue>
<sat>[:Invoke.GetLights.Message.Value.3.State.sat:]</sat>
</AddLight>
</FacetScript>
</Invoke>
<Output Name="Result" as="ActionResult">
<Value>
<LoadLights>True</LoadLights>
</Value>
</Output>
</Task>
</Workflow>
</Action>
</ThingFacet>
<ThingModel Name="PhilipLightModel" Combines="PhilipLightFacet">
<Sid Name="LightId"/>
</ThingModel>
<ThingModel Name="PhilipLightManagerModel" Combines="PhilipLightManagerFacet">
<sid Name="ManagerId"/>
</ThingModel>
</Domain>
</Namespace>
|