Template UI for Philips HUE

Hi,
I am trying to create my own template node to ease my setup and to just create one dashboard node for setting brightness, color, on/off,... I'm slowly getting into the html stuff, but I'm still no wiz.

I managed to get my slider stuff and switch and so on working, but my problem is that my color picker either can set the color in the hue lamp or receive the color from the hue lamp. The problem seems to be the hex value. When coming from the hue lamp, I have to add a '#' to the value. When this is done, setting the color via dashboard does not work anymore.

My template node looks as follows:

<div class="roomFrame">
    <div class="lightTable">
        <div class="lightTableRow">
            <div class="d1">Name</div>
            <div class="d2"><input type="color" ng-model="msg.payload.hex" ng-change="send(msg)"></div>
            <div class="d3"><md-switch aria-label="tank" class="md-switch" value="{{msg.payload.on}}" ng-model="aktiv" ng-change="send({payload : {on:aktiv}})" ng-checked="msg.payload.on"></md-switch></div>
        </div>
    </div>
    <div class="lightTable">
        <div class="lightTableRow">
            <div class="d4">Heligkeit</div>
            <div class="d5"><md-slider min="0" max="100" ng-model="helligkeit" value="{{msg.payload.brightness}}" ng-change="send({payload : {brightness:helligkeit}})" class="lightSlider"></md-slider></div>
            <div class="d6">{{msg.payload.brightness}}</div>
        </div>
        <div class="lightTableRow">
            <div class="d4">Farbe</div>
            <div class="d5"><md-slider min="153" max="500" ng-model="farbtemp" value="{{msg.payload.colorTemp}}" ng-change="send({payload : {colorTemp:farbtemp}})" class="lightSlider"></md-slider></div>
            <div class="d6">{{msg.payload.colorTemp}}</div>
        </div>
    </div>
</div>

I have also got a node containing the style:

<style>
    .lightSlider {
        float:right;
        width: 100%   
    }
    .lightSlider .md-thumb:after, .lightSlider .md-track{
        background-color: #FA9900 !important;
        border-color: #FA9900 !important;
    }
    .lightSlider .md-focus-thumb, .lightSlider .md-focus-ring{
        background-color: #FA9900;
    }
    .lightTable {
        display:table;
        width:95%;
        margin-left: 5px;
        margin-right: 5px;
    }
    .lightTableRow {
        display:table-row;
    }
    .d1 {
        display:table-cell;
        width:60%;
    }
    .d2 {
        display:table-cell;
        text-align:center;
        width:20%;
    }
    .d3 {
        display:table-cell;
        text-align:right;
        width:20%;
    }
    .d4 {
        display:table-cell;
        width:30%;
        vertical-align:middle;
    }
    .d5 {
        display:table-cell;
        width:60%;
    }
    .d6 {
        display:table-cell;
        text-align:right;
        width:10%;
        vertical-align:middle;
    }
    .roomFrame {
        border:1px solid grey;
    }
</style>

I used the slider from some post in the forum. I'm sure there is room for improvement. But my main question is how to get input and output for the color picker working for the hue lamps. With the normal dashboard color picker it works as this can be setup to use hex values.

Any help would be great! Thanks

I installed your HTML and CSS in a template node, so I can see what your dashboard looks like but it doesn't do anything.

Please share your complete flow so that we can see the inputs to the template and how you handle the output.
Also show us examples of the data "coming from the hue lamp" and data which works to set the lamp colour.

My reply was swallowed unfortunately.
In the meantime, I solved the greatest issue, the problem was that the original message from the HUE was sent through the node and the template set the hex only. The message also contains Rob information, so the color was overwritten by the message itself.
I still have one issue, that the template color picker can only be set when a '#' ist added in front of the hex value. Do you have any solution for this issue?

Another nice to have is the following:
I'd like to make the Farbe Slider grey, when the colorTemp payload contains false. didn't manage to change the class depending on the value.

Here's the flow - in case someone is interested:

[
    {
        "id": "290b7a6f911b1f62",
        "type": "ui_template",
        "z": "486dea2824d2bb02",
        "group": "e5f7d98cd417c6e8",
        "name": "Sliderstyle",
        "order": 2,
        "width": 0,
        "height": 0,
        "format": "<style>\n    .lightSlider {\n        float:right;\n        width: 100%   \n    }\n    .lightSlider .md-thumb:after, .lightSlider .md-track{\n        background-color: #097479 !important;\n        border-color: #097479 !important;\n    }\n    .lightSlider .md-focus-thumb, .lightSlider .md-focus-ring{\n        background-color: #0b8b91;\n    }\n    \n    .lightTable {\n        display:table;\n        width:95%;\n        margin-left: 5px;\n        margin-right: 5px;\n    }\n    .lightTableRow {\n        display:table-row;\n    }\n    .d1 {\n        display:table-cell;\n        width:75%;\n        vertical-align:middle;\n    }\n    .d2 {\n        display:table-cell;\n        text-align:center;\n        width:20%;\n    }\n    .d3 {\n        display:table-cell;\n        text-align:right;\n        width:5%;\n    }\n    .d4 {\n        display:table-cell;\n        width:30%;\n        vertical-align:middle;\n    }\n    .d5 {\n        display:table-cell;\n        width:60%;\n    }\n    .d6 {\n        display:table-cell;\n        text-align:right;\n        width:10%;\n        vertical-align:middle;\n    }\n    .roomFrame {\n        border:1px solid grey;\n    }\n</style>",
        "storeOutMessages": true,
        "fwdInMessages": true,
        "resendOnRefresh": true,
        "templateScope": "local",
        "className": "sliderstyle",
        "x": 410,
        "y": 100,
        "wires": [
            []
        ]
    },
    {
        "id": "d146875305ac6621",
        "type": "hue-light",
        "z": "486dea2824d2bb02",
        "name": "Dusche indirekt",
        "bridge": "fdd57983b73f8605",
        "lightid": "10d664ae-bfdb-42e4-8459-394712a8c0b4",
        "colornamer": true,
        "skipevents": false,
        "initevents": false,
        "x": 120,
        "y": 200,
        "wires": [
            [
                "9b7081fb638c0d14",
                "9b7081fb638c0d14"
            ]
        ]
    },
    {
        "id": "09e4ab5db7cc5098",
        "type": "hue-light",
        "z": "486dea2824d2bb02",
        "name": "Dusche indirekt",
        "bridge": "fdd57983b73f8605",
        "lightid": "10d664ae-bfdb-42e4-8459-394712a8c0b4",
        "colornamer": true,
        "skipevents": false,
        "initevents": false,
        "x": 840,
        "y": 200,
        "wires": [
            []
        ]
    },
    {
        "id": "9b7081fb638c0d14",
        "type": "function",
        "z": "486dea2824d2bb02",
        "name": "Add#",
        "func": "msg.payload.hex = \"#\" + msg.payload.hex;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 310,
        "y": 200,
        "wires": [
            [
                "e6bffd9285b440fc"
            ]
        ]
    },
    {
        "id": "e6bffd9285b440fc",
        "type": "ui_template",
        "z": "486dea2824d2bb02",
        "group": "e5f7d98cd417c6e8",
        "name": "Test",
        "order": 1,
        "width": 6,
        "height": "5",
        "format": "<div class=\"roomFrame\">\n    <div class=\"lightTable\">\n        <div class=\"lightTableRow\">\n            <div class=\"d1\">Name</div>\n            <div class=\"d2\">\n                <input type=\"color\" ng-model=\"msg.payload.hex\" ng-change=\"send({payload : {hex: msg.payload.hex}})\">\n            </div>\n            <div class=\"d3\"><md-switch aria-label=\"tank\" class=\"md-switch\" ng-model=\"aktiv\" ng-change=\"send({payload : {on:aktiv}})\" ng-checked=\"msg.payload.on\"></md-switch></div>\n        </div>\n    </div>\n    <div class=\"lightTable\">\n        <div class=\"lightTableRow\">\n            <div class=\"d4\">Heligkeit</div>\n            <div class=\"d5\">\n                <md-slider min=\"0\" max=\"100\" step=\"1\" ng-model=\"msg.payload.brightness\" \n                    value=\"{{msg.payload.brightness}}\" ng-change=\"send({payload : { brightness: msg.payload.brightness}})\" \n                    class=\"lightSlider\">\n                </md-slider>\n            </div>\n            <div class=\"d6\">{{msg.payload.brightness}}</div>\n        </div>\n        <div class=\"lightTableRow\">\n            <div class=\"d4\">Farbe</div>\n            <div class=\"d5\">\n                <md-slider min=\"153\" max=\"500\" ng-model=\"msg.payload.colorTemp\" \n                    ng-change=\"send({payload : {colorTemp:msg.payload.colorTemp}})\" \n                    class=\"lightSlider\">\n                </md-slider>\n            </div>\n            <div class=\"d6\">{{msg.payload.colorTemp}}</div>\n        </div>\n    </div>\n</div>",
        "storeOutMessages": false,
        "fwdInMessages": false,
        "resendOnRefresh": true,
        "templateScope": "local",
        "className": "",
        "x": 470,
        "y": 200,
        "wires": [
            [
                "09e4ab5db7cc5098"
            ]
        ]
    },
    {
        "id": "e5f7d98cd417c6e8",
        "type": "ui_group",
        "name": "test2",
        "tab": "c8014419458cb66d",
        "order": 2,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "fdd57983b73f8605",
        "type": "hue-bridge",
        "name": "Tautendorf EG",
        "bridge": "192.168.110.30",
        "key": "ZET7k2XRFUDtHpvNOXm8DiqeVSZgCrJpwGAj9QNY",
        "worker": "4",
        "autoupdates": true,
        "disableupdates": false
    },
    {
        "id": "c8014419458cb66d",
        "type": "ui_tab",
        "name": "Test",
        "icon": "info",
        "disabled": false,
        "hidden": false
    }
]

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.