From 3dce8d1c7c994c52ed81a46c9bbbac65690b0e0b Mon Sep 17 00:00:00 2001 From: marvin78 Date: Tue, 14 Jan 2020 07:53:48 +0000 Subject: [PATCH] 98_todoist: removed Attribute "sortTasks" / better commandref git-svn-id: https://svn.fhem.de/fhem/trunk@20969 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/98_todoist.pm | 96 +++++------------------------------------ 2 files changed, 12 insertions(+), 85 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 6eb0c2663..fe86109ed 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - change: 98_todoist: removed Attribute "sortTasks" / better commandref - change: 93_DbLog: change datetime pattern in valueFn of addCacheLine Forum: #107285 - change: 98_todoist: reorder tasks - widget reorder diff --git a/fhem/FHEM/98_todoist.pm b/fhem/FHEM/98_todoist.pm index a6d88f18e..990c69465 100644 --- a/fhem/FHEM/98_todoist.pm +++ b/fhem/FHEM/98_todoist.pm @@ -17,7 +17,7 @@ eval "use Date::Parse;1" or $missingModule .= "Date::Parse "; ####################### # Global variables -my $version = "1.3.0"; +my $version = "1.3.1"; my $srandUsed; @@ -76,7 +76,6 @@ sub todoist_Initialize($) { $hash->{AttrList} = "disable:1,0 ". "pollInterval ". "do_not_notify ". - "sortTasks:1,0 ". "getCompleted:1,0 ". "showPriority:1,0 ". "showAssignedBy:1,0 ". @@ -937,7 +936,7 @@ sub todoist_GetTasksCallback($$$){ else { my $decoded_json=""; - # checl for correct JSON + # check for correct JSON if (eval{decode_json($data)}) { $decoded_json = decode_json($data); @@ -1134,11 +1133,7 @@ sub todoist_GetTasksCallback($$$){ readingsEndUpdate( $hash, 1 ); - - ## sort Tasks alphabetically if set - todoist_sort($hash) if (AttrVal($name,"sortTasks",0) == 1); - - + RemoveInternalTimer($hash,"todoist_GetTasks"); InternalTimer(gettimeofday()+$hash->{INTERVAL}, "todoist_GetTasks", $hash, 0); ## loop with Interval @@ -1466,73 +1461,6 @@ sub todoist_GetProjectsCallback($$$){ return "Got $i new projects: ".$return; } -# sort alphabetically (probably deprecated) -sub todoist_sort($) { - my ($hash) = @_; - - my $name=$hash->{NAME}; - - my $lText=""; - - my %list; - - - ## get all Readings - my $readings = $hash->{READINGS}; - ## prepare Hash for sorting - foreach my $key (keys %{$readings}) { - if ($key =~ m/^Task_\d\d\d$/) { - my @temp = split("_",$key); - my $tid = int($temp[1]); - my $val = $readings->{$key}{VAL}; - my $id = $hash->{helper}{IDS}{'Task_'.$tid}; - $list{$tid} = {content => $val, ID => $id}; - } - } - - CommandDeleteReading(undef, "$hash->{NAME} (T|t)ask_.*"); - - readingsBeginUpdate($hash); - - delete($hash->{helper}{"IDS"}); - - ## sort Tasks and write them back - my $i = 0; - foreach my $key (sort {lc($list{$a}->{content}) cmp lc($list{$b}->{content})} keys(%list)) { - my $data = $list{$key}; - readingsBulkUpdate($hash,"Task_".sprintf("%03s",$i),$data->{content}); - readingsBulkUpdate($hash,"Task_".sprintf("%03s",$i)."_dueDate",$hash->{helper}{"DUE_DATE"}{$data->{ID}}) if ($hash->{helper}{"DUE_DATE"}{$data->{ID}}); - readingsBulkUpdate($hash,"Task_".sprintf("%03s",$i)."_responsibleUid",$hash->{helper}{"RESPONSIBLE_UID"}{$data->{ID}}) if ($hash->{helper}{"RESPONSIBLE_UID"}{$data->{ID}} && AttrVal($name,"showResponsible",0)==1); - readingsBulkUpdate($hash,"Task_".sprintf("%03s",$i)."_assignedByUid",$hash->{helper}{"ASSIGNEDBY_UID"}{$data->{ID}}) if ($hash->{helper}{"ASSIGNEDBY_UID"}{$data->{ID}} && AttrVal($name,"showAssignedBy",0)==1); - readingsBulkUpdate($hash,"Task_".sprintf("%03s",$i)."_priority",$hash->{helper}{"PRIORITY"}{$data->{ID}}) if ($hash->{helper}{"PRIORITY"}{$data->{ID}} && AttrVal($name,"showPriority",0)==1); - readingsBulkUpdate($hash,"Task_".sprintf("%03s",$i)."_recurrenceType",$hash->{helper}{"RECURRENCE_TYPE"}{$data->{ID}}) if ($hash->{helper}{"RECURRENCE_TYPE"}{$data->{ID}}); - readingsBulkUpdate($hash,"Task_".sprintf("%03s",$i)."_completedAt",$hash->{helper}{"COMPLETED_AT"}{$data->{ID}}) if ($hash->{helper}{"COMPLETED_AT"}{$data->{ID}}); - readingsBulkUpdate($hash,"Task_".sprintf("%03s",$i)."_completedById",$hash->{helper}{"COMPLETED_BY_ID"}{$data->{ID}}) if ($hash->{helper}{"COMPLETED_BY_ID"}{$data->{ID}}); - readingsBulkUpdate($hash,"Task_".sprintf("%03s",$i)."_order",$hash->{helper}{"ORDER"}{$data->{ID}}) if ($hash->{helper}{"ORDER"}{$data->{ID}} && AttrVal($name,"showOrder",0)==1); - readingsBulkUpdate($hash,"Task_".sprintf("%03s",$i)."_parentID",$hash->{helper}{"PARENT_ID"}{$data->{ID}}) if ($hash->{helper}{"PARENT_ID"}{$data->{ID}}); - readingsBulkUpdate($hash,"Task_".sprintf("%03s",$i)."_sectionID",$hash->{helper}{"SECTION_ID"}{$data->{ID}}) if ($hash->{helper}{"SECTION_ID"}{$data->{ID}}); - readingsBulkUpdate($hash,"Task_".sprintf("%03s",$i)."_checked",$hash->{helper}{"CHECKED"}{$data->{ID}}) if ($hash->{helper}{"CHECKED"}{$data->{ID}} && AttrVal($name,"showChecked",1)==1); - readingsBulkUpdate($hash,"Task_".sprintf("%03s",$i)."_isDeleted",$hash->{helper}{"ISDELETED"}{$data->{ID}}) if ($hash->{helper}{"ISDELETED"}{$data->{ID}} && AttrVal($name,"showDeleted",1)==1); - readingsBulkUpdate($hash,"Task_".sprintf("%03s",$i)."_ID",$data->{ID}) if (AttrVal($name,"hideId",0)!=1); - - $hash->{helper}{"IDS"}{"Task_".$i} = $data->{ID}; - $hash->{helper}{"WID"}{$data->{ID}} = $i; - - if (!$hash->{helper}{"COMPLETED_AT"}{$data->{ID}}) { - $lText.=", " if ($i != 0); - $lText.=$data->{content}; - } - $i++; - } - - ## list Text for TTS, Text-Message... - $lText="-" if ($lText eq ""); - readingsBulkUpdate($hash,"listText",$lText) if ($lText ne ""); - - readingsEndUpdate( $hash, 1 ); - return undef; -} - ################################################# # delete all Tasks from list @@ -1751,7 +1679,7 @@ sub todoist_Attr($@) { } } - if ( $attrName eq "sortTasks" || $attrName =~ /(show(Priority|AssignedBy|Responsible|Order|DetailWidget|Section|Parent)|getCompleted|hide(Id|ListIfEmpty)|autoGetUsers|avoidDuplicates|delDeletedLists)/) { + if ( $attrName =~ /(show(Priority|AssignedBy|Responsible|Order|DetailWidget|Section|Parent)|getCompleted|hide(Id|ListIfEmpty)|autoGetUsers|avoidDuplicates|delDeletedLists)/) { if ( $cmd eq "set" ) { return "$name: $attrName has to be 0 or 1" if ($attrVal !~ /^(0|1)$/); Log3 $name, 4, "todoist ($name): set attribut $attrName to $attrVal"; @@ -2406,7 +2334,7 @@ sub todoist_genUUID() { set <DEVICE> updateTask 1 dueDate=übermorgen
set <DEVICE> updateTask TITLE:Brot dueDate=übermorgen

  • moveTask - move a task to another parent or project. - Needs Task-ID or todoist-Task-ID as parameter

    + Expects Task-ID or todoist-Task-ID as parameter

    Possible additional parameters are:

    @@ -2443,12 +2375,6 @@ sub todoist_genUUID() {
  • disable
  • pollInterval get the list every pollInterval seconds. Default is 1800. Smallest possible value is 20.

  • -
  • sortTasks -

  • hideId