Hello,
I’m trying to play with OH3 and I stuck in the simple custom widget
I have AirQuality Binding which and related Color type Item LocalAirQuality_AQIColor.
I try to use value of this Item as the background color in custom widget. Unfortunately with no success
uid: widget_2366c2df3a
tags: []
props:
parameters:
- description: A text prop
label: Prop 1
name: prop1
required: false
type: TEXT
- context: item
description: An item to control
label: Item
name: item
required: false
type: TEXT
- context: item
description: AQI color item
label: Item
name: ColorValue
required: false
type: TEXT
parameterGroups: []
timestamp: Jan 9, 2021, 8:06:55 PM
component: f7-card
config:
style:
max-height: 200px
background: '"rgb(" + =items[props.ColorValue].state + ")"'
title: '=(props.item) ? "State of " + props.item : "Set props to test!"'
footer: =props.prop1
content: =items[props.item].displayState || items[props.item].state
Could somebody provide me a sample how to us it correctly?
I know, it’s a while ago, but I struggled with the same issue that you did, and I wanted use a set of colors that were consistent with other widgets, so I chose:
I came across this post while I was trying to use a color from a color picker as background color of a button.
Maybee thats usefull for somebody else.
The code is converting a HSB color value from the color picker to a HSL color value used in css.
It is based on the following Algroithem: HSL and HSV - Wikipedia
Because it is not possible to use variables (at least I don’t know how) the code got very uggly, but it is working.