User Tools

Site Tools


kits:pwm:api:events

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:

NameConstantDescription
AddressaddrThe 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 TypeAPfxThe “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.
CommandmcmdThe command being sent. For discrete gpio it will be “ON” or “OFF” for numerical values it will be “SetValue”
ValueValuIf the command is SetValue then the actual value will be sent with this key
Update OnlyUpDtIf 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
ErrorcommIf 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 FormatFrmtTemperature 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 ModeCLMdThe 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 TemperatureCTmpthe numerical color temperature, like 2700 or 6500, may be included in the command even if the color mode is not “white”.
Calculated Color TemperatureCaTmAn 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 ColorRGBwStandard 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 ColorHSVcThe 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:

NameConstantDescription
PWM Channelxt.pwmCommands to a single PWM channel
Color Devicext.colora virtual color device consisting of 3 RGB channels setup in the dimmer module.
White Temperaturext.whiteA virtual color temperature capable pair of channels setup in the dimmer module.
GPIO Endpointxt.gpioAny update from a GPIO endpoint.
Registerxt.registerValues without specific handling requirements may be sent as registers. The RSSI and Cpu Temperature values are sent as registers
Temperaturext.temp1-wire and DHT-22 Temperature sensors will use this as their Device Type/Address Prefix
Humidityxt.humDHT-22 sensors or any other humidity sources will use this Device Type
RF Buttonxt.rfbuttonAn 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.

NameConstantContentDescription
Connection EventXTGPIOFirmware Version number or stringUpon connection this event is sent. The value will be the firmware version of the device
GPIO EventgpioJson StringAn event has happened for one of the GPIO endpoints. New value, or new temp/reading etc
1-Wire Reading1wireJson StringA 1-wire sensor has a new reading
Wifi StrengthRSSIJson StringThe 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 TemperatureCPUTEMPJson StringThe 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 ValuePWMJson StringThe 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}
kits/pwm/api/events.txt · Last modified: 2023/02/13 14:52 by 127.0.0.1