Skip to content

Commit

Permalink
Add Conversion to ui_led node.
Browse files Browse the repository at this point in the history
  • Loading branch information
kd9lsv committed Dec 28, 2024
1 parent 316fc33 commit ec2a03d
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
32 changes: 32 additions & 0 deletions tests/flows/basic-layout-after.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
31 changes: 31 additions & 0 deletions tests/flows/basic-layout-before.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 13 additions & 0 deletions tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
3 changes: 2 additions & 1 deletion transformers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
3 changes: 2 additions & 1 deletion transformers/map.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"ui_slider": "uiSlider",
"ui_switch": "uiSwitch",
"ui_text": "uiText",
"ui_text_input": "uiTextInput"
"ui_text_input": "uiTextInput",
"ui_led" : "uiLed"
}
13 changes: 13 additions & 0 deletions transformers/nodes/ui-led.js
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit ec2a03d

Please sign in to comment.