I have an openhab chart where I plot states of all of my lights which are all dimmers and they plot well. I want to add to that chart with two open/closed sensors and a switch. Since their states are OPEN/CLOSED & ON/OFF rather than numerical, I can’t seem to figure out how to plot these on a chart without creating secondary items and rules to set the secondary item to 1 or 0 based on OPEN/CLOSED or ON/OFF and plotting those instead. Is this possible?
Just change the type of the switch item to numeric and you got the by desired behavior
The default way the oh charts show ON/OFF is by using the eCharts markarea feature. This won’t draw a line, but it will color in the times when the item is in the positive state:
I don’t know if you can add it using the wizard yet, but it’s easy to add on the code page. Just create a blank time series (don’t give the timeseries an item) and then add the markarea
slot and oh-mark-area
component to that series and put the item name in there:
series:
- component: oh-time-series
config:
gridIndex: 0
name: Series 1
type: line
xAxisIndex: 0
yAxisIndex: 0
slots:
markArea:
- component: oh-mark-area
config:
item: My_OnOff_Item
name: My Item
If you’re really intent on getting a line instead you can come close by adding an itemStyle
config to the mark area component:
Using that you can make the areas themselves transparent and draw a border around the boxes instead. It won’t be exact because the lines wont connect along the x-axis baseline, but it will be really close.