Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UZSU Plugin: introduce "once" feature for only running an uzsu entry one time #983

Merged
merged 34 commits into from
Dec 23, 2024
Merged
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5635c05
uzsu plugin: "once" feature to trigger uzsu entry only once and deact…
onkelandy Nov 20, 2024
a01adce
uzsu plugin: logging improvement
onkelandy Nov 21, 2024
9e7f94a
uzsu: make once work with individual list entries
onkelandy Dec 1, 2024
cbdbe7f
uzsu: make 'once' work with interpolation
onkelandy Dec 2, 2024
b06198f
uzsu: implement once for series, part 1
onkelandy Dec 3, 2024
e71299b
uzsu: make once work with series
onkelandy Dec 3, 2024
31ac401
uzsu: bump version to 2.1.0
onkelandy Dec 3, 2024
8cdf0e6
uzsu: fix scheduling for series once
onkelandy Dec 3, 2024
45bc390
uzsu: fix once for series
onkelandy Dec 4, 2024
0229005
uzsu: update webif and docu
onkelandy Dec 4, 2024
a460a1e
uzsu: fix series interval calculation. Actually, now end of series is…
onkelandy Dec 7, 2024
b60eb57
uzsu: implement activeToday for smartvisu, fix once for series
onkelandy Dec 8, 2024
5cafb5d
uzsu: fix comparison of new and old dictionary
onkelandy Dec 13, 2024
b2d1a34
uzsu: update handling of once for series. might work now? ;)
onkelandy Dec 14, 2024
a2d9dcc
uzsu: fix once handling .. again
onkelandy Dec 16, 2024
c820c20
uzsu: adjust struct
onkelandy Dec 18, 2024
c4adb7e
uzsu: introduce "perday" interpolation feature
onkelandy Dec 18, 2024
119f935
uzsu: minimize/optimize dict writing to item
onkelandy Dec 18, 2024
64eeadd
uzsu: improve web interface
onkelandy Dec 19, 2024
95f386b
uzsu: update docu
onkelandy Dec 19, 2024
d0155d8
uzsu: fix extra-long debug messages
onkelandy Dec 20, 2024
38a188f
uzsu: code improvements, fix lastvalue handling, update activeToday o…
onkelandy Dec 20, 2024
972ac52
uzsu: further lastvalue improvements/fixes
onkelandy Dec 21, 2024
e4109af
uzsu: improve documentation, add info on once feature
onkelandy Dec 21, 2024
11ce478
uzsu: fix evaluation of upcoming setting when once feature is used
onkelandy Dec 21, 2024
22ec0f1
uzsu: global once deactivates uzsu on first setting, no matter if it …
onkelandy Dec 21, 2024
5553a3e
uzsu: introduce set_activetoday plugin function
onkelandy Dec 21, 2024
4089b11
uzsu: introduce ignore_once_entries parameter for (not) using once se…
onkelandy Dec 21, 2024
f2c5ee5
uzsu: fix and improve perday interpolation
onkelandy Dec 21, 2024
486b350
uzsu: avoid wrong value when 2 entries set a value at the same time a…
onkelandy Dec 21, 2024
81478c5
uzsu: update docu
onkelandy Dec 21, 2024
61878e5
uzsu: fix wrong logger entry
onkelandy Dec 22, 2024
2b12069
uzsu: improve item writing, fix issue when uzsu has no active entries
onkelandy Dec 22, 2024
c3c1348
uzsu: avoid cycle of schedule and item update
onkelandy Dec 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
uzsu: improve web interface
onkelandy committed Dec 19, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 64eeaddf2a4d8106175379245c1740ef7b3bc37d
8 changes: 5 additions & 3 deletions uzsu/__init__.py
Original file line number Diff line number Diff line change
@@ -629,6 +629,8 @@ def _update_item(self, item, caller="", comment=""):
self.logger.debug(f'Issues with updating sunset/rise calculations for item {item} caller: {caller} comment: {comment}, issue: {success}')
#item(self._items[item], caller, comment)
self._webdata['items'][item.property.path].update({'interpolation': self._items[item].get('interpolation')})
if self._webdata['items'][item.property.path].get('interpolationrunning') is None:
self._webdata['items'][item.property.path].update({'interpolationrunning': 'False'})
self._webdata['items'][item.property.path].update({'active': str(self._items[item].get('active'))})
_suncalc = self._items[item].get('SunCalculated')
self._webdata['items'][item.property.path].update({'sun': _suncalc})
@@ -838,9 +840,10 @@ def _schedule(self, item, caller=None):
self._update_item(item, 'UZSU Plugin', 'reset_interpolation')
if _caller != "dry_run":
self.logger.debug(f'will add scheduler named uzsu_{item.property.path} with datetime {_next} and tzinfo {_next.tzinfo} and value {_value} based on list index {_entryindex}')
self._planned.update({item: {'value': _value, 'next': _next.strftime('%Y-%m-%d %H:%M:%S')}})
self._webdata['items'][item.property.path].update({'planned': {'value': _value, 'time': _next.strftime('%d.%m.%Y %H:%M')}})
self._planned.update({item: {'value': _value, 'next': _next.strftime('%d.%m.%Y %H:%M:%S')}})
self._webdata['items'][item.property.path].update({'planned': {'value': _value, 'time': _next.strftime('%d.%m.%Y %H:%M:%S')}})
self._webdata['items'][item.property.path].update({'seriesrunning': 'True' if self._series[item].get(_entryindex) == "running" else 'False'})
self._webdata['items'][item.property.path].update({'interpolationrunning': str(_interpolated)})
self._update_count['done'] = self._update_count.get('done', 0) + 1
update = 'init' if update == 'init' else 'add_scheduler'
self._update_item(item, 'UZSU Plugin', 'add_scheduler')
@@ -1495,7 +1498,6 @@ def get_itemdict(self, item):
:item: uzsu item
:return: sanitized dict from uzsu item
"""

return html.escape(json.dumps(self._items[item]))

def get_items(self):
66 changes: 44 additions & 22 deletions uzsu/webif/templates/index.html
Original file line number Diff line number Diff line change
@@ -39,55 +39,65 @@
planned = objResponse['items'][item]['planned']['value'];
lastvalue = objResponse['items'][item]['lastvalue'];
seriesrunning = objResponse['items'][item]['seriesrunning'];
if (objResponse['items'][item]['active'] == 'True' && planned == '-') {color = 'red';}
else if (planned == '-' || objResponse['items'][item]['active'] == 'False' ){color = 'gray';}
else if (seriesrunning == 'True'){color = '#FEC34D';}
else {color = 'green'}

if (objResponse['items'][item]['active'] === 'True' && planned === '-') {color = 'red';}
else if (planned === '-' || objResponse['items'][item]['active'] === 'False' ){color = 'gray';}
else if (seriesrunning === 'True'){color = '#FEC34D';}
else {color = 'green';}
{intpl_color = color;}
if (objResponse['items'][item]['depend']['item'] == null) {
depend_text = '{{ _('Item existiert nicht!') }}';
color = 'red';
intpl_color = 'red';
}
else {
depend_text = objResponse['items'][item]['depend']['item'] + ' (' + objResponse['items'][item]['interpolation']['itemtype'] + ')';
}

if (objResponse['items'][item]['interpolation'] == undefined) {
if (objResponse['items'][item]['interpolation'] === undefined) {
intpl_text = "{{ _('fehlt!') }}";
bit_text = "{{ _('fehlt!') }}";
color = 'red';
intpl_color = 'red';
}
else {
if (objResponse['items'][item]['interpolation']['itemtype'] == 'bool') {
if (planned == 1) {planned = 'True';}
else if (planned == 0) {planned = 'False';}
if (lastvalue == 1) {lastvalue = 'True';}
else if (lastvalue == 0) {lastvalue = 'False';}
if (objResponse['items'][item]['interpolation']['itemtype'] === 'bool') {
if (planned === 1) {planned = 'True';}
else if (planned === 0) {planned = 'False';}
if (lastvalue === 1) {lastvalue = 'True';}
else if (lastvalue === 0) {lastvalue = 'False';}
}
if (objResponse['items'][item]['interpolation']['initage'] === '') {
bit_text = '0';
}
else {
bit_text = objResponse['items'][item]['interpolation']['initage'];
}
if (objResponse['items'][item]['interpolation']['interval'] == '' || objResponse['items'][item]['interpolation']['interval'] == undefined) {
if (objResponse['items'][item]['interpolation']['type'] == 'none') {
if (objResponse['items'][item]['interpolationrunning'] !== 'True')
intpl_color = 'gray';
if (objResponse['items'][item]['interpolation']['interval'] === '' || objResponse['items'][item]['interpolation']['interval'] === undefined) {
if (objResponse['items'][item]['interpolation']['type'] === 'none') {
interval = '';
}
else {
interval = ' (<span style="color: gray;">5</span>)';
}
}
else {
if (objResponse['items'][item]['interpolation']['type'] == 'none') {
if (objResponse['items'][item]['interpolation']['type'] === 'none') {
interval = '';
}
else {
interval = ' (' + objResponse['items'][item]['interpolation']['interval'] + ')';
if (objResponse['items'][item]['interpolation']['perday'] === true) {
perday = ', per day';
}
else {
perday = '';
}
interval = ' (' + objResponse['items'][item]['interpolation']['interval'] + perday + ')';
}
}
intpl_text = objResponse['items'][item]['interpolation']['type'] + interval;
if (objResponse['items'][item]['sun'] == undefined) {
if (objResponse['items'][item]['sun'] === undefined) {
sunrise_text = '';
sunset_text = '';
}
@@ -112,15 +122,16 @@
}
}
$('#' + $.escapeSelector(item)).css({'color': color});
$('#' + $.escapeSelector(item + '_interpolation')).css({'color': intpl_color});
shngInsertText (item+'_interpolation', intpl_text, 'maintable', 10);
shngInsertText (item+'_backintime', bit_text, 'maintable', 10);
shngInsertText (item+'_dict', objResponse['items'][item]['dict'], 'maintable');
shngInsertText (item+'_dependvalue', objResponse['items'][item]['depend']['value'], 'maintable', 10);
shngInsertText (item+'_nextvalue', planned, 'maintable', 10);
if (objResponse['items'][item]['planned']['time'] == '-')
if (objResponse['items'][item]['planned']['time'] === '-')
shngInsertText (item+'_nexttime', '-', 'maintable', 10);
else
shngInsertText (item+'_nexttime', '&#x202a;'+objResponse['items'][item]['planned']['time']+'&#x202c;', 'maintable', 10);
shngInsertText (item+'_nexttime', '&#8234;'+objResponse['items'][item]['planned']['time']+'&#8236;', 'maintable', 10);
shngInsertText (item+'_dependitem', depend_text, 'maintable');
shngInsertText (item+'_lastvalue', lastvalue, 'maintable', 10);
shngInsertText ('sunrise', sunrise_text, null, 2);
@@ -204,6 +215,7 @@
{% else %}
{% set color = 'green' %}
{% endif %}
{% set intpl_color = color %}
<tr id="{{ item }}" style="color: {{ color }}">
<td></td>
<td class="py-1" id="{{ item }}_path">{{ item }}</td>
@@ -221,25 +233,35 @@
{% endif %}
</td>
<td class="py-1" id="{{ item }}_nextvalue">
{{ p._webdata['items'][item]['planned']['value'] }}
{{ p._webdata['items'][item]['planned']['value'] | replace('.0', '') }}
</td>
<td class="py-1" id="{{ item }}_nexttime">
{% if p._webdata['items'][item]['planned']['time'] == '-' %}
-
{% else %}
&#x202a;{{ p._webdata['items'][item]['planned']['time'] }}&#x202c;
&#8234;{{ p._webdata['items'][item]['planned']['time'] }}&#8236;
{% endif %}
</td>
<td class="py-1" id="{{ item }}_lastvalue">
{{ p._webdata['items'][item]['lastvalue'] }}
</td>
<td class="py-1" id="{{ item }}_interpolation">
{% if p._webdata['items'][item]['interpolation'] is not defined %}
{% set intpl_color = 'red' %}
{% elif p._webdata['items'][item]['interpolationrunning'] != 'True' %}
{% set intpl_color = 'gray' %}
{% endif %}
<td class="py-1" id="{{ item }}_interpolation" style="color: {{ intpl_color }}">
{% if p._webdata['items'][item]['interpolation'] is not defined %}
{{ _('fehlt!') }}
{% elif p._webdata['items'][item]['interpolation']['type'] %}
{{ p._webdata['items'][item]['interpolation']['type'] }}
{% if p._webdata['items'][item]['interpolation']['type'] != 'none' and p._webdata['items'][item]['interpolation']['interval'] %}
({{ p._webdata['items'][item]['interpolation']['interval'] }})
{% if p._webdata['items'][item]['interpolation']['perday'] == true %}
{% set perday = ', per day' %}
{% else %}
{% set perday = '' %}
{% endif %}
({{ p._webdata['items'][item]['interpolation']['interval'] }}{{ perday }})
{% endif %}
{% else %}-
{% endif %}