Skip to content

Commit

Permalink
thermostat setpoint mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Standarduser committed May 15, 2024
1 parent a1d767b commit ebaa61f
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 40 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ The widgets are designed for VIS 1.x.
* (Standarduser) thermostat: text presets
* (Standarduser) thermostat: css-corrections
* (Standarduser) thermostat: select for heating profile
* (Standarduser) thermostat: added setpoint mode

### 0.0.13 (2024-05-05)

Expand Down
36 changes: 35 additions & 1 deletion widgets/vis-homekittiles.html
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@
autofillOids[true]/checkbox;
oidActualTemperature/id/autofillThermostat(onChangeFunc);
oidSetPointTemperature/id;
oidSetPointMode/id;
oidHumidity/id;
oidActiveProfile/id;
oidLowBat/id;
Expand All @@ -486,6 +487,10 @@
closebuttonLabel;
actualTemperatureLabel;
setpointTemperatureLabel;
setpointModeLabel;
setpointModeValues;
setpointModeTexts;
setpointModeOperable/checkbox;
actualHumidityLabel;
activeProfileLabel;
activeProfileValues;
Expand Down Expand Up @@ -529,7 +534,14 @@
var windowStateValue = (data.attr('windowStateValues') ? data.attr('windowStateValues').split(';') : []);
var windowStateText = (data.attr('windowStateTexts') ? data.attr('windowStateTexts').split(';') : []);
if (windowStateValue.includes(windowState)) windowState = windowStateText[windowStateValue.indexOf(windowState)]; %>
<span class="label5value"><%= windowState %></span>
<span class="label5value"><%= windowState %></span><br>
<% } %>
<% if (this.data.attr('oidSetPointMode')) {
var setpointMode = vis.states.attr(this.data['oidSetPointMode'] + '.val').toString();
var setpointModeValue = (data.attr('setpointModeValues') ? data.attr('setpointModeValues').split(';') : []);
var setpointModeText = (data.attr('setpointModeTexts') ? data.attr('setpointModeTexts').split(';') : []);
if (setpointModeValue.includes(setpointMode)) setpointMode = setpointModeText[setpointModeValue.indexOf(setpointMode)]; %>
<span class="label6value"><%= setpointMode %></span>
<% } %>
</div>
</div>
Expand All @@ -543,6 +555,28 @@
<div class="thermostat content">
<div class="values">
<% if (this.data.attr('oidSetPointTemperature')) { %><div class="setpointTemperature"><span class="title"><%= this.data.attr('setpointTemperatureLabel') %></span><span class="value"><%= vis.states.attr(this.data['oidSetPointTemperature'] + '.val') %><%= this.data.attr('unitTemperature') %></span></div><% } %>
<% if (this.data.attr('oidSetPointMode')) {
var setpointMode = vis.states.attr(this.data['oidSetPointMode'] + '.val').toString();
var setpointModeValue = (data.attr('setpointModeValues') ? data.attr('setpointModeValues').split(';') : []);
var setpointModeText = (data.attr('setpointModeTexts') ? data.attr('setpointModeTexts').split(';') : []);
if (setpointModeValue.includes(setpointMode)) setpointMode = setpointModeText[setpointModeValue.indexOf(setpointMode)]; %>
<div class="setpointMode <%= setpointMode %>"><span class="title"><%= this.data.attr('setpointModeLabel') %></span>
<% if (this.data.attr('setpointModeOperable')) { %>
<div class="selectMode">
<select id="<%= this.data.attr('wid') %>_select" data-oid="<%= this.data.attr('oidSetPointMode') %>" data-view="<%= this.view %>" <%= (el) -> setTimeout(function () { vis.binds['vis-homekittiles'].multiselect(el)}, 250) %> >
<%
var values = (data.attr('setpointModeValues') ? data.attr('setpointModeValues').split(';') : []);
var texts = (data.attr('setpointModeTexts') ? data.attr('setpointModeTexts').split(';') : []);
for (var val in values) { %>
<option value="<%= values[val] %>"><%= texts[val] %></option>
<% } %>
</select >
</div>
<% } else { %>
<span class="value"><%= setpointMode %></span></div>
<% } %>
</div>
<% } %>
<% if (this.data.attr('oidHumidity')) { %><div class="actualHumidity"><span class="title"><%= this.data.attr('actualHumidityLabel') %></span><span class="value"><%= vis.states.attr(this.data['oidHumidity'] + '.val') %><%= this.data.attr('unitHumidity') %></span></div><% } %>
<% if (this.data.attr('oidActiveProfile')) {
var activeProfile = vis.states.attr(this.data['oidActiveProfile'] + '.val').toString();
Expand Down
13 changes: 11 additions & 2 deletions widgets/vis-homekittiles/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,8 @@
}
.homekitTiles.tile.thermostatDialog .labelGroup2 .label3value,
.homekitTiles.tile.thermostatDialog .labelGroup2 .label4value,
.homekitTiles.tile.thermostatDialog .labelGroup2 .label5value {
.homekitTiles.tile.thermostatDialog .labelGroup2 .label5value,
.homekitTiles.tile.thermostatDialog .labelGroup2 .label6value {
display: inline-block;
width: 62px;
white-space: nowrap;
Expand All @@ -911,7 +912,8 @@
}
.homekitTiles.tile.thermostatDialog .labelGroup2 .label3value:before,
.homekitTiles.tile.thermostatDialog .labelGroup2 .label4value:before,
.homekitTiles.tile.thermostatDialog .labelGroup2 .label5value:before {
.homekitTiles.tile.thermostatDialog .labelGroup2 .label5value:before,
.homekitTiles.tile.thermostatDialog .labelGroup2 .label6value:before {
display: inline-block;
width: 12px;
text-align: center;
Expand All @@ -928,6 +930,10 @@
content: "o";
font-family: Wingdings;
}
.homekitTiles.tile.thermostatDialog .labelGroup2 .label6value:before {
content: "R";
font-family: Wingdings;
}

/* Thermostat Dialog */
.homekitTiles.dialog .content {
Expand Down Expand Up @@ -980,6 +986,7 @@
color: white;
font-size: 16px;
}
.homekitTiles.dialog .thermostat.content .values .selectMode,
.homekitTiles.dialog .thermostat.content .values .selectProfile {
width: 88px;
font-size: 1.25rem;
Expand All @@ -988,6 +995,7 @@
grid-template-areas: "select";
align-items: center;
}
.homekitTiles.dialog .thermostat.content .values .selectMode::after,
.homekitTiles.dialog .thermostat.content .values .selectProfile::after {
content: "";
width: 0.5em;
Expand All @@ -998,6 +1006,7 @@
grid-area: select;
margin-left: 10px;
}
.homekitTiles.dialog .thermostat.content .values .selectMode select,
.homekitTiles.dialog .thermostat.content .values .selectProfile select {
appearance: none;
background-color: transparent;
Expand Down
54 changes: 17 additions & 37 deletions widgets/vis-homekittiles/js/vis-homekittiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ $.extend(

"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" },
"oidSetPointTemperature": { "en": "Object ID for setpoint temp", "de": "Objekt-ID für Sollwert Temp." },
"oidSetPointMode": { "en": "Object ID for setpoint mode", "de": "Objekt-ID für Sollwert Modus" },
"oidHumidity": { "en": "Object ID for humidity", "de": "Objekt-ID für Feuchte" },
"oidActiveProfile": { "en": "Object ID for heating profile", "de": "Objekt-ID für Heizprofil" },
"oidLowBat": { "en": "Object ID for low battery", "de": "Objekt-ID für Batterie schwach" },
Expand All @@ -164,12 +165,16 @@ $.extend(
"temperatureStep": { "en": "Temperature steps", "de": "Schrittweite Temperatur" },
"group_thermostatDialog": { "en": "Thermostat dialog", "de": "Thermostat-Dialog" },
"closebuttonLabel": { "en": "Label close-button", "de": "Beschriftung Schließen-Button" },
"actualTemperatureLabel": { "en": "Label temperature", "de": "Beschriftung Temperatur" },
"setpointTemperatureLabel": { "en": "Label setpoint", "de": "Beschriftung Sollwert" },
"actualTemperatureLabel": { "en": "Label actual temperature", "de": "Beschriftung aktuelle Temperatur" },
"setpointTemperatureLabel": { "en": "Label setpoint temperature", "de": "Beschriftung Sollwert Temperatur" },
"setpointModeLabel": { "en": "Label setpoint mode", "de": "Beschriftung Sollwert Modus" },
"setpointModeValues": { "en": "Values setpoint mode", "de": "Werte Sollwert Modus" },
"setpointModeTexts": { "en": "Names setpoint mode", "de": "Namen Sollwert Modus" },
"setpointModeOperable": { "en": "Setpoint mode operable", "de": "Sollwert Modus bedienbar" },
"actualHumidityLabel": { "en": "Label humidity", "de": "Beschriftung Feuchte" },
"activeProfileLabel": { "en": "Label heating profile", "de": "Beschriftung Heizprofil" },
"activeProfileValues": { "en": "Values of heating profile", "de": "Werte des Heizprofils" },
"activeProfileTexts": { "en": "Names of heating profile", "de": "Namen des Heizprofiles" },
"activeProfileTexts": { "en": "Names of heating profile", "de": "Namen des Heizprofils" },
"windowStateLabel": { "en": "Label window contact", "de": "Beschriftung Fensterkontakt" },
"windowStateValues": { "en": "Values of window contact", "de": "Werte des Fensterkontakts" },
"windowStateTexts": { "en": "Value names of window contact", "de": "Textwerte des Fensterkontakts" },
Expand Down Expand Up @@ -920,44 +925,13 @@ vis.binds["vis-homekittiles"] = {

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.SET_POINT_MODE.val') !== undefined) vis.views[view].widgets[widgetID].data.oidSetPointMode = oidPath[0] + '.' + oidPath[1] + '.' + oidPath[2] + '.1.SET_POINT_MODE';
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';
Expand All @@ -980,6 +954,9 @@ vis.binds["vis-homekittiles"] = {
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.setpointModeLabel = 'Setpoint mode';
vis.views[view].widgets[widgetID].data.setpointModeValues = '0;1;2';
vis.views[view].widgets[widgetID].data.setpointModeTexts = 'Auto;Manual;Holiday';
vis.views[view].widgets[widgetID].data.actualHumidityLabel = 'Humidity';
vis.views[view].widgets[widgetID].data.activeProfileLabel = 'Heating profile';
vis.views[view].widgets[widgetID].data.activeProfileValues = '1;2;3;4;5;6';
Expand All @@ -994,7 +971,10 @@ vis.binds["vis-homekittiles"] = {
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.setpointTemperatureLabel = 'Sollwert Temperatur';
vis.views[view].widgets[widgetID].data.setpointModeLabel = 'Sollwert Modus';
vis.views[view].widgets[widgetID].data.setpointModeValues = '0;1;2';
vis.views[view].widgets[widgetID].data.setpointModeTexts = 'Auto;Manuell;Urlaub';
vis.views[view].widgets[widgetID].data.actualHumidityLabel = 'Feuchte';
vis.views[view].widgets[widgetID].data.activeProfileLabel = 'Heizprofil';
vis.views[view].widgets[widgetID].data.activeProfileValues = '1;2;3;4;5;6';
Expand Down

0 comments on commit ebaa61f

Please sign in to comment.