Asystent AI
Powiadomienia
Wyczyść wszystko

timer counter

1 Wpisów
1 Użytkownicy
0 Reactions
3,212 Wyświetleń
(@gerdii)
Wpisów: 27
Praktykant
Autor tematu
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 
[#212]

Hej pomożecie nie widzę błędu a nie działa jak powinno. Założenie, że zlicza mi czas działania switch Piec po włączeniu na ON a widzę że się zmienia jak przełącznik jest na oFF.

var long LastUpdate2 = 0
rule "Piec time calculation"
when
Item Piec received update
then
var long currentTime2 = now.millis

if (LastUpdate2 != 0) {
var long timeElapsed = currentTime - LastUpdate2
if (timeElapsed > 0) {
var Number timeperiod = timeElapsed / 1000 //min
postUpdate(TotalPiecTime, TotalPiecTime.state as DecimalType + timeperiod)
postUpdate(DailyPiecTime, DailyPiecTime.state as DecimalType + timeperiod)
}
}

LastUpdate2 = currentTime
end

*.items

Number TotalPiecTime "total time [%.0f min]"
Number DailyPiecTime "todays time [%.0f min]"

 

log:

2018-01-12 14:41:27.827 [vent.ItemStateChangedEvent] - Piec changed from OFF to ON
2018-01-12 14:41:27.861 [vent.ItemStateChangedEvent] - TotalPiecTime changed from 37 to 38
2018-01-12 14:41:27.868 [vent.ItemStateChangedEvent] - DailyPiecTime changed from 37 to 38
2018-01-12 14:42:28.965 [vent.ItemStateChangedEvent] - Piec changed from ON to OFF
2018-01-12 14:42:28.998 [vent.ItemStateChangedEvent] - TotalPiecTime changed from 38 to 39
2018-01-12 14:42:29.003 [vent.ItemStateChangedEvent] - DailyPiecTime changed from 38 to 39
2018-01-12 14:43:30.349 [vent.ItemStateChangedEvent] - TotalPiecTime changed from 39 to 40
2018-01-12 14:43:30.351 [vent.ItemStateChangedEvent] - DailyPiecTime changed from 39 to 40
2018-01-12 14:44:31.313 [vent.ItemStateChangedEvent] - TotalPiecTime changed from 40 to 41
2018-01-12 14:44:31.325 [vent.ItemStateChangedEvent] - DailyPiecTime changed from 40 to 41
2018-01-12 14:46:33.781 [vent.ItemStateChangedEvent] - TotalPiecTime changed from 41 to 43
2018-01-12 14:46:33.790 [vent.ItemStateChangedEvent] - DailyPiecTime changed from 41 to 43


 
Dodane : 12/01/2018 4:05 pm
Udostępnij: