# LED Widget

**General Setting**

User can change following things in LED widget:

* Name for widget which will be used data referenceFor Example, if widget name is 'LED', then data of widget is referenced as LED.data
* Show title - User can show/hide widget title
* Title Color
* Background Color

![Configure LED Widget](https://365492316-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7aTljSjWsfbXZ_OP_9%2Fuploads%2FXASbaNMKKrCFMS4nXpLt%2Fledgeneral.png?alt=media\&token=5524f8c5-77c6-4d12-a902-fe782ea79438)

**Widget Setting**

In Widget Setting option, user can change following parameters:

* Key - key parameter of JSON Object which will define state of LED.
* LED Style - Select one from available options of LED

![Configure LED Widget](https://365492316-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7aTljSjWsfbXZ_OP_9%2Fuploads%2FIZbbu2T7WfBwm6gvDVi8%2FledWidget.png?alt=media\&token=8c78e5a9-f4f8-4d18-bd3b-524794dbc95c)

User can manage state of LED using MQTT or Actions. To change state of LED, user need to send data in following format.

```
{"dataKey":true/false}   
OR
{"dataKey":1/0} 

// 'dataKey' is set as key in widget form.
```

#### Source <a href="#source" id="source"></a>

User can select a source mode as MQTT or Action.

**Using MQTT**

Here, to change state of LED user can publish JSON object on given **data** MQTT topic. No need to provide \<account\_id> while providing the MQTT topic. The JSON object will be as below.

```
{"dataKey":true/false}   
OR
{"dataKey":1/0} 

// 'dataKey' is set as key in widget form.
```

![Configure LED Widget](https://365492316-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7aTljSjWsfbXZ_OP_9%2Fuploads%2FvyJlymoxREdo0POc0K0e%2FdropdownSourceMQTT.png?alt=media\&token=25dc7ab6-ecf4-4f6b-a2a4-bd2119278a7a)

**Using Action**

Here, to change state of LED, output of the action should contain key-value pair with 'dataKey' key. User can also update the widget either onLoad or periodically by providing refresh interval.

![Configure LED Widget](https://365492316-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7aTljSjWsfbXZ_OP_9%2Fuploads%2FyyEv1NXz6g1DGHk03LpR%2FdropdownSourceAction.png?alt=media\&token=714b3cb5-50e0-4865-8150-439acff11815)

#### Event Handling

LED widget does not support any event.

#### Example

If we configure LED Widget as below:

1. key - testWidgetKey

and set source type for widget as MQTT and topic configured is 'data'. And if we publish following JSON Object over 'data' topic then LED Widget will look as shown in image.

```
// Data over configured MQTT Topic

{ 
    "ledKey":true/1 
}

OR 

{ 
    "ledKey":false/0
}
```

![Enabled LED Widget](https://365492316-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7aTljSjWsfbXZ_OP_9%2Fuploads%2FAcD6AnGYZHqnUVo4DGxC%2FScreenshot%202022-01-15%20at%205.01.20%20PM.png?alt=media\&token=f92978a9-84ec-4a78-8272-bc0215fd4853) ![Disabled LED Widget](https://365492316-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7aTljSjWsfbXZ_OP_9%2Fuploads%2FSbbCbtxz4354mrm6JXTN%2FScreenshot%202022-01-15%20at%205.17.44%20PM.png?alt=media\&token=529f04f7-f2b6-406b-8bd6-ec218390054d)
