|
|
package lifx
import "encoding/json"
type ProductMap struct { Vid uint32 `json:"vid"` Name string `json:"name"` Defaults struct { Hev bool `json:"hev"` Color bool `json:"color"` Chain bool `json:"chain"` Matrix bool `json:"matrix"` Relays bool `json:"relays"` Buttons bool `json:"buttons"` Infrared bool `json:"infrared"` Multizone bool `json:"multizone"` TemperatureRange []int `json:"temperature_range"` ExtendedMultiZone bool `json:"extended_multizone"` } `json:"defaults"` Products []ProductMapEntry `json:"products"` }
type ProductMapEntry struct { Pid uint32 `json:"pid"` Name string `json:"name"` Features struct { Color bool `json:"color"` Chain bool `json:"chain"` Matrix bool `json:"matrix"` Infrared bool `json:"infrared"` MultiZone bool `json:"multizone"` TemperatureRange []int `json:"temperature_range,omitempty"` MinExtMzFirmware int `json:"min_ext_mz_firmware,omitempty"` MinExtMzFirmwareComponents []int `json:"min_ext_mz_firmware_components,omitempty"` Relays bool `json:"relays,omitempty"` Buttons bool `json:"buttons,omitempty"` Hev bool `json:"hev,omitempty"` } `json:"features"` Upgrades []struct { Major uint16 `json:"major"` Minor uint16 `json:"minor"` Features struct { TemperatureRange []int `json:"temperature_range,omitempty"` ExtendedMultizone *bool `json:"extended_multizone,omitempty"` } `json:"features"` } `json:"upgrades"` }
var productMap ProductMap
func findProduct(vendorId uint32, productId uint32) *ProductMapEntry { if vendorId != productMap.Vid { return nil }
for _, entry := range productMap.Products { if entry.Pid == productId { return &entry } }
return nil }
func init() { // Source: https://github.com/LIFX/products
// Commit: 2734460e132dd7ed32c3c0132345a758d47ff80b
err := json.Unmarshal([]byte(`{"vid":1,"name":"LIFX","defaults":{"hev":false,"color":false,"chain":false,"matrix":false,"relays":false,"buttons":false,"infrared":false,"multizone":false,"temperature_range":null,"extended_multizone":false},"products":[{"pid":1,"name":"LIFX Original 1000","features":{"color":true,"chain":false,"matrix":false,"infrared":false,"multizone":false,"temperature_range":[2500,9000]},"upgrades":[]},{"pid":3,"name":"LIFX Color 650","features":{"color":true,"chain":false,"matrix":false,"infrared":false,"multizone":false,"temperature_range":[2500,9000]},"upgrades":[]},{"pid":10,"name":"LIFX White 800 (Low Voltage)","features":{"color":false,"chain":false,"matrix":false,"infrared":false,"multizone":false,"temperature_range":[2700,6500]},"upgrades":[]},{"pid":11,"name":"LIFX White 800 (High Voltage)","features":{"color":false,"chain":false,"matrix":false,"infrared":false,"multizone":false,"temperature_range":[2700,6500]},"upgrades":[]},{"pid":15,"name":"LIFX Color 1000","features":{"color":true,"chain":false,"matrix":false,"infrared":false,"multizone":false,"temperature_range":[2500,9000]},"upgrades":[]},{"pid":18,"name":"LIFX White 900 BR30 (Low Voltage)","features":{"color":false,"chain":false,"matrix":false,"infrared":false,"multizone":false,"temperature_range":[2500,9000]},"upgrades":[]},{"pid":19,"name":"LIFX White 900 BR30 (High Voltage)","features":{"color":false,"chain":false,"matrix":false,"infrared":false,"multizone":false,"temperature_range":[2500,9000]},"upgrades":[]},{"pid":20,"name":"LIFX Color 1000 BR30","features":{"color":true,"chain":false,"matrix":false,"infrared":false,"multizone":false,"temperature_range":[2500,9000]},"upgrades":[]},{"pid":22,"name":"LIFX Color 1000","features":{"color":true,"chain":false,"matrix":false,"infrared":false,"multizone":false,"temperature_range":[2500,9000]},"upgrades":[]},{"pid":27,"name":"LIFX A19","features":{"color":true,"chain":false,"matrix":false,"infrared":false,"multizone":false,"temperature_range":[2500,9000]},"upgrades":[{"major":2,"minor":80,"features":{"temperature_range":[1500,9000]}}]},{"pid":28,"name":"LIFX BR30","features":{"color":true,"chain":false,"matrix":false,"infrared":false,"multizone":false,"temperature_range":[2500,9000]},"upgrades":[{"major":2,"minor":80,"features":{"temperature_range":[1500,9000]}}]},{"pid":29,"name":"LIFX A19 Night Vision","features":{"color":true,"chain":false,"matrix":false,"infrared":true,"multizone":false,"temperature_range":[2500,9000]},"upgrades":[{"major":2,"minor":80,"features":{"temperature_range":[1500,9000]}}]},{"pid":30,"name":"LIFX BR30 Night Vision","features":{"color":true,"chain":false,"matrix":false,"infrared":true,"multizone":false,"temperature_range":[2500,9000]},"upgrades":[{"major":2,"minor":80,"features":{"temperature_range":[1500,9000]}}]},{"pid":31,"name":"LIFX Z","features":{"color":true,"chain":false,"matrix":false,"infrared":false,"multizone":true,"temperature_range":[2500,9000]},"upgrades":[]},{"pid":32,"name":"LIFX Z","features":{"color":true,"chain":false,"matrix":false,"infrared":false,"multizone":true,"temperature_range":[2500,9000],"min_ext_mz_firmware":1532997580,"min_ext_mz_firmware_components":[2,77]},"upgrades":[{"major":2,"minor":77,"features":{"extended_multizone":true}},{"major":2,"minor":80,"features":{"temperature_range":[1500,9000]}}]},{"pid":36,"name":"LIFX Downlight","features":{"color":true,"chain":false,"matrix":false,"infrared":false,"multizone":false,"temperature_range":[2500,9000]},"upgrades":[{"major":2,"minor":80,"features":{"temperature_range":[1500,9000]}}]},{"pid":37,"name":"LIFX Downlight","features":{"color":true,"chain":false,"matrix":false,"infrared":false,"multizone":false,"temperature_range":[2500,9000]},"upgrades":[{"major":2,"minor":80,"features":{"temperature_range":[1500,9000]}}]},{"pid":38,"name":"LIFX Beam","features":{"color":true,"chain":false,"matrix":false,"infrared":false,"multizone":true,"temperature_range":[2500,9000],"min_ext_mz_firmware":1532997580,"min_ext_mz_firmware_components":[2,77]},"upgrades":[{"major":2,"minor":77,"features if err != nil { panic(err) } }
|