kits:pwm:api:data

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

kits:pwm:api:data [2021/11/01 15:50] (current)
James Sentman created
Line 1: Line 1:
 +=====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:====
 +<​code>​
 +{
 +    "​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
 +        }
 +    ]
 +}
 +
 +
 +</​code>​
 +
 +====Json Keys:====
 +^Name^Json Constant Key^Description^
 +|Device, channel or GPIO Name|name|The name of the device, Channel or GPIO, as set on the Settings configuration page.|
 +|Temp Format|format|The configured temperature format. Will be either “F” or “C”.|
 +|Wifi Signal Strength|rssi|A negative number showing the strength of the WiFi connection.|
 +|CPU Temperature|cputemp|The temperature in F of the CPU.|
 +|PWM Channel Array|channels|An array of all 6 PWM channels holding all their information.|
 +|Channel or GPIO Index|index|All channels or GPIO will include the index in their list object.|
 +|Value|value|The brightness of any PWM channel, also the temperature of sensors or analog readings of those GPIO.|
 +|Dimmable|dimmable|Boolean,​ 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 Array|gpio|An array of configured GPIO objects. Only those objects in use and having a value will be listed.|
 +|GPIO Type|type|Integer,​ In the GPIO array every object will show what type it is. See the list of GPIO Types below.|
 +|Temperature|temp|for DHT-22 devices on GPIO pins the temperature will be included as a float here.|
 +|Humidity|hum|For 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 State|state|Boolean,​ for discrete GPIO inputs and outputs the state will be true or false.|
 +|One Wire Array|onewire|An array of all discovered 1-wire devices on the 1-wire bus.|
 +|Device ID|id|the 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.|
 +|Reliability|reliability|A 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.
 +
 +^ID^Name^Description^
 +|0|NONE|channel is unused. Will not be included in the output list|
 +|1|OUTPUT_LOW|GPIO Output being LOW at power on|
 +|2|OUTPUT_HIGH|GPIO Output being HIGH at power on|
 +|3|OUTPUT_RETURN|GPIO Output returning to the last saved state prior to the power failure|
 +|4|PWM Output|Not currently implemented,​ use the real PWM outputs|
 +|5|DAC OUTPUT|Some channels support analog voltage outputs.|
 +|6|INPUT_PULLUP|GPIO Input with pullup resister turned on.|
 +|7|INPUT_PULLDOWN|GPIO Input with pulldown resister turned on.|
 +|8|INPUT_FLOAT|GPIO Input with neither pull up nor pulldown turned on, bring your own. This is unimplemented at the moment|
 +|9|BUTTON_LOW|A button connected to GND. Including standard debouncing and commands for double click and hold.|
 +|10|SWITCH_LOW|A switch connected to GND. Including common debouncing values.|
 +|11|COUNTER_LOW|A counter input connecting to ground.|
 +|12|ANALOG|Analog voltage input. from 0.0 t0 3.1v input.|
 +|13|TOUCH|Capacitive Touch Sensor Input.|
 +|14|CAPACITENCE|The measured capacitence value of a touch sensor as an analog value.|
 +|15|ENCODER1_A|The first encoder input for line A.|
 +|16|ENCODER1_B|The first encoder input for line B.|
 +|17|ENCODER2_A|The second encoder input for line A.|
 +|18|Encoder2_B|The second encoder input for line B.|
 +|19|COUNTER_THRESHOLD|Currently unimplemented. An analog value that counts when going over a specific value.|
 +|20|ANALOG_THRESHOLD|Currently unimplemented,​ An analog value that turns a discrete GPIO on and off as it passes above or below a certain value.|
 +|21|DHT|A DHT-22 Temp and Humidity sensor.|
 +|22|433Mhz Radio Receiver.|
 +|23|IR|IR Remote Receiver.|
 +|24|SERVO|Servo Control Output.|
 +|25|BUTTON_HIGH|Like the BUTTON_LOW but connected to V+.|
 +|26|SWITCH_HIGH|Like the SWITCH_LOW but connected to V+.|
 +|27|COUNTER_HIGH|Like the COUNTER_LOW but connected to V+.|
 +
 +
  
kits/pwm/api/data.txt · Last modified: 2021/11/01 15:50 by James Sentman