Problems getting values from rules via items to BasicUI

Hi all

Have a really simple setup, and have run into some problems in getting values from my rules to be shown in my BasicUI.

I just got a motion detector sensor, and I was going to start by just accumulating the number and presenting in the GUI.

.items

Number Movements

.rules

var m=0
rule "Add a Movement"
when
  Item zwave_device_98f1144c_node4_alarm_motion changed from OFF to ON
then
  m=m+1
  Movements.sendCommand(m)
end

.sitemap

Text item=Movements label="Rörelser: [%.0f]"

In my event log file, I can see this:

2018-05-10 15:43:24.611 [vent.ItemStateChangedEvent] - zwave_device_98f1145c_node4_alarm_motion changed from OFF to ON
2018-05-10 15:43:25.162 [ome.event.ItemCommandEvent] - Item 'Movements' received command 1

How come it doesn’t show up in the BasicUI?
I have other similar rules (or maybe the rues work, but not the commands?), that have worked before, but have now stopped working, that looks like this:

rule "Olof connects"
when
  Item Presence_Mobil_Olof changed from OFF to ON
then
  Olof_ansluten.sendCommand(now.toString)
end

This rule used to present a date and time for when I last connected to the wifi, but now it doesn’t show up anymore. Just like the motion detection, it seems to work all the way up to actually showing the value in the BasicUI.

Any ideas?

/GC

For items to appear in the basicUI or the classsicUI, they need to be delared in a sitemap:

https://docs.openhab.org/configuration/sitemaps.html

Thanks, but I don’t understand.
The Movements item I use in the rule is in the sitemap as I posted.
The item Olof_ansluten also exist in the sitemap even though I didn’t show it in the post.
The text shows up, but the value doesn’t.
The Olof_ansluten used to work, but it doesn’t anymore. I’m not sure if it stopped working when I went from v2.0 to 2.2 a couple of days ago or earlier.

/GC

Maybe off-topic, but I often (most of the time) need to refresh my browser to get any updates or even the status of contacts displayed correctly. Another way to try to get more details is to add logInfo commands and see in your logs what your rules actually do.

+1 for refreshing the browser to display updates correctly, but for devices app (android) it is instantly get updated OR try restarting your server.

here’s how I setup my motion sitemap/item

.sitemap
Text item=motionSensor label="Motion Sensor" valuecolor=["red"] icon="sensor"
.items
Switch motionSensor "Motion Sensor [MAP(motion.map):%s]" <motion> { mqtt="<[mosquitto:cmnd/Wemos-PIR/POWER4:state:default]" } 
.map (transform) 
ON=MOTION DETECTED!
OFF=STILL

Hope this help.

If your item’s label has a state presentation you have to define it in the items file.
In sitemap, label only alters the text part of the label.
So, define your item like this:

Number Movements "Rörelser: [%.0f]"

Thanks for the input.
Still no luck, unfortunately.

I’ve tried both with %d and %f and %s, but I’m not quite sure what to use.
Is it like plain old C, or how should one think regarding that?

/GC

Remove the label parameter in the sitemap
It is defined in the item and you don’t need it
The sitemap one overrides the one in the item definition and you won’t see updates
You can also remove the icon parameter as you have defined it as <motion> in the item

.sitemap Text item=motionSensor valuecolor=["red"]

I define as much as possible in the item (Sitemap specific parameters like valuecolor obviously have to stay in the sitemap)

Oh God, this is really anoying.
Still no luck, even with all text to be presented defined in the items file.
And regarding just the text part of a label being updated when defined in the sitemap file, is that a new behaviour? I know for sure that my mobile ”presence” item has shown up with a datetime in the gui, even with the way I declared them before.

/GC

Can you show your log when the PIR is triggered, please?

Ok, so the latest versions of my files (limited to one particular item):

.items

Number Movements "Rörelser: [%.0f]" <motion>

.sitemap

Text item=Movements

.rules

rule "Add a Movement"
when
  Item zwave_device_98f1144c_node4_alarm_motion changed from OFF to ON
then
  m=m+1
  Movements.sendCommand(m)
end

log entry when me passing the sensor:

2018-05-11 08:13:45.500 [vent.ItemStateChangedEvent] - zwave_device_98f1144c_node4_alarm_motion changed from OFF to ON
2018-05-11 08:13:45.554 [ome.event.ItemCommandEvent] - Item 'Movements' received command 3

How should the String vs Number, %s vs %.0f and so on effect the outcome?
I’ve tried a lot of combinations since it’s not obvious to me how a counter should be handled.

Thanks, again.

/GC

For the formating as display of integers:

Number Movements "Rörelser: [%d]" <motion>

It should work, even what you showed me should work.
What browser are you using and have you checked the autoupdate settings?

Well, I have tried Chrome on PC and my Android phone, as well as on the iPad.
I can see that it refreshes, since I’ve broken things completely several times…

As I said, I have other items/rules that suddenly has stopped working as well, my “Olof Connects” rule in my first post for example.

What hardware are you using?

I’m using an RPi3 B with an Aeotec z-stick gen 5, and the motion sensor is from Fibaro.
I just can’t see that there is anything but a silly detail that causes this, since the event log really says that my “end item” Movements actually gets the command…

But you said that other things also have stopped working suddenly. How long have you had that SD card in the PI?

I actually suspected you where getting to that comment now. :grinning:
And the answer is “quite a while”, I don’t know exactly.
What I do know is that the uptime on the Pi were 238 days a couple of days ago…

Yes, but the other things that stopped working is sort of the same thing.
It’s three items that suddenly won’t display the text they’re given via a sendCommand() in the rules file.