Simple REST API to control magic-home lights on the same network, built with magic-home and express.
Gets a list of magic-home devices on the network
URL : /api/devices/
Method : GET
Auth required : NO
Permissions required : None
Code : 200 OK
Content example
[
{
"address": "192.168.69.198",
"id": "F4CFA2120867",
"model": "AK001-ZJ2101"
}
]
Gets a the state of a magic-home device, by it's id
URL : /api/device/:id
Method : GET
Auth required : NO
Permissions required : None
Code : 200 OK
Content example
{
"type": 51,
"on": true,
"mode": "color",
"speed": 66.66666666666667,
"color": {
"red": 255,
"green": 255,
"blue": 0
},
"warm_white": 0,
"cold_white": 0
}
Change the color of a magic-home device, by it's address or id.
URL : /api/color/
Method : POST
Auth required : NO
Permissions required : None
Data constraints
If no id or address is provided, all lights on the network will receive this change.
{
"id": "id of magic-home device, string, optional",
"address": "address of magic-home device, string, optional",
"color": "color to change to, string (hex) or number (decimal), required",
"brightness": "brightness to adjust the color with, number, optional"
}
Data example All fields must be sent.
{
"id": "F4CFA2120867",
"address": "192.168.69.198",
"color": "#FF0000", // or "FF0000" or 16711680
"brightness": "100"
}
Condition : Color commands were sent
Code : 200 OK