var UNIT_PARAMS = {
minMireds: 153,
maxMireds: 370,
maxBrightness: 255
};
var UI_TABS = [ {
tag: "tab-wifi",
friendly: "Wifi",
}, {
tag: "tab-setup",
friendly: "Setup",
}, {
tag: "tab-led",
friendly: "LED",
}, {
tag: "tab-radio",
friendly: "Radio",
}, {
tag: "tab-mqtt",
friendly: "MQTT"
}
];
var UI_FIELDS = [ {
tag: "admin_username",
friendly: "Admin username",
help: "Username for logging into this webpage",
type: "string",
tab: "tab-wifi"
}, {
tag: "admin_password",
friendly: "Password",
help: "Password for logging into this webpage",
type: "string",
tab: "tab-wifi"
}, {
tag: "ce_pin",
friendly: "CE / PKT pin",
help: "Pin on ESP8266 used for 'CE' (for NRF24L01 interface) or 'PKT' (for 'PL1167/LT8900' interface)",
type: "string",
tab: "tab-setup"
}, {
tag: "csn_pin",
friendly: "CSN pin",
help: "Pin on ESP8266 used for 'CSN'",
type: "string",
tab: "tab-setup"
}, {
tag: "reset_pin",
friendly: "RESET pin",
help: "Pin on ESP8266 used for 'RESET'",
type: "string",
tab: "tab-setup"
}, {
tag: "led_pin",
friendly: "LED pin",
help: "Pin to use for LED status display (0=disabled); negative inverses signal (recommend -2 for on-board LED)",
type: "string",
tab: "tab-setup"
}, {
tag: "packet_repeats",
friendly: "Packet repeats",
help: "The number of times to repeat RF packets sent to bulbs",
type: "string",
tab: "tab-radio"
}, {
tag: "http_repeat_factor",
friendly: "HTTP repeat factor",
help: "Multiplicative factor on packet_repeats for requests initiated by the HTTP API. UDP API typically receives " +
"duplicate packets, so more repeats should be used for HTTP",
type: "string",
tab: "tab-wifi"
}, {
tag: "auto_restart_period",
friendly: "Auto-restart period",
help: "Automatically restart the device every number of minutes specified. Use 0 for disabled",
type: "string",
tab: "tab-setup"
}, {
tag: "discovery_port",
friendly: "Discovery port",
help: "UDP port to listen for discovery packets on. Defaults to the same port used by MiLight devices, 48899. Use 0 to disable",
type: "string",
tab: "tab-wifi"
}, {
tag: "mqtt_server",
friendly: "MQTT server",
help: "Domain or IP address of MQTT broker. Optionally specify a port with (example) myMQTTbroker.com:1884",
type: "string",
tab: "tab-mqtt"
}, {
tag: "mqtt_topic_pattern",
friendly: "MQTT topic pattern",
help: "Pattern for MQTT topics to listen on. Example: lights/:device_id/:device_type/:group_id. See README for further details",
type: "string",
tab: "tab-mqtt"
}, {
tag: "mqtt_update_topic_pattern",
friendly: "MQTT update topic pattern",
help: "Pattern to publish MQTT updates. Packets that are received from other devices, and packets that are sent from this device will " +
"result in updates being sent",
type: "string",
tab: "tab-mqtt"
}, {
tag: "mqtt_state_topic_pattern",
friendly: "MQTT state topic pattern",
help: "Pattern for MQTT topic to publish state to. When a group changes state, the full known state of the group will be published to this topic pattern",
type: "string",
tab: "tab-mqtt"
}, {
tag: "mqtt_username",
friendly: "MQTT user name",
help: "User name to log in to MQTT server",
type: "string",
tab: "tab-mqtt"
}, {
tag: "mqtt_password",
friendly: "MQTT password",
help: "Password to log into MQTT server",
type: "string",
tab: "tab-mqtt"
}, {
tag: "radio_interface_type",
friendly: "Radio interface type",
help: "2.4 GHz radio model. Only change this if you know you're not using an NRF24L01!",
type: "radio_interface_type",
tab: "tab-radio"
}, {
tag: "listen_repeats",
friendly: "Listen repeats",
help: "Increasing this increases the amount of time spent listening for " +
"packets. Set to 0 to disable listening. Default is 3.",
type: "string",
tab: "tab-wifi"
}, {
tag: "state_flush_interval",
friendly: "State flush interval",
help: "Minimum number of milliseconds between flushing state to flash. " +
"Set to 0 to disable delay and immediately persist state to flash",
type: "string",
tab: "tab-setup"
}, {
tag: "mqtt_state_rate_limit",
friendly: "MQTT state rate limit",
help: "Minimum number of milliseconds between MQTT updates of bulb state (defaults to 500)",
type: "string",
tab: "tab-mqtt"
}, {
tag: "packet_repeat_throttle_threshold",
friendly: "Packet repeat throttle threshold",
help: "Controls how packet repeats are throttled. Packets sent " +
"with less time between them than this value (in milliseconds) will cause " +
"packet repeats to be throttled down. More than this value will unthrottle " +
"up. Defaults to 200ms",
type: "string",
tab: "tab-radio"
}, {
tag: "packet_repeat_throttle_sensitivity",
friendly: "Packet repeat throttle sensitivity",
help: "Controls how packet repeats are throttled. " +
"Higher values cause packets to be throttled up and down faster " +
"(defaults to 0, maximum value 1000, 0 disables)",
type: "string",
tab: "tab-radio"
}, {
tag: "packet_repeat_minimum",
friendly: "Packet repeat minimum",
help: "Controls how far throttling can decrease the number " +
"of repeated packets (defaults to 3)",
type: "string",
tab: "tab-radio"
}, {
tag: "group_state_fields",
friendly: "Group state fields",
help: "Selects which fields should be included in MQTT state updates and REST responses for bulb state",
type: "group_state_fields",
tab: "tab-mqtt"
}, {
tag: "enable_automatic_mode_switching",
friendly: "Enable automatic mode switching",
help: "For RGBWW bulbs (using RGB+CCT or FUT089), enables automatic switching between modes in order to affect changes to " +
"temperature and saturation when otherwise it would not work",
type: "enable_automatic_mode_switching",
tab: "tab-radio"
}, {
tag: "led_mode_wifi_config",
friendly: "LED mode during wifi config",
help: "LED mode when the device is in Access Point mode waiting to configure Wifi",
type: "led_mode",
tab: "tab-led"
}, {
tag: "led_mode_wifi_failed",
friendly: "LED mode when wifi failed to connect",
help: "LED mode when the device has failed to connect to the wifi network",
type: "led_mode",
tab: "tab-led"
}, {
tag: "led_mode_operating",
friendly: "LED mode when operating",
help: "LED mode when the device is in successfully running",
type: "led_mode",
tab: "tab-led"
}, {
tag: "led_mode_packet",
friendly: "LED mode on packets",
help: "LED mode when the device is sending or receiving packets",
type: "led_mode",
tab: "tab-led"
}, {
tag: "led_mode_packet_count",
friendly: "Flash count on packets",
help: "Number of times the LED will flash when packets are changing",
type: "string",
tab: "tab-led"
}
];
// TODO: sync this with GroupStateField.h
var GROUP_STATE_KEYS = [
"state",
"status",
"brightness",
"level",
"hue",
"saturation",
"color",
"mode",
"kelvin",
"color_temp",
"bulb_mode",
"computed_color",
"effect",
"device_id",
"group_id",
"device_type",
"oh_color"
];
var LED_MODES = [
"Off",
"Slow toggle",
"Fast toggle",
"Slow blip",
"Fast blip",
"Flicker",
"On"
];
var UDP_PROTOCOL_VERSIONS = [ 5, 6 ];
var DEFAULT_UDP_PROTOCL_VERSION = 5;
var selectize;
var sniffing = false;
var loadingSettings = false;
// don't attempt websocket if we are debugging locally
if (location.hostname != "") {
var webSocket = new WebSocket("ws://" + location.hostname + ":81");
webSocket.onmessage = function(e) {
if (sniffing) {
var message = e.data;
$('#sniffed-traffic').prepend('