My personal Rule of thumb is if I can have fewer lines of code in Rules it’s better. I’m not sure it saves you much in this case. I wouldn’t change the working Rule.
However I have some observations.
I’d get rid of the first timer (now.plusMillis(1)) and just call the HTTP command.
The next two timers go off at basically the same time, so why not combine them and just use one Timer that calls both?
For me to understand & learn:
Wouldn’t this mean that if it takes the camera 1000ms to respond to the move request, it will make the rule wait for a whole second?
If my understanding is correct, why would you prefer the rule to wait for 1 second over using a timer thread? Because there are only 2 timer threads and 5 rule threads?
You are correct.
The reason for this is that the “Start Video recording” and “Stop video recording” are at the same part of the code, while the “Run PHP file” is in a later part of the code, which calls the PHP file with a parameter, based on an “if” clause.
Based on reading your Design Pattern: How to Structure a Rule, I assume I should build the HTTP string in the “if” clause, and only then create a single timer with the 2 HTTP calls:
One “static” to Start Video recording
Second “dynamic” (which was built in the “if” clause) to run the PHP file.
Am I correct?
EDIT:
While waiting for your answer, I tried modifying the rule, but I receive an error in VS.
The error is:
Cannot refer to the non-final variable httpPHPStr inside a lambda expression
The modified rule:
rule EntranceDoor Opened
when
Item iEntranceDoorSensor changed to OPEN
then
createTimer(now.plusMillis(1), [ |
sendHttpGetRequest(". . . . .", 1000) // Move camera to face door
])
var httpPHPStr = "http://192.168.1.111/SendMailOpenHAB.php?id=3" // Parents at home
if (ParentsNotAtHome) {
if (KidsAtHome) {
httpPHPStr = "http://192.168.1.111/SendMailOpenHAB.php?id=1" // Kids Home Alone
} else {
httpPHPStr = "http://192.168.1.111/SendMailOpenHAB.php?id=2" // Home is Empty
}
}
createTimer(now.plusSeconds(1), [ |
sendHttpGetRequest(". . . . .", 1000) // Start Video recording
sendHttpGetRequest(httpPHPStr, 1000) // Run PHP file that checks what is the latest file NOW but sends it in 30 seconds
])
createTimer(now.plusSeconds(15), [ |
sendHttpGetRequest(". . . . .", 1000) // Stop Video recording
])
end
I assume this is because the httpPHPStr variable is not defined within the createTimer.
How should I tackle this?
Or does it mean I cannot use your DP in this case?
Rick can give you the “why” about lambdas and context, but the overall effect is that you cannot pass vars into timer lambdas - the code between . This is the “non-final” thing it’s whinging about.
You can pass vals - but have to observe the limitation that you cannot modify a val after creation, it’s like a constant.
Unrelated consideration; do you want to evaluate conditions at the time you create the timer, or at the moment it executes? Doesn’t matter a lot when it’s just a few seconds, but it can do, and then you’d need to structure as required.
This should work, note use of val and var
// only one place to set URL, easier to maintain
val httpPHPStr = "http://192.168.1.111/SendMailOpenHAB.php"
createTimer(now.plusSeconds(1), [ |
sendHttpGetRequest(". . . . .", 1000) // Start Video recording
var httpPHPStrParam = httpPHPStr + "?id=3" // Parents at home
if (ParentsNotAtHome) {
if (KidsAtHome) {
httpPHPStrParam = httpPHPStr + "?id=1" // Kids Home Alone
} else {
httpPHPStrParam = httpPHPStr + "?id=2" // Home is Empty
}
}
sendHttpGetRequest(httpPHPStrParam, 1000) // Run PHP file that checks what is the latest file NOW but sends it in 30 seconds
])
I’m a bit confused with the overall task - if you have control of Start and Stop recording, why not do the grab-and-post part after recording has stopped?
Thank you for the thorough explanation - I understand the difference between var and val, and now also know that from outside a lambda you can also pass vals, and you can only use vars that are defined within the lambda.
I wold like to evaluate at the time the timer is created. Thanks.
I have 1 more question:
Is it allowed to use createTimer within a createTimer? Is there any risk involved (apart of what you already explained me, that only 2 timer threads can be executed at the same time)?
If, for example, I would like to send a Telegram message with a photo, a few seconds after the door was opened, can I use this (note the sendTelegramPhoto inside:
// only one place to set URL, easier to maintain
val httpPHPStr = "http://192.168.1.111/SendMailOpenHAB.php"
createTimer(now.plusSeconds(1), [ |
sendHttpGetRequest(". . . . .", 1000) // Start Video recording
var httpPHPStrParam = httpPHPStr + "?id=3" // Parents at home
if (ParentsNotAtHome) {
if (KidsAtHome) {
httpPHPStrParam = httpPHPStr + "?id=1" // Kids Home Alone
} else {
httpPHPStrParam = httpPHPStr + "?id=2" // Home is Empty
createTimer(now.plusSeconds(3), [ |
sendTelegramPhoto("bot1", "http://192.168.1.222/snapshot.cgi", "Door Opened when Kids home alone")
])
}
}
sendHttpGetRequest(httpPHPStrParam, 1000) // Run PHP file that checks what is the latest file NOW but sends it in 30 seconds
])
Is there a better approach to this?
This is a bit complicated - I hope I’ll manage to explain it with my lousy English.
My camera starts and stops recording based on different events (for example, motion detected, size of video file, etc).
In order for the video file to be played correctly after being sent, it must be sent in full, i.e. after the recording of that file is stopped.
Therefor, whenever the door is opened I want to start recording (and make sure a new video file is created).
Then, I want to check what is the name of that last video file, wait for 15 seconds, finish recording (thus “closing” the file) and only then sending it.
I am already using the expire binding for a dozen of “virtual” switch items that operate as timers (for example: change air condition temperature after some time, etc.)
Do you recommend creating a couple of virtual items that will server as timers with the expire binding, and using a couple of rules, execute the relevant activities?
Yes… exactly!
I have just been checking out some forum posts on use of the expire binding and there is info in the forums but I don’t find a clear easy example of how I mostly use it… so
I usually create a switch item as follows
Switch BathDayXpr { expire="3m,command=OFF" }
So, the switch changes to OFF after 3 minutes. If it is sent any command except OFF, it re-triggers the timer. So if it is sent ON from a motion sensor or something, the 3 minutes starts over.
then I use a rule as such
rule "My timer ran out"
when
BathDayXpr changes to OFF
then
// do whatever you want here
MyBathroomLight.sendCommand (OFF)
end
What may be useful for you is not worrying about running out of timer threads or creating new timers or whatever, just set up an unbound expire item as shown then do whatever when it is ready
Yes and you are creating a lot of timers in this a rule which increases the likelihood that you will have two or more that need to run at the same time.
There is also no evidence presented to indicate that you are usually running low on rule threads.
This sounds like a good approach.
I believe this is one of those cases where VSCode complains but the rule will actually run just fine.
The following code works.
var Timer timer = null
rule "Test string"
when
Item Test received command
then
logInfo("Test", "Test changed to \""+Test.state.toString+"\"")
var count = 0
timer = createTimer(now, [ |
logInfo("test", "Looping timer with " + count)
if(count < 10) {
count = count + 1
timer.reschedule(now.plusMillis(500))
}
else {
timer = null
}
])
end
I tested it not to long ago. As you can see, count is a var referenced inside the lambda. The trick though is that the changes to count exist only inside the lambda.
Actually you can with create timer. It doesn’t make sense to with a lambda passed to forEach, for example, because the changes made to the var only exist inside the lambda.
This has been reported as an error by the vscode forever but I wonder if it’s always been allowed despite the warning.
All that being said, rossko57’s version is a bit cleaner over all.
So taking into consideration the advantages and disadvantages, how would you implement if it was for yourself?
A. Using the rossko57’s version (which does uses timers)
or B. leaving the sendHttp* calls in the rule, and taking the risk that the rule could hang up to 3 seconds (and another rule with expire binding that will be executed 15 seconds later and could hang for 1 second a well)?
You are right.
When I originally built my rules, I placed all my sendHTTP* calls in a createTimer, because I read somewhere a recommendation to refrain from having it in a rule.
I was not aware that there is also a limit on the number of timer threads running together.
When I check the number of threads using htop, is it normal that this number fluctuates, with an overall growing trend?
On June 13th at 10:45 it was 287
On June 13th at 15:12 it was 301
On June 13th at 16:48 it was 291
On June 13th at 23:33 it was 296
On June 14th at 08:35 it was 298
On June 14th at 23:03 it was 294
On June 15th at 23:48 it was 316
On June 16th at 21:46 (now) it is 310
What should I pay attention to in my rules, to make sure I don’t cause this number to grow?
Also, is it normal to see on the htop list many threads with:
The answer depends on information I don’t have. The better solution depends on what the rest of your rules and timers are doing. If you are unlikely to have lots of other rules running when this rule runs then I’d the up the Rule thread. If you are but you are unlikely to have more than one other Timer, Cron triggered rule, or Astro triggered rule go off at the same time then Timers would be a better choice. If you are likely to have rules and timers going off at the same time, I’d move these long running http calls to an external script that can execute without consuming OH resources.
Also note that as you update and modify your rules the better solution may change.
That shows you all of the OH threads. But in this discussion all that matters is the timer threads and the rules threads. By default you only get two timer threads and five rules threads.
What can cause the number of threads to increase?
Do the statistics I provided above reflect a normal status or not?
Do these threads get “released” after some time?
The thread gets released when the rule is done executing
I’m sure Rich can explain it better but there are 5 rules threads. Every running rule consumes one thread while it is actually running. Most rules only run for a few fractions of a second so long as they are not overly complex. Example: motion sensor signal ON, rule runs, turns light on… done, maybe a few milliseconds. So 5 should be plenty, in case 2 or 3 things happen all at once. But if you have rules that run for a long period of time, for what ever reason, that is one less thread in the pool of available threads for other rules that want to run
So… what causes threads to run for a long time? Lots of stuff, but most is common sense. Long thread sleeps are the worst offenders. Long running loops, calls to services that don’t reply quickly, whatever
I am already familiar with everything you wrote (with regards to rules, and thanks to this thread, also with regards to timers).
I don’t use any Thread::sleep, all my sendHTTP* calls were within createTimer to prevent rules hanging, and apart of this my rules don’t use any timers (I do have 16 cron-based rules and 3 astro-based rules, but they are all well spread along the day).
I am not familiar, though, with the OS, how it should behave, and how to analyze the usage of resources, and making sure it works as it should, or I should look into specific areas and analyze them.
I am looking for what causes the number of threads growing on my system, and whether this is a "temporary"grow (and threads get released over time) or it is a “constant” grow.
If it helps, my setup is using openhabian over a RPi 3B+ with the following bindings:
Astro (only 3 very short rules are triggered by the astro binding)
Expire (~30 items using it)
HarmonyHub
Xiaomi Mi (2 nodes connected to it)
Network (pinging 4 iPhones)
Samsung Tv (polling every 1 second)
openHAB Weather (polling every 2 minutes)
YamahaReceiver (polling every 10 seconds)
ZWave (~22 nodes connected to it)
Also using:
openHAB Cloud connector
Google Calendar connector
Mapdb for RestoreOnStartup
Influxdb for some other items (installed grafana as well, but didn’t “play” with it too much, yet)
Here is a the full bundle list:
openhab> bundle:list
START LEVEL 100 , List Threshold: 50
ID │ State │ Lvl │ Version │ Name
20 │ Active │ 80 │ 5.3.1.201602281253 │ OSGi JAX-RS Connector
21 │ Active │ 80 │ 2.7.0.v20170129-0911 │ Gson: Google Json Library for Java
22 │ Active │ 80 │ 18.0.0 │ Guava: Google Core Libraries for Java
23 │ Active │ 80 │ 3.0.0.v201312141243 │ Google Guice (No AOP)
26 │ Active │ 80 │ 3.5.5 │ JmDNS
28 │ Active │ 80 │ 1.0.0 │ Units of Measurement API
30 │ Active │ 80 │ 1.1.0.Final │ Bean Validation API
31 │ Active │ 80 │ 2.0.1 │ javax.ws.rs-api
32 │ Active │ 80 │ 3.2.0.v201101311130 │ ANTLR Runtime
35 │ Active │ 80 │ 3.2.1 │ Commons Collections
36 │ Active │ 80 │ 1.1 │ Commons Exec
37 │ Active │ 80 │ 2.2.0 │ Commons IO
38 │ Active │ 80 │ 2.6 │ Commons Lang
47 │ Active │ 80 │ 4.2.1 │ Apache Karaf :: OSGi Services :: Event
63 │ Active │ 80 │ 4.6.0 │ Apache XBean OSGI Bundle Utilities
64 │ Active │ 80 │ 4.6.0 │ Apache XBean :: Classpath Resource Finder
65 │ Active │ 80 │ 2.12.0.v20160420-0247 │ EMF Common
66 │ Active │ 80 │ 2.12.0.v20160420-0247 │ EMF Ecore
67 │ Active │ 80 │ 2.11.0.v20160420-0247 │ EMF Change Model
68 │ Active │ 80 │ 2.12.0.v20160420-0247 │ EMF XML/XMI Persistence
69 │ Active │ 80 │ 3.8.0.v20160509-1230 │ Common Eclipse Runtime
70 │ Active │ 80 │ 3.6.100.v20160223-2218 │ Extension Registry Support
80 │ Active │ 80 │ 9.4.11.v20180605 │ Jetty :: Proxy
94 │ Active │ 80 │ 0.4.1.v20180515-1321 │ org.eclipse.lsp4j
95 │ Active │ 80 │ 0.4.1.v20180515-1321 │ org.eclipse.lsp4j.jsonrpc
96 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome OAuth2Client
97 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Config Core
98 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Configuration Discovery
99 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Configuration mDNS Discovery
100 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Config Dispatcher
101 │ Active │ 75 │ 0.10.0.oh240 │ Eclipse SmartHome Config XML
102 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Core
103 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Core Audio
104 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Core Binding XML
105 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Core ID
106 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Core Persistence
107 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Scheduler Service
108 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Core Semantics
109 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Core Thing
110 │ Active │ 75 │ 0.10.0.oh240 │ Eclipse SmartHome Core Thing XML
111 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Transformation Service
112 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Core Voice
113 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Console
114 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Console for OSGi runtime Karaf
115 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome HTTP Interface Bundle
116 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome JavaSound I/O, Fragments: 183
117 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Monitor
118 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Net I/O Bundle
119 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome REST Interface Bundle
120 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Core REST API
121 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome REST mDNS Announcer
122 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome REST Interface JAX-RS optimization Bundle
123 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Sitemap REST API
124 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome SSE REST API
125 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Voice REST API
126 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Bonjour/MDS Service Discovery Bundle
127 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Web Audio Support
128 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Model Core
129 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Item Model
130 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Item Model IDE
131 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Item Model Runtime
132 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Language Server
133 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Persistence Model
134 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Persistence Model IDE
135 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Persistence Runtime
136 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Rule Model
137 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Rule Model IDE
138 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Rule Runtime
139 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Script
140 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Script Model IDE
141 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Script Runtime
142 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Sitemap Model
143 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Sitemap Model IDE
144 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Sitemap Runtime
145 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Thing Model
146 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Thing Model IDE
147 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Thing Model Runtime
148 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Json Storage Service
149 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome UI
150 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome UI Icons
151 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Classic IconSet
152 │ Active │ 80 │ 2.14.0.v20180522-1629 │ Xtend Runtime Library
153 │ Active │ 80 │ 2.14.0.v20180522-1629 │ Xtend Macro Interfaces
154 │ Active │ 80 │ 2.14.0.v20180522-1821 │ Xtext
155 │ Active │ 80 │ 2.14.0.v20180522-1833 │ Xtext Common Types
156 │ Active │ 80 │ 2.14.0.v20180522-1821 │ Xtext IDE Core
157 │ Active │ 80 │ 2.14.0.v20180522-1821 │ Xtext Utility
158 │ Active │ 80 │ 2.14.0.v20180522-1833 │ Xbase Model
159 │ Active │ 80 │ 2.14.0.v20180522-1833 │ Xbase Generic IDE Services
160 │ Active │ 80 │ 2.14.0.v20180522-1629 │ Xbase Runtime Library
175 │ Active │ 80 │ 1.9.6 │ MIME streaming extension
177 │ Active │ 80 │ 6.2.0 │ org.objectweb.asm
178 │ Active │ 80 │ 6.2.0 │ org.objectweb.asm.commons
179 │ Active │ 80 │ 6.2.0 │ org.objectweb.asm.tree
180 │ Active │ 90 │ 2.4.0 │ openHAB Core
181 │ Active │ 80 │ 2.4.0 │ openHAB Karaf Integration
183 │ Resolved │ 80 │ 2.4.0 │ openHAB Sound Support, Hosts: 116
184 │ Active │ 80 │ 2.4.0 │ openHAB Dashboard UI
189 │ Active │ 80 │ 1.0.2 │ Units of Measurement Common Library
190 │ Active │ 80 │ 1.0.8 │ Units of Measurement Implementation for Java SE
191 │ Active │ 80 │ 1.6.0 │ Commons Codec
192 │ Active │ 80 │ 3.3.0 │ Commons Net
193 │ Active │ 80 │ 4.2.3 │ Apache HttpClient OSGi bundle
194 │ Active │ 80 │ 4.2.3 │ Apache HttpCore OSGi bundle
195 │ Active │ 80 │ 3.1.0.7 │ Apache ServiceMix :: Bundles :: commons-httpclient
196 │ Active │ 80 │ 2.4.0 │ openHAB 1.x Compatibility Layer
197 │ Active │ 80 │ 1.1.1.201605111122 │ Swagger Provider
198 │ Active │ 80 │ 2.4.5 │ Jackson-annotations
199 │ Active │ 80 │ 2.4.5 │ Jackson-core
200 │ Active │ 80 │ 2.4.5 │ jackson-databind
201 │ Active │ 80 │ 2.4.5 │ Jackson-dataformat-XML
202 │ Active │ 80 │ 2.4.5 │ Jackson-dataformat-YAML
203 │ Active │ 80 │ 2.4.5 │ Jackson-module-JAXB-annotations
204 │ Active │ 80 │ 2.1.0 │ json-path
205 │ Active │ 80 │ 3.14.0 │ nrjavaserial
206 │ Active │ 80 │ 3.15.0.OH2 │ nrjavaserial
207 │ Active │ 80 │ 1.5.8 │ swagger-annotations
208 │ Active │ 80 │ 1.5.8 │ swagger-core
209 │ Active │ 80 │ 1.5.8 │ swagger-jaxrs
210 │ Active │ 80 │ 1.5.8 │ swagger-models
211 │ Active │ 80 │ 3.19.0.GA │ Javassist
212 │ Active │ 80 │ 2.2 │ json-smart
213 │ Active │ 80 │ 3.2.1 │ Apache Commons Lang
214 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Astro Binding
215 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Configuration UPnP Discovery
216 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Configuration USB-Serial Discovery
217 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Configuration USB-Serial Discovery Linux sysf Scanning
218 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Config Serial
219 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Serial Transport
220 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Serial Transport for RXTX
221 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Serial Transport extension for RXTX RFC2217
222 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome UPnP Transport Bundle
223 │ Active │ 75 │ 0.10.0.oh240 │ Eclipse SmartHome Exec Transformation Service
224 │ Active │ 75 │ 0.10.0.oh240 │ Eclipse SmartHome JavaScript Transformation Service
225 │ Active │ 75 │ 0.10.0.oh240 │ Eclipse SmartHome JSonPath Transformation Service
226 │ Active │ 75 │ 0.10.0.oh240 │ Eclipse SmartHome Map Transformation Service
227 │ Active │ 75 │ 0.10.0.oh240 │ Eclipse SmartHome RegEx Transformation Service
228 │ Active │ 75 │ 0.10.0.oh240 │ Eclipse SmartHome Scale Transformation Service
229 │ Active │ 75 │ 0.10.0.oh240 │ Eclipse SmartHome XPath Transformation Service
230 │ Active │ 75 │ 0.10.0.oh240 │ Eclipse SmartHome Xslt Transformation Service
231 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Basic UI, Fragments: 249
232 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome WebApp UI, Fragments: 250
233 │ Active │ 80 │ 0.10.0.oh240 │ Eclipse SmartHome Paper UI, Fragments: 253
234 │ Active │ 80 │ 2.5.1 │ JUPnP Library
235 │ Active │ 80 │ 1.13.0 │ openHAB Telegram Action
236 │ Active │ 80 │ 2.4.0 │ Amazon Echo Control Binding
237 │ Active │ 80 │ 1.13.0 │ openHAB Expire Binding
238 │ Active │ 80 │ 2.4.0 │ HarmonyHub Binding
239 │ Active │ 80 │ 2.4.0 │ Xiaomi Mi Smart Home Binding
240 │ Active │ 80 │ 2.4.0 │ Network Binding
241 │ Active │ 80 │ 2.4.0 │ Samsung Tv Binding
242 │ Active │ 80 │ 1.13.0 │ openHAB Weather Binding
243 │ Active │ 80 │ 2.4.0 │ YamahaReceiver Binding
244 │ Active │ 80 │ 2.4.0 │ ZWave Binding
245 │ Active │ 80 │ 1.13.0 │ openHAB Google Calendar
246 │ Active │ 80 │ 2.4.0 │ openHAB Cloud Connector Bundle
247 │ Active │ 80 │ 2.4.0 │ openHAB REST Documentation
248 │ Active │ 80 │ 1.13.0 │ openHAB InfluxDB Persistence bundle
249 │ Resolved │ 75 │ 2.4.0 │ openHAB Basic UI Fragment, Hosts: 231
250 │ Resolved │ 75 │ 2.4.0 │ openHAB Classic UI Fragment, Hosts: 232
251 │ Active │ 80 │ 2.4.0 │ HABmin User Interface
252 │ Active │ 80 │ 2.4.0 │ HABPanel User Interface
253 │ Resolved │ 75 │ 2.4.0 │ openHAB Paper UI Theme Fragment, Hosts: 233
254 │ Active │ 80 │ 0.9.10.v20160429-1435 │ reflections (wrap)
255 │ Active │ 80 │ 3.1.4 │ Stax2 API
256 │ Active │ 80 │ 1.5.8.v20160511-1038 │ swagger-jersey2-jaxrs (wrap)
257 │ Active │ 80 │ 1.13.0 │ openHAB MapDB Persistence Bundle
There is another way to achieve a similar result, that is by using the ipcamera binding and the create gif feature. I have been considering adding the ability to output an mp4 file instead of a gif.
The way it works is simple.
Use a rule to turn on the create gif switch when your door is opened.
When the file is created the binding turns the switch off and this can trigger a rule to send the email.
No timers or sleep needed as the binding handles this for you.
The threads you listed make up all the rest of OH. Almost all of them are created and used by the core of OH and the bindings. You have no control over them.
I have no idea.
Maybe. It depends on how they are implemented. If thread pools are being used then there is a fixed number of threads that get reused. Otherwise it is the job of what ever part of the code that created the thread to release it when it’s done.
You would need to hook a profiler up to a running OH instance and be familiar with the code to understand what is creating Threads under what circumstances.
It seems like the number of threads continues to grow:
On June 16th at 22:21 it was 317
On June 17th at 08:15 it was 309
On June 18th at 19:49 it was 335
On June 19th at 00:21 it was 341
On June 19th at 10:16 it was 338
Are there any bindings / add-ons out of the ones I am using, that are known to cause this?
On the contrary - are there ones who are known for sure to NOT cause this?
(so I can try removing the remaining ones, one by one, and see which one causes this)
Or is it not that of an issue, as long as the CPU usage is not going high? (which currently seems like it is not going high)
I believe telegram supports sending the animated gif so you can upgrade from a static picture to a moving one right away. If I was to add mp4 output i am not sure what abilities it would have, need to experiment when I get some spare time as to what is possible. Features like preroll before you ask to record may not be possible which is with the gif.
First of all, we don’t know that this is unusual and we don’t know that it is a problem. what does matter is the CPU utilization and RAM utilization.
There are no bindings that are known to leak threads nor is there any part of the core that is known to leak threads. That doesn’t mean there aren’t any, we just don’t know it if they do.