diff --git a/README.md b/README.md index 34e74a7..7be9c49 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,8 @@ Please note that this script does not cover everything, see below for a list of - `ui_slider` - converted to Dashboard 2.0's `ui-slider` - `ui_text_input` - converted to Dashboard 2.0's `ui-text-input` - `.tooltip` is not supported - +- `ui_led` - converted to Dashboard 2.0's `ui-led` + ### Config Nodes - `ui_tab` - converted to Dashboard 2.0's `ui-page` diff --git a/tests/flows/basic-layout-after.json b/tests/flows/basic-layout-after.json index 6b64e84..56bb410 100644 --- a/tests/flows/basic-layout-after.json +++ b/tests/flows/basic-layout-after.json @@ -230,6 +230,38 @@ [] ] }, + { + "id": "71985e85957f8be3", + "type": "ui-led", + "z": "78ee589ecd091670", + "name": "My Led", + "group": "f663864dda246564", + "order": 8, + "width": 0, + "height": 0, + "label": "My Led", + "labelPlacement": "left", + "labelAlignment": "left", + "states": [ + { + "value": "false", + "valueType": "bool", + "color": "#ff0000" + }, + { + "value": "true", + "valueType": "bool", + "color": "#00ff00" + } + ], + "allowColorForValueInMessage": false, + "shape": "circle", + "showBorder": true, + "showGlow": true, + "x": 990, + "y": 200, + "wires": [] + }, { "id": "856a31bba370e7fc", "type": "ui-group", diff --git a/tests/flows/basic-layout-before.json b/tests/flows/basic-layout-before.json index 5efea68..272640c 100644 --- a/tests/flows/basic-layout-before.json +++ b/tests/flows/basic-layout-before.json @@ -223,6 +223,37 @@ [] ] }, + { + "id": "ddca2be4bd1c8726", + "type": "ui_led", + "z": "78ee589ecd091670", + "order": 8, + "group": "856a31bba370e7fc", + "width": 0, + "height": 0, + "label": "My Led", + "labelPlacement": "left", + "labelAlignment": "left", + "colorForValue": [ + { + "color": "#ff0000", + "value": "false", + "valueType": "bool" + }, + { + "color": "#00ff00", + "value": "true", + "valueType": "bool" + } + ], + "allowColorForValueInMessage": false, + "shape": "circle", + "showGlow": true, + "name": "My Led", + "x": 990, + "y": 200, + "wires": [] + }, { "id": "856a31bba370e7fc", "type": "ui_group", diff --git a/tests/index.js b/tests/index.js index 5f6a8e1..17f0523 100644 --- a/tests/index.js +++ b/tests/index.js @@ -162,6 +162,19 @@ describe('Dashboard Migration Script', function () { } }) }) + describe('UI LED:', function () { + const input = utils.getByType(migratedFlow, 'ui-led')[0] + const input1 = utils.getByType(basicLayoutAfter, 'ui-led')[0] + + const excludeFromChecks = ['id', 'group'] + Object.keys(input).forEach((prop) => { + if (!excludeFromChecks.includes(prop)) { + it('should set ' + prop + ' correctly ', function () { + input[prop].should.eql(input1[prop]) + }) + } + }) + }) describe('UI Switch:', function () { const swtch = utils.getByType(migratedFlow, 'ui-switch')[0] diff --git a/transformers/index.js b/transformers/index.js index 7a54aae..39c528a 100644 --- a/transformers/index.js +++ b/transformers/index.js @@ -7,5 +7,6 @@ module.exports = { uiSlider: require('./nodes/ui-slider'), uiSwitch: require('./nodes/ui-switch'), uiText: require('./nodes/ui-text'), - uiTextInput: require('./nodes/ui-text-input') + uiTextInput: require('./nodes/ui-text-input'), + uiLed: require('./nodes/ui-led') } diff --git a/transformers/map.json b/transformers/map.json index 53eb2cb..e8b9a52 100644 --- a/transformers/map.json +++ b/transformers/map.json @@ -7,5 +7,6 @@ "ui_slider": "uiSlider", "ui_switch": "uiSwitch", "ui_text": "uiText", - "ui_text_input": "uiTextInput" + "ui_text_input": "uiTextInput", + "ui_led" : "uiLed" } diff --git a/transformers/nodes/ui-led.js b/transformers/nodes/ui-led.js new file mode 100644 index 0000000..ab4f094 --- /dev/null +++ b/transformers/nodes/ui-led.js @@ -0,0 +1,13 @@ +module.exports = function (node, baseId, themeId) { + node.type = 'ui-led' + + // update properties + node.states = node.colorForValue + + // new properties + node.showBorder = true + + // remove properties + delete node.colorForValue + return node +}