User Tools

Site Tools


kits:pwm:api:data

API: PWM Dimmer Data Request:

The current state of all Channels, GPIO inputs and outputs as well as temperatures from 1-wire and others can be polled for by visiting http://pwmdimmer.local/api/data

The data is returned as a JSON object with the keys as listed below.

Example Output:

{
    "name": “Library Dimmer,
    "format": "F",
    "rssi": -39,
    "cputemp": 123, 
    "channels": [
        {
            "index": 1,
            "name": "Library Shelf 1",
            "value": 0,
            "dimmable": true
        },
        {
            "index": 2,
            "name": "Library Shelf 2",
            "value": 0,
            "dimmable": true
        },
        {
            "index": 3,
            "name": "LIbrary Shelf 3",
            "value": 0,
            "dimmable": true
        },
        {
            "index": 4,
            "name": "Library Peacock",
            "value": 100,
            "dimmable": true
        },
        {
            "index": 5,
            "name": "Library Fairy Bottle",
            "value": 58,
            "dimmable": true
        },
        {
            "index": 6,
            "name": "PWM Channel 6",
            "value": 100,
            "dimmable": true
        }
    ],
       "gpio": [
        {
            "index": 1,
            "name": "GPIO #1",
            "type": 3,
            "dimmable": false,
            "state": true
        },
        {
            “index”:5,
            “name”:”TEMP/HUM Sensor”,
            “type”:21,
            “temp”:76.4,
            “hum”:43
        }
    ],
    "onewire": [
        {
            "id": "AD5079",
            "value": 79.3625,
            "reliability": 100
        },
        {
            "id": "0F5579",
            "value": 79.8125,
            "reliability": 74
        }
    ]
}

Json Keys:

NameJson Constant KeyDescription
Device, channel or GPIO NamenameThe name of the device, Channel or GPIO, as set on the Settings configuration page.
Temp FormatformatThe configured temperature format. Will be either “F” or “C”.
Wifi Signal StrengthrssiA negative number showing the strength of the WiFi connection.
CPU TemperaturecputempThe temperature in F of the CPU.
PWM Channel ArraychannelsAn array of all 6 PWM channels holding all their information.
Channel or GPIO IndexindexAll channels or GPIO will include the index in their list object.
ValuevalueThe brightness of any PWM channel, also the temperature of sensors or analog readings of those GPIO.
DimmabledimmableBoolean, for PWM channels if the device will accept a value command or not and for GPIO if the input/output type will accept a numerical value or just a simple on/off command.
GPIO ArraygpioAn array of configured GPIO objects. Only those objects in use and having a value will be listed.
GPIO TypetypeInteger, In the GPIO array every object will show what type it is. See the list of GPIO Types below.
Temperaturetempfor DHT-22 devices on GPIO pins the temperature will be included as a float here.
HumidityhumFor DHT-22 devices on GPIO pins the humidity will be included as an integer or possibly float here depending on the resolution of the device.
GPIO StatestateBoolean, for discrete GPIO inputs and outputs the state will be true or false.
One Wire ArrayonewireAn array of all discovered 1-wire devices on the 1-wire bus.
Device IDidthe address of the one wire device hashed to 3 bytes of hex. Ignoring the device type of the address using only the unique ID portion.
ReliabilityreliabilityA calculation based on how many times the 1-wire bus is scanned that a valid value was received from the specific 1-wire device, or if it wasn’t found that is considered an error as well. Many things can interfere with a 1-wire bus and if readings are failing they will affect the reliability reading here. Note that this has some issues in calculation and can go above 100% and also below 0% on occation.

GPIO Types:

The type codes used above to show what the GPIO is setup as. Only device types that can possible output or input useful data are shown. Endpoints shown as Unused are not shown.

IDNameDescription
0NONEchannel is unused. Will not be included in the output list
1OUTPUT_LOWGPIO Output being LOW at power on
2OUTPUT_HIGHGPIO Output being HIGH at power on
3OUTPUT_RETURNGPIO Output returning to the last saved state prior to the power failure
4PWM OutputNot currently implemented, use the real PWM outputs
5DAC OUTPUTSome channels support analog voltage outputs.
6INPUT_PULLUPGPIO Input with pullup resister turned on.
7INPUT_PULLDOWNGPIO Input with pulldown resister turned on.
8INPUT_FLOATGPIO Input with neither pull up nor pulldown turned on, bring your own. This is unimplemented at the moment
9BUTTON_LOWA button connected to GND. Including standard debouncing and commands for double click and hold.
10SWITCH_LOWA switch connected to GND. Including common debouncing values.
11COUNTER_LOWA counter input connecting to ground.
12ANALOGAnalog voltage input. from 0.0 t0 3.1v input.
13TOUCHCapacitive Touch Sensor Input.
14CAPACITENCEThe measured capacitence value of a touch sensor as an analog value.
15ENCODER1_AThe first encoder input for line A.
16ENCODER1_BThe first encoder input for line B.
17ENCODER2_AThe second encoder input for line A.
18Encoder2_BThe second encoder input for line B.
19COUNTER_THRESHOLDCurrently unimplemented. An analog value that counts when going over a specific value.
20ANALOG_THRESHOLDCurrently unimplemented, An analog value that turns a discrete GPIO on and off as it passes above or below a certain value.
21DHTA DHT-22 Temp and Humidity sensor.
22433Mhz Radio Receiver.
23IRIR Remote Receiver.
24SERVOServo Control Output.
25BUTTON_HIGHLike the BUTTON_LOW but connected to V+.
26SWITCH_HIGHLike the SWITCH_LOW but connected to V+.
27COUNTER_HIGHLike the COUNTER_LOW but connected to V+.
kits/pwm/api/data.txt · Last modified: 2023/02/13 14:52 by 127.0.0.1