User Tools

Site Tools


kits:gpio:api:events

Server Events Stream:

The device supports a Server Events Stream at the link: http://xtgio.local/events

There is a limit to the number of streams the device can keep open at once. Please plan to limit the number of connected clients to at most 4. The events stream does not give you any indication of the capabilities or configuration of the device, please first hit the /api/data request to get information on all the endpoints or other info that might be sent through the endpoint. The connection event below is the only one that sends a simple value. All other events send a short JSON command using the constants 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”

DeviceTypes:

NameConstantDescription
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

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

Examples:

Connection Event:

id: 144265395
event: XTGPIO
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/gpio/api/events.txt · Last modified: 2023/02/13 14:52 by 127.0.0.1