- Platform information:
- Hardware: CPUArchitecture/RAM/storage
- OS: what OS is used and which version
- Java Runtime Environment: which java platform is used and what version
- openHAB version: 2.5.11
- Issue of the topic: please be detailed explaining your issue
- Please post configurations (if applicable):
- Items configuration related to the issue
- Sitemap configuration related to the issue
- Rules code related to the issue
- Services configuration related to the issue
- If logs where generated please post these here using code fences:
Hello I have a problem which I could not solve so far
Ich have a item with format datetime but which does not have a value all the time
.items File
DateTime PZ_overlay_expiry "Overlay Expiry" { channel="tado:zone:a5022236:2:overlayExpiry" }
The target ist to store the value in a virtual item (to be displayed in happanel or paperui)
virtual.item File
String PZ_habpanel_expiry "[%s]"
As the value of the item ist not a real value all the time
log:
2021-01-09 10:08:37.394 [vent.ItemStateChangedEvent] - PZ_overlay_expiry changed from NULL to UNDEF
2021-01-09 18:33:15.763 [vent.ItemStateChangedEvent] - PZ_overlay_expiry changed from UNDEF to 2021-01-09T18:33:04.000+0000
2021-01-09 19:11:53.060 [vent.ItemStateChangedEvent] - PZ_overlay_expiry changed from 2021-01-09T18:46:10.000+0000 to UNDEF
I added some if condition and tried various rules, but I could not succeed
rule
rule "Temp_Patrickzimmer_Umbau"
when
Item PZ_overlay_expiry changed
then
if (PZ_overlay_expiry.state != NULL || PZ_overlay_expiry.state != UNDEF) {
PZ_habpanel_expiry.postUpdate(String::format("%1$tH:%1$tM", PZ_overlay_expiry.state))}
end
// I also tried in the then condition:
if ...{
var String tmp = PZ_overlay_expiry.state.format("%1$tH:%1$tM")
PZ_habpanel_expiry.postUpdate(tmp)}
But I get errors
2021-01-09 20:13:35.778 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Temp_Patrickzimmer_Umbau': H != org.eclipse.smarthome.core.library.types.DateTimeType
Error of second variant
2021-01-09 20:12:05.562 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Temp_Waschkueche_Umbau': H != java.lang.String
what is wrong ?
Could solve it with help of REST
rule
...
if (PZ_overlay_expiry.state != NULL && PZ_overlay_expiry.state != UNDEF) {
PZ_habpanel_expiry.postUpdate(PZ_overlay_expiry.state.format("%1$tH:%1$tM"))}
else PZ_habpanel_expiry.postUpdate("")
...