-
Platform information:
- openHAB version: 4.04
-
Issue
I have developed an addon for PVPC (Spanish electricity market for small consumers). The add-on publishes, amongst other things, three channels mapped to items: -
Spanish_Electricity_Market_PVPC_Rate_API_Thing_PVPC_Rate_Now (Number:Energy)
-
Spanish_Electricity_Market_PVPC_Rate_API_Thing_PVPC_Is_Rate_Cheap_Now (Switch ON/OFF)
-
Spanish_Electricity_Market_PVPC_Rate_API_Thing_PVPC_Is_Rate_Below_Average_Now (Switch ON/OFF)
From this data I would like to create a bar graph of the PVPC_Rate_Now whereby the color is green when Is_Rate_Cheap_Now is true (ON), orange when Is_Rate_Below_Average_Now is true and red otherwise. In a first step to differentiate between cheap rates and “other” rates, I came up with:
config:
label: PVPC Daily Chart
period: D
slots:
grid:
- component: oh-chart-grid
config: {}
xAxis:
- component: oh-time-axis
config:
gridIndex: 0
yAxis:
- component: oh-value-axis
config:
gridIndex: 0
name: Price (KWh)
series:
- component: oh-time-series
config:
name: Rate
gridIndex: 0
xAxisIndex: 0
yAxisIndex: 0
type: bar
item: Spanish_Electricity_Market_PVPC_Rate_API_Thing_PVPC_Rate_Now
color: '=
items.Spanish_Electricity_Market_PVPC_Rate_API_Thing_PVPC_Is_Rate_Cheap_Now.state
=== "ON" ? "Green" : "Red"'
on: true
But it does not yield the desired outcome: the color does vary, but is determined by the last/current state of PVPC_Is_Rate_Cheap_Now and not by the corresponding Is_Rate_Cheap_Now value matching with the PVPC_Rate_Now at the given hour. I have tried adding PVPC_Is_Rate_Cheap_Now as a (hidden) series itself, but it also does not help. Somehow I need to refer to the Is_Rate_Cheap_Now which corresponds to the matching (historical) hourly rate, but haven’t found the proper syntax. I also read the Apache Echarts docs but the examples always contain static data. All hints appreciated…