Skip to content

Commit

Permalink
thermostat autofill & text templates
Browse files Browse the repository at this point in the history
  • Loading branch information
Standarduser committed May 15, 2024
1 parent 6daac29 commit cd814ac
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 50 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ The widgets are designed for VIS 1.x.
* (Standarduser) settings-bool: corrected height of widget
* (Standarduser) thermostat: corrected translation
* (Standarduser) thermostat: corrected linebreak at tile (profile)
* (Standarduser) thermostat: parsing of profile and window states
* (Standarduser) thermostat: corrected parsing of profile and window states
* (Standarduser) thermostat: autofill object ids for Homematic devices
* (Standarduser) thermostat: text presets
* (Standarduser) thermostat: css-corrections

### 0.0.13 (2024-05-05)

Expand Down
71 changes: 39 additions & 32 deletions widgets/vis-homekittiles.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,29 @@
type - some predefined types have edit helpers, else it will be shown as text field
Type format:
id - Object ID Dialog
checkbox
image - image
number,min,max,step - non-float number. min,max,step are optional
color - color picker
views - Name of the view
effect - jquery UI show/hide effects
eff_opt - additional option to effect slide (up, down, left, right)
fontName - Font name
slider,min,max,step - Default step is ((max - min) / 100)
select,value1,value2,... - dropdown select
nselect,value1,value2,... - same as select, but without translation of items
style,fileFilter,nameFilter,attrFilter
custom,functionName,options,... - custom editor - functionName is starting from vis.binds.[widgetset.funct]. E.g. custom/timeAndWeather.editWeather,short
group.name - define new or old group. All following attributes belongs to new group till new group.xyz
group.name/byindex - like group, but all following attributes will be grouped by ID. Like group.windows/byindex;slide(1-4)/id;slide_type(1-4)/select,open,closed Following groups will be created Windows1(slide1,slide_type1), Windows2(slide2,slide_type2), Windows3(slide3,slide_type3), Windows4(slide4,slide_type4)
text - dialog box with html editor
html - dialog box with html editor
hid
checkbox
image - image
number,min,max,step - non-float number. min,max,step are optional
dimension - text input with button for px or %
color - color picker
views - Name of the view
effect - jquery UI show/hide effects
eff_opt - additional option to effect slide (up, down, left, right)
fontname - Font name
slider,min,max,step - Default step is ((max - min) / 100)
select,value1,value2,... - dropdown select
nselect,value1,value2,... - same as select, but without translation of items
auto,value1,value2,... - autocomplete
style,fileFilter,nameFilter,attrFilter
custom,functionName,options,... - custom editor - functionName is starting from vis.binds.[widgetset.funct]. E.g. custom/timeAndWeather.editWeather,short
group.name - define new or old group. All following attributes belongs to new group till new group.xyz
group.name/byindex/icon - like group, but all following attributes will be grouped by ID. Icon is optional. Like group.windows/byindex;slide(1-4)/id;slide_type(1-4)/select,open,closed Following groups will be created Windows1(slide1,slide_type1), Windows2(slide2,slide_type2), Windows3(slide3,slide_type3), Windows4(slide4,slide_type4)
text - dialog box with html editor
html - dialog box with html editor
widget - existing widget selector
history - select history instances
password - password
If type is "id", you can define filer for "Select ID Dialog", like "myID/id,level.temperature".
Additionally you can define callback(onChangeFunc), which will be called if this attribute was changed by user for different purposes: validate entry, fill other attributes, ...
Expand Down Expand Up @@ -459,7 +464,8 @@
</div>
</div>'
data-vis-attrs="description/custom,vis-homekittiles.infoText,hktThermostatDialog;
oidActualTemperature/id;
autofillOids[true]/checkbox;
oidActualTemperature/id/autofillThermostat(onChangeFunc);
oidSetPointTemperature/id;
oidHumidity/id;
oidActiveProfile/id;
Expand All @@ -475,19 +481,20 @@
data-vis-attrs0="group.label;label[Thermostat];label2pre[Set at];label2post[];"
data-vis-attrs1="group.blockOperation;blockOperationIfTrue/checkbox;blockOperationIfFalse/checkbox;blockOperationShowIcon/checkbox;blockOperationIcon/image;blockOperationIconNotInEditor/checkbox;blockOperationUseDifferentOID/checkbox;blockOperationOID/id;"
data-vis-attrs2="group.thermostatDialog;
title[Room];
closebuttonLabel[Close];
actualTemperatureLabel[Actual temperature];
setpointTemperatureLabel[Setpoint temperature];
actualHumidityLabel[Humidity];
activeProfileLabel[Temperature profile];
activeProfileValues[1§2§3§4§5§6];
activeProfileTexts[Comfort§Eco§-§-§Preheating§Away];
windowStateLabel[Window];
windowStateValues[0§1];
windowStateTexts[closed§open];
lowBatLabel[Battery low];
unreachLabel[Unreach];
texttemplate[-]/select,-,english,german/texttemplateThermostat(onChangeFunc);
title;
closebuttonLabel;
actualTemperatureLabel;
setpointTemperatureLabel;
actualHumidityLabel;
activeProfileLabel;
activeProfileValues;
activeProfileTexts;
windowStateLabel;
windowStateValues;
windowStateTexts;
lowBatLabel;
unreachLabel;
autoclose/slider,0,30000,100;
modal/checkbox;
dialog_top;
Expand Down
39 changes: 24 additions & 15 deletions widgets/vis-homekittiles/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -888,36 +888,45 @@
/*---------------------------------------------------------------*/
/* Thermostat Kachel */
.homekitTiles.tile.thermostatDialog .tileValue.cooling {
background-color: deepskyblue;
background-color: deepskyblue;
}
.homekitTiles.tile.thermostatDialog .tileValue.heating {
background-color: darkorange;
}
.homekitTiles.tile.thermostatDialog .labelGroup2 {
top: 9px;
left: 48px;
right: 1px;
position: absolute;
font-size: 10px;
top: 9px;
left: 48px;
right: 1px;
position: absolute;
font-size: 10px;
}
.homekitTiles.tile.thermostatDialog .labelGroup2 .label3value,
.homekitTiles.tile.thermostatDialog .labelGroup2 .label4value,
.homekitTiles.tile.thermostatDialog .labelGroup2 .label5value {
display: inline-block;
width: 62px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.homekitTiles.tile.thermostatDialog .labelGroup2 .label3value:before,
.homekitTiles.tile.thermostatDialog .labelGroup2 .label4value:before,
.homekitTiles.tile.thermostatDialog .labelGroup2 .label5value:before {
display: inline-block;
width: 12px;
text-align: center;
display: inline-block;
width: 12px;
text-align: center;
}
.homekitTiles.tile.thermostatDialog .labelGroup2 .label3value:before {
content: "S";
font-family: Wingdings;
content: "S";
font-family: Wingdings;
}
.homekitTiles.tile.thermostatDialog .labelGroup2 .label4value:before {
content: "";
font-family: Webdings;
content: "";
font-family: Webdings;
}
.homekitTiles.tile.thermostatDialog .labelGroup2 .label5value:before {
content: "o";
font-family: Wingdings;
content: "o";
font-family: Wingdings;
}

/* Thermostat Dialog */
Expand Down
101 changes: 99 additions & 2 deletions widgets/vis-homekittiles/js/vis-homekittiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ $.extend(
"unit": { "en": "Unit", "de": "Einheit" },
"showLikeActive": { "en": "Allways show like active", "de": "Immer als aktiv anzeigen" },
"dateformat": { "en": "Date format", "de": "Datumsformat" },
"english": { "en": "English", "de": "Englisch" },
"german": { "en": "German", "de": "Deutsch" },
"texttemplate": { "en": "Text template", "de": "Textvoreinstellung" },

"decimals": { "en": "Decimals", "de": "Nachkommastellen" },
"factor": { "en": "Multiplicator", "de": "Multiplikator" },
Expand Down Expand Up @@ -146,6 +149,7 @@ $.extend(
"comparisonLower": { "en": "<", "de": "<" },
"comparisonGreater": { "en": ">", "de": ">" },

"autofillOids": { "en": "Autofill object IDs", "de": "Objekt-IDs automatisch füllen" },
"oidActualTemperature": { "en": "Object ID for temperature", "de": "Objekt-ID für Temperatur" },
"oidSetPointTemperature": { "en": "Object ID for setpoint", "de": "Objekt-ID für Sollwert" },
"oidHumidity": { "en": "Object ID for humidity", "de": "Objekt-ID für Feuchte" },
Expand Down Expand Up @@ -213,8 +217,8 @@ $.extend(
"de": "Analogwert mit Inkrement-Tasten."
},
"hktThermostatDialogDescription": {
"en": "Thermostat dialog, specially adapted for Homematic.",
"de": "Thermostat-Dialog, speziell für Homematic angepasst."
"en": "Thermostat dialog that can be used for different thermostats, but is specifically adapted for Homematic. If an HmIP device is selected for the current temperature, the remaining data points are filled automatically.",
"de": "Thermostat-Dialog, das für verschiedene Thermostate genutzt werden kann, jedoch speziell für Homematic angepasst ist. Wird für die aktuelle Temperatur ein HmIP-Gerät ausgewählt, werden die restlichen Datenpunkte automatisch befüllt."
},
"hktSwitchBoolDescription": {
"en": "Simple switch (on/off) with icon, increment buttons and two free to define label groups.",
Expand Down Expand Up @@ -911,6 +915,99 @@ vis.binds["vis-homekittiles"] = {
$(el).parent().find('div.vis-widget-body').show();
}
},
//Thermostat dialog - autofill OIDs
autofillThermostat: function (widgetID, view, value, attr, isCss) {

var autofill = vis.views[view].widgets[widgetID].data.autofillOids;

// if (autofill && value) {
// var oidPath = value.split('.');

// //check if thermostat is from homematic and autofill if calculated object id exists
// if (oidPath[0] === 'hm-rpc' && oidPath[4] === 'ACTUAL_TEMPERATURE') {
// if (vis.views[view].widgets[widgetID].data.oidSetPointTemperature === '' || vis.views[view].widgets[widgetID].data.oidSetPointTemperature === undefined) {
// var _oid = oidPath[0] + '.' + oidPath[1] + '.' + oidPath[2] + '.1.SET_POINT_TEMPERATURE';
// if (vis.states.attr(_oid + '.val') !== undefined) vis.views[view].widgets[widgetID].data.oidSetPointTemperature = _oid;
// }
// if (vis.views[view].widgets[widgetID].data.oidHumidity === '' || vis.views[view].widgets[widgetID].data.oidHumidity === undefined) {
// var _oid = oidPath[0] + '.' + oidPath[1] + '.' + oidPath[2] + '.1.HUMIDITY';
// if (vis.states.attr(_oid + '.val') !== undefined) vis.views[view].widgets[widgetID].data.oidHumidity = _oid;
// }
// if (vis.views[view].widgets[widgetID].data.oidActiveProfile === '' || vis.views[view].widgets[widgetID].data.oidActiveProfile === undefined) {
// var _oid = oidPath[0] + '.' + oidPath[1] + '.' + oidPath[2] + '.1.ACTIVE_PROFILE';
// if (vis.states.attr(_oid + '.val') !== undefined) vis.views[view].widgets[widgetID].data.oidActiveProfile = _oid;
// }
// if (vis.views[view].widgets[widgetID].data.oidLowBat === '' || vis.views[view].widgets[widgetID].data.oidLowBat === undefined) {
// var _oid = oidPath[0] + '.' + oidPath[1] + '.' + oidPath[2] + '.0.LOW_BAT';
// if (vis.states.attr(_oid + '.val') !== undefined) vis.views[view].widgets[widgetID].data.oidLowBat = _oid;
// }
// if (vis.views[view].widgets[widgetID].data.oidUnreach === '' || vis.views[view].widgets[widgetID].data.oidUnreach === undefined) {
// var _oid = oidPath[0] + '.' + oidPath[1] + '.' + oidPath[2] + '.0.UNREACH';
// if (vis.states.attr(_oid + '.val') !== undefined) vis.views[view].widgets[widgetID].data.oidUnreach = _oid;
// }
// if (vis.views[view].widgets[widgetID].data.oidWindowState === '' || vis.views[view].widgets[widgetID].data.oidWindowState === undefined) {
// var _oid = oidPath[0] + '.' + oidPath[1] + '.' + oidPath[2] + '.1.WINDOW_STATE';
// if (vis.states.attr(_oid + '.val') !== undefined) vis.views[view].widgets[widgetID].data.oidWindowState = _oid;
// }
// }
// }

if (autofill && value) {
var oidPath = value.split('.');

//check if thermostat is from homematic and autofill if calculated object id exists
if (oidPath[0] === 'hm-rpc' && oidPath[4] === 'ACTUAL_TEMPERATURE') {
if (vis.states.attr(oidPath[0] + '.' + oidPath[1] + '.' + oidPath[2] + '.1.SET_POINT_TEMPERATURE.val') !== undefined) vis.views[view].widgets[widgetID].data.oidSetPointTemperature = oidPath[0] + '.' + oidPath[1] + '.' + oidPath[2] + '.1.SET_POINT_TEMPERATURE';
if (vis.states.attr(oidPath[0] + '.' + oidPath[1] + '.' + oidPath[2] + '.1.HUMIDITY.val') !== undefined) vis.views[view].widgets[widgetID].data.oidHumidity = oidPath[0] + '.' + oidPath[1] + '.' + oidPath[2] + '.1.HUMIDITY';
if (vis.states.attr(oidPath[0] + '.' + oidPath[1] + '.' + oidPath[2] + '.1.ACTIVE_PROFILE.val') !== undefined) vis.views[view].widgets[widgetID].data.oidActiveProfile = oidPath[0] + '.' + oidPath[1] + '.' + oidPath[2] + '.1.ACTIVE_PROFILE';
if (vis.states.attr(oidPath[0] + '.' + oidPath[1] + '.' + oidPath[2] + '.0.LOW_BAT.val') !== undefined) vis.views[view].widgets[widgetID].data.oidLowBat = oidPath[0] + '.' + oidPath[1] + '.' + oidPath[2] + '.0.LOW_BAT';
if (vis.states.attr(oidPath[0] + '.' + oidPath[1] + '.' + oidPath[2] + '.0.UNREACH.val') !== undefined) vis.views[view].widgets[widgetID].data.oidUnreach = oidPath[0] + '.' + oidPath[1] + '.' + oidPath[2] + '.0.UNREACH';
if (vis.states.attr(oidPath[0] + '.' + oidPath[1] + '.' + oidPath[2] + '.1.WINDOW_STATE.val') !== undefined) vis.views[view].widgets[widgetID].data.oidWindowState = oidPath[0] + '.' + oidPath[1] + '.' + oidPath[2] + '.1.WINDOW_STATE';
}

//reset autofill
vis.views[view].widgets[widgetID].data.autofillOids = false;
}
},
//Thermostat dialog - text presets
texttemplateThermostat: function (widgetID, view, value, attr, isCss) {

var texttemplate = vis.views[view].widgets[widgetID].data.texttemplate;

switch (texttemplate) {
case 'english':
vis.views[view].widgets[widgetID].data.title = 'Room';
vis.views[view].widgets[widgetID].data.closebuttonLabel = 'Close';
vis.views[view].widgets[widgetID].data.actualTemperatureLabel = 'Actual temperature';
vis.views[view].widgets[widgetID].data.setpointTemperatureLabel = 'Setpoint temperature';
vis.views[view].widgets[widgetID].data.actualHumidityLabel = 'Humidity';
vis.views[view].widgets[widgetID].data.activeProfileLabel = 'Temperature profile';
vis.views[view].widgets[widgetID].data.activeProfileValues = '1;2;3;4;5;6';
vis.views[view].widgets[widgetID].data.activeProfileTexts = 'Comfort;Eco;-;-;Preheating;Away';
vis.views[view].widgets[widgetID].data.windowStateLabel = 'Window';
vis.views[view].widgets[widgetID].data.windowStateValues = '0;1';
vis.views[view].widgets[widgetID].data.windowStateTexts = 'closed;open';
vis.views[view].widgets[widgetID].data.lowBatLabel = 'Battery low';
vis.views[view].widgets[widgetID].data.unreachLabel = 'Unreach';
break;
case 'german':
vis.views[view].widgets[widgetID].data.title = 'Raum';
vis.views[view].widgets[widgetID].data.closebuttonLabel = 'Schließen';
vis.views[view].widgets[widgetID].data.actualTemperatureLabel = 'Aktuelle Temperatur';
vis.views[view].widgets[widgetID].data.setpointTemperatureLabel = 'Sollwert';
vis.views[view].widgets[widgetID].data.actualHumidityLabel = 'Feuchte';
vis.views[view].widgets[widgetID].data.activeProfileLabel = 'Temperaturprofil';
vis.views[view].widgets[widgetID].data.activeProfileValues = '1;2;3;4;5;6';
vis.views[view].widgets[widgetID].data.activeProfileTexts = 'Komfort;Eco;-;-;Vorheizen;Abwesend';
vis.views[view].widgets[widgetID].data.windowStateLabel = 'Fenster';
vis.views[view].widgets[widgetID].data.windowStateValues = '0;1';
vis.views[view].widgets[widgetID].data.windowStateTexts = 'zu;auf';
vis.views[view].widgets[widgetID].data.lowBatLabel = 'Batterie schwach';
vis.views[view].widgets[widgetID].data.unreachLabel = 'Nicht erreichbar';
}
//reset autofill
vis.views[view].widgets[widgetID].data.texttemplate = '-';
},

//Add elements to widgets
addButtonIcon: function (el, data) {
Expand Down

0 comments on commit cd814ac

Please sign in to comment.