Table of Contents
Server Events Stream:
The device supports a Server Events Stream at the link http://pwmdimmer.local/events
There is a limit to the number of streams that can be kept open at once. Please plan on limiting this to 4 streams at any one time. The Events Steam does not give you any information about the capabilities of the device or individual channels, please hit the /api/data link first to get initially setup and then open the events stream connection. The connected event is the only one that sends a simple value, all others send a short JSON string which is described below.
JSON Command Constants:
Name | Constant | Description |
---|---|---|
Address | addr | The address of the endpoint or 1-wire sensor. For GPIO Endpoint 1 the address will be the string “1” for a 1-wire sensor the address might be “A429FF” |
Device Type | APfx | The “Address Prefix” showing what kind of unit is being addressed. For a GPIO endpoint the value will be “xt.gpio” see below for a list of other suitable endpoints. |
Command | mcmd | The command being sent. For discrete gpio it will be “ON” or “OFF” for numerical values it will be “SetValue” |
Value | Valu | If the command is SetValue then the actual value will be sent with this key |
Update Only | UpDt | If the command is sending data that may not have changed from the last setting this value will be set to true. If it is present and true you should only take action on the new value if it is different from the last value you received. The RSSI and CPUTEMP commands are sent every 30 seconds but with this set to true |
Error | comm | If set to any value other than 0 then an error should be indicated for the endpoint or sensor being addressed. Will not always be present. Sending a 0 should cancel any error display. |
Temp Format | Frmt | Temperature sensors will send the temperature format that is configured for the device here along with readings. It will be a lower case “f” or “c” |
Color Mode | CLMd | The color mode requested of the virtual channel. Will be either “color” or “white” depending on if you should then look for a color or a white color temperature in the rest of the command. |
Color Temperature | CTmp | the numerical color temperature, like 2700 or 6500, may be included in the command even if the color mode is not “white”. |
Calculated Color Temperature | CaTm | An attempt to turn a requested color temperature into an RGB color value for devices that do not specifically support a color temperature. If in “white” mode and you are not a color capable device this will be used. It will not be as bright or as accurate as a device that properly supports it but is better than nothing |
RGB Color | RGBw | Standard RGB Color string as used in HTML and elsewhere. 3 hex bytes for RGB like “F82219”. May be included even if the color mode is not “color” |
HSV Color | HSVc | The color as a comma delimited list of Hue, Saturation and Value. Though Value is always going to be 100% and will be ignored as the rest of the values should be calculated taking the value from the value command level sent as a separate key. |
DeviceTypes:
Name | Constant | Description |
---|---|---|
PWM Channel | xt.pwm | Commands to a single PWM channel |
Color Device | xt.color | a virtual color device consisting of 3 RGB channels setup in the dimmer module. |
White Temperature | xt.white | A virtual color temperature capable pair of channels setup in the dimmer module. |
GPIO Endpoint | xt.gpio | Any update from a GPIO endpoint. |
Register | xt.register | Values without specific handling requirements may be sent as registers. The RSSI and Cpu Temperature values are sent as registers |
Temperature | xt.temp | 1-wire and DHT-22 Temperature sensors will use this as their Device Type/Address Prefix |
Humidity | xt.hum | DHT-22 sensors or any other humidity sources will use this Device Type |
RF Button | xt.rfbutton | An RF device type received from a 433 or other receiver on a GPIO pin. It will not create separate units for each receiver on the network, but just one that can be triggered from whatever receiver finds the signal first. |
Event Constants:
In general the kind of measurement or event that you are receiving should be taken from the Device Type portion of the command above, however a command string is also included that might be useful in knowing how to route or process the command.
Name | Constant | Content | Description |
---|---|---|---|
Connection Event | XTGPIO | Firmware Version number or string | Upon connection this event is sent. The value will be the firmware version of the device |
GPIO Event | gpio | Json String | An event has happened for one of the GPIO endpoints. New value, or new temp/reading etc |
1-Wire Reading | 1wire | Json String | A 1-wire sensor has a new reading |
Wifi Strength | RSSI | Json String | The Wifi Signal strength. These are currently sent every 30 seconds but will change in future builds to only send if the value has changed. |
CPU Temperature | CPUTEMP | Json String | The CPU Temperature in F as returned from the ESP32 core temp call. These are currently sent every 30 seconds but will change in future builds to only send if the value has changed |
PWM Value | PWM | Json String | The value of one of the PWM channels has changed. Sends a similar JSON string as above. |
Examples:
Connection Event:
id: 144265395 event: PWM data: 1.2.45.178.2234
GPIO #1 Changed State:
id: 1062735 event: gpio data: {"addr":"1","APfx":"xt.gpio","mcmd":"OFF"}
id: 1062735 event: gpio data: {"addr":"1","APfx":"xt.gpio","mcmd”:"ON"}
1-wire Temperature Reading:
id: 1461490365 event: 1wire data: {"addr":"FFA181","APfx":"xt.temp","mcmd":"SetValue","Valu":34.8125,"comm":0,"Frmt":"f"}
CPU Temperature Reading:
id: 1092236 event: CPUTEMP data: {"addr":"CPUTEMP","APfx":"xt.register","UpDt":true,"mcmd":"SetValue","Valu":122}
WiFi RSSI Reading:
id: 1122223 event: RSSI data: {"addr":"RSSI","APfx":"xt.register","UpDt":true,"mcmd":"SetValue","Valu":-48}