Skip to content

Commit

Permalink
1.6.3
Browse files Browse the repository at this point in the history
Added decimals parameter for manually  added entities.
  • Loading branch information
RonnyWinkler committed Jul 22, 2024
1 parent 1069681 commit fe92e88
Show file tree
Hide file tree
Showing 29 changed files with 1,079 additions and 71 deletions.
4 changes: 4 additions & 0 deletions .homeychangelog.json
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,10 @@
"1.6.2": {
"en": "Small technical fixes.",
"de": "Kleine technische Korrekturen."
},
"1.6.3": {
"en": "Added decimals parameter for manually added entities.",
"de": "Dezimalstellen-Parameter für manuell hinzugefügte Entitäten ergänzt."
}

}
2 changes: 1 addition & 1 deletion .homeycompose/app.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "io.home-assistant.community",
"version": "1.6.2",
"version": "1.6.3",
"compatibility": ">=8.1.0",
"sdk": 3,
"brandColor": "#0DA6EA",
Expand Down
51 changes: 48 additions & 3 deletions .homeycompose/drivers/repair/add_entity/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
capability: document.getElementById('capabilityAdd').value,
name: document.getElementById('nameAdd').value,
unit: document.getElementById('unitAdd').value,
decimals: document.getElementById('decimalsAdd').value,
converter_ha2homey: document.getElementById('converter_ha2homeyAdd').value,
converter_homey2ha: document.getElementById('converter_homey2haAdd').value,
add_as_main_capability: document.getElementById('addAsMainCapabilityAdd').checked,
Expand Down Expand Up @@ -137,7 +138,18 @@
}
);
}

function onInfoDecimals(){
let message = new InfoMessage();
message.info(
Homey.__("repair.custom_device.info_decimals"),
{
duration: 0,
closable: true,
dangerUseHtml: true
}
);
}

function onAddEntityAttributeClick(){
if (document.getElementById("addEntityAttributeAdd").checked){
document.getElementById("labelEntityAttributeAdd").style.display = 'unset';
Expand Down Expand Up @@ -174,6 +186,27 @@
}
}

function onCapabilityChanged(){
decimalsVisibility();
}

function decimalsVisibility(){
document.getElementById('decimalsAdd').value = '';
let capability = document.getElementById('capabilityAdd').value;
if (
(capability.startsWith('measure') || capability.startsWith('meter'))
&&
!capability.startsWith('measure_generic')){
document.getElementById("divNumberDecimal").style.display = 'unset';
}
else{
document.getElementById("divNumberDecimal").style.display = 'none';
}
}

// update decimal value field
decimalsVisibility();

// update visible/invisible fields
onAddEntityAttributeClick();
</script>
Expand Down Expand Up @@ -216,7 +249,7 @@
<div class="info_icon" onClick="onInfoCapability()">
<span class="fa fa-icon fa-info-circle"></span>
</div>
<input id="capabilityAdd" class="homey-form-input" type="text" value=""/>
<input id="capabilityAdd" class="homey-form-input" type="text" value="" onchange="onCapabilityChanged()" oninput="onCapabilityChanged()"/>
<!-- </div>
<div class="homey-form-group"> -->
<fieldset class="homey-form-checkbox-set">
Expand All @@ -233,6 +266,17 @@
</div>
</div>

<!-- Number Decimal options -->
<div class="homey-form-group" id="divNumberDecimal" style="display:none">
<fieldset class="homey-form-checkbox-set">
<label for="decimalsAdd" class="homey-form-label" style="display: inline;"><span data-i18n="repair.custom_device.decimals"></span></label>
<div class="info_icon" onClick="onInfoDecimals()">
<span class="fa fa-icon fa-info-circle"></span>
</div>
<input id="decimalsAdd" class="homey-form-input" type="number" value=""/>
</fieldset>
</div>

<!-- Number Input options -->
<div class="homey-form-group" id="divNumberInput" style="display:none">
<fieldset class="homey-form-checkbox-set">
Expand All @@ -258,7 +302,7 @@
<input id="entityNumberRangeMaxAdd" class="homey-form-input" type="text" value=""/>
</td>
<td>
<label for="entityNumberRangeStepnAdd" class="homey-form-label"><span data-i18n="repair.custom_device.number_range_step"></span></label>
<label for="entityNumberRangeStepAdd" class="homey-form-label"><span data-i18n="repair.custom_device.number_range_step"></span></label>
<input id="entityNumberRangeStepAdd" class="homey-form-input" type="text" value=""/>
</td>
</tr>
Expand Down Expand Up @@ -364,6 +408,7 @@
document.getElementById('nameAdd').value = event.detail.selection.value.name;
document.getElementById('unitAdd').value = event.detail.selection.value.unit;
document.getElementById('capabilityAdd').value = await Homey.emit("getCustomTemplateCapability", event.detail.selection.value.entity_id)
decimalsVisibility();
if (event.detail.selection.value.number_range != undefined){
document.getElementById('addEntityNumberInput').checked = false;
if (event.detail.selection.value.number_range.min != undefined){
Expand Down
2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"_comment": "This file is generated. Please edit .homeycompose/app.json instead.",
"id": "io.home-assistant.community",
"version": "1.6.2",
"version": "1.6.3",
"compatibility": ">=8.1.0",
"sdk": 3,
"brandColor": "#0DA6EA",
Expand Down
51 changes: 48 additions & 3 deletions drivers/alarm_control_panel/repair/add_entity.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
capability: document.getElementById('capabilityAdd').value,
name: document.getElementById('nameAdd').value,
unit: document.getElementById('unitAdd').value,
decimals: document.getElementById('decimalsAdd').value,
converter_ha2homey: document.getElementById('converter_ha2homeyAdd').value,
converter_homey2ha: document.getElementById('converter_homey2haAdd').value,
add_as_main_capability: document.getElementById('addAsMainCapabilityAdd').checked,
Expand Down Expand Up @@ -137,7 +138,18 @@
}
);
}

function onInfoDecimals(){
let message = new InfoMessage();
message.info(
Homey.__("repair.custom_device.info_decimals"),
{
duration: 0,
closable: true,
dangerUseHtml: true
}
);
}

function onAddEntityAttributeClick(){
if (document.getElementById("addEntityAttributeAdd").checked){
document.getElementById("labelEntityAttributeAdd").style.display = 'unset';
Expand Down Expand Up @@ -174,6 +186,27 @@
}
}

function onCapabilityChanged(){
decimalsVisibility();
}

function decimalsVisibility(){
document.getElementById('decimalsAdd').value = '';
let capability = document.getElementById('capabilityAdd').value;
if (
(capability.startsWith('measure') || capability.startsWith('meter'))
&&
!capability.startsWith('measure_generic')){
document.getElementById("divNumberDecimal").style.display = 'unset';
}
else{
document.getElementById("divNumberDecimal").style.display = 'none';
}
}

// update decimal value field
decimalsVisibility();

// update visible/invisible fields
onAddEntityAttributeClick();
</script>
Expand Down Expand Up @@ -216,7 +249,7 @@
<div class="info_icon" onClick="onInfoCapability()">
<span class="fa fa-icon fa-info-circle"></span>
</div>
<input id="capabilityAdd" class="homey-form-input" type="text" value=""/>
<input id="capabilityAdd" class="homey-form-input" type="text" value="" onchange="onCapabilityChanged()" oninput="onCapabilityChanged()"/>
<!-- </div>
<div class="homey-form-group"> -->
<fieldset class="homey-form-checkbox-set">
Expand All @@ -233,6 +266,17 @@
</div>
</div>

<!-- Number Decimal options -->
<div class="homey-form-group" id="divNumberDecimal" style="display:none">
<fieldset class="homey-form-checkbox-set">
<label for="decimalsAdd" class="homey-form-label" style="display: inline;"><span data-i18n="repair.custom_device.decimals"></span></label>
<div class="info_icon" onClick="onInfoDecimals()">
<span class="fa fa-icon fa-info-circle"></span>
</div>
<input id="decimalsAdd" class="homey-form-input" type="number" value=""/>
</fieldset>
</div>

<!-- Number Input options -->
<div class="homey-form-group" id="divNumberInput" style="display:none">
<fieldset class="homey-form-checkbox-set">
Expand All @@ -258,7 +302,7 @@
<input id="entityNumberRangeMaxAdd" class="homey-form-input" type="text" value=""/>
</td>
<td>
<label for="entityNumberRangeStepnAdd" class="homey-form-label"><span data-i18n="repair.custom_device.number_range_step"></span></label>
<label for="entityNumberRangeStepAdd" class="homey-form-label"><span data-i18n="repair.custom_device.number_range_step"></span></label>
<input id="entityNumberRangeStepAdd" class="homey-form-input" type="text" value=""/>
</td>
</tr>
Expand Down Expand Up @@ -364,6 +408,7 @@
document.getElementById('nameAdd').value = event.detail.selection.value.name;
document.getElementById('unitAdd').value = event.detail.selection.value.unit;
document.getElementById('capabilityAdd').value = await Homey.emit("getCustomTemplateCapability", event.detail.selection.value.entity_id)
decimalsVisibility();
if (event.detail.selection.value.number_range != undefined){
document.getElementById('addEntityNumberInput').checked = false;
if (event.detail.selection.value.number_range.min != undefined){
Expand Down
8 changes: 8 additions & 0 deletions drivers/basedriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,14 @@ class BaseDriver extends Homey.Driver {
capability = 'onoff';
}
}

// Add decimals for number capability
if (data.decimals != undefined){
if ( parseInt(data.decimals).par != NaN){
capabilitiesOptions["decimals"] = parseInt(data.decimals);
}
}

if (!device.hasCapability(capability)){
this.log("Adding capability: "+capability);
try{
Expand Down
51 changes: 48 additions & 3 deletions drivers/button/repair/add_entity.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
capability: document.getElementById('capabilityAdd').value,
name: document.getElementById('nameAdd').value,
unit: document.getElementById('unitAdd').value,
decimals: document.getElementById('decimalsAdd').value,
converter_ha2homey: document.getElementById('converter_ha2homeyAdd').value,
converter_homey2ha: document.getElementById('converter_homey2haAdd').value,
add_as_main_capability: document.getElementById('addAsMainCapabilityAdd').checked,
Expand Down Expand Up @@ -137,7 +138,18 @@
}
);
}

function onInfoDecimals(){
let message = new InfoMessage();
message.info(
Homey.__("repair.custom_device.info_decimals"),
{
duration: 0,
closable: true,
dangerUseHtml: true
}
);
}

function onAddEntityAttributeClick(){
if (document.getElementById("addEntityAttributeAdd").checked){
document.getElementById("labelEntityAttributeAdd").style.display = 'unset';
Expand Down Expand Up @@ -174,6 +186,27 @@
}
}

function onCapabilityChanged(){
decimalsVisibility();
}

function decimalsVisibility(){
document.getElementById('decimalsAdd').value = '';
let capability = document.getElementById('capabilityAdd').value;
if (
(capability.startsWith('measure') || capability.startsWith('meter'))
&&
!capability.startsWith('measure_generic')){
document.getElementById("divNumberDecimal").style.display = 'unset';
}
else{
document.getElementById("divNumberDecimal").style.display = 'none';
}
}

// update decimal value field
decimalsVisibility();

// update visible/invisible fields
onAddEntityAttributeClick();
</script>
Expand Down Expand Up @@ -216,7 +249,7 @@
<div class="info_icon" onClick="onInfoCapability()">
<span class="fa fa-icon fa-info-circle"></span>
</div>
<input id="capabilityAdd" class="homey-form-input" type="text" value=""/>
<input id="capabilityAdd" class="homey-form-input" type="text" value="" onchange="onCapabilityChanged()" oninput="onCapabilityChanged()"/>
<!-- </div>
<div class="homey-form-group"> -->
<fieldset class="homey-form-checkbox-set">
Expand All @@ -233,6 +266,17 @@
</div>
</div>

<!-- Number Decimal options -->
<div class="homey-form-group" id="divNumberDecimal" style="display:none">
<fieldset class="homey-form-checkbox-set">
<label for="decimalsAdd" class="homey-form-label" style="display: inline;"><span data-i18n="repair.custom_device.decimals"></span></label>
<div class="info_icon" onClick="onInfoDecimals()">
<span class="fa fa-icon fa-info-circle"></span>
</div>
<input id="decimalsAdd" class="homey-form-input" type="number" value=""/>
</fieldset>
</div>

<!-- Number Input options -->
<div class="homey-form-group" id="divNumberInput" style="display:none">
<fieldset class="homey-form-checkbox-set">
Expand All @@ -258,7 +302,7 @@
<input id="entityNumberRangeMaxAdd" class="homey-form-input" type="text" value=""/>
</td>
<td>
<label for="entityNumberRangeStepnAdd" class="homey-form-label"><span data-i18n="repair.custom_device.number_range_step"></span></label>
<label for="entityNumberRangeStepAdd" class="homey-form-label"><span data-i18n="repair.custom_device.number_range_step"></span></label>
<input id="entityNumberRangeStepAdd" class="homey-form-input" type="text" value=""/>
</td>
</tr>
Expand Down Expand Up @@ -364,6 +408,7 @@
document.getElementById('nameAdd').value = event.detail.selection.value.name;
document.getElementById('unitAdd').value = event.detail.selection.value.unit;
document.getElementById('capabilityAdd').value = await Homey.emit("getCustomTemplateCapability", event.detail.selection.value.entity_id)
decimalsVisibility();
if (event.detail.selection.value.number_range != undefined){
document.getElementById('addEntityNumberInput').checked = false;
if (event.detail.selection.value.number_range.min != undefined){
Expand Down
Loading

0 comments on commit fe92e88

Please sign in to comment.