Chart shows float values instead of integers

mqtt
charts
Tags: #<Tag:0x00007f212a524c78> #<Tag:0x00007f212a524b10>

(mikael_trieb) #1

I have an mqtt-item

Number MotionSensor "Motion [%d]"  <contact>  (Office)  {mqtt="<[mosquitto:basetopic/motion:state:default]"}

the data is displayed in a chart as

Chart item=MotionSensor period=D refresh=3000

The payload of the mqtt message is “0” or “1”.
But I can’t figure out why the data in the chart is displayed as somekind of float value?


(Rich Koshak) #2

What persistence are you using?


(mikael_trieb) #3

rrd4j

MotionSensor : strategy = everyChange, everyMinute, restoreOnStartup

(Rich Koshak) #4

OK, rrd4j could be a source of some of this for older data but usually it takes half a day or longer before it starts decimating the data and replacing it with averages. So that doesn’t explain why the recent data is not working as expected.

If you look in events.log can you confirm that the MotionSensor Item is indeed only being set to 1 and 0? If it is only ever going to be a 1 or a 0 why not use a Contact or Switch Item?


(mikael_trieb) #5

events.log look ok I think, the only values are 0.00 and 1.00.

2016-11-02 07:33:55 - MotionSensor state updated to 0.00
...
2016-11-03 10:44:49 - MotionSensor state updated to 1.00

(Rich Koshak) #6

So your Item and Chart are using the Item MotionSensor but these logs are for SensorMotion. Have you changed the name or do you perhaps have two similarly named Items and mixed them up?


(mikael_trieb) #7

Should be MotionSensor here too. (I’ve changed the name from its real)


(Rich Koshak) #8

In that case I’m at a loss. The behavior is not expected. What I would try:

  • Use a Switch or Contact and see if that makes a difference
  • Use db40 (if on OH 1.8) or SQLite instead of rrd4j and see if that makes a difference
  • Punt and upgrade to the Influx+Grafana solution

(mikael_trieb) #9

Changing type to Switch gives me the following warning:

given new state is NULL, couldn't post update for 'MotionSensor'

The item is now defined as:

Switch MotionSensor "Motion [%d]" <switch> (Office) {mqtt="<[mosquitto:basetopic/motion:state:default]"}

(Rich Koshak) #10

It may not be able to parse the float into an int properly. You could try a MAP transform instead of default to map 1.00 to ON and 0.00 to OFF.