Hello,
currently I’m learning how to create own widgets in openHAB. Therefore, I tried to configure a lightning switch widget with an optional dimmer popup.
uid: widget_lightdimmer_v1.0
tags:
- light
- dimmer
props:
parameters:
- description: Item Name
name: itemname
required: true
type: TEXT
- context: item
description: Dimmer Item
label: Item
name: dimmeritem
required: true
type: TEXT
parameterGroups: []
timestamp: Dec 3, 2022, 4:48:54 PM
component: f7-card
config:
expandable: true
swipeToClose: false
backdrop: true
noShadow: true
class:
- card-expandable-animate-width
style:
max-height: 90px
min-width: 300px
margin: 5px
slots:
default:
- component: oh-button
config:
iconF7: gear
iconSize: 25px
color: black
style:
position: absolute
top: 0
right: 0
padding-top: 30px
padding-bottom: 65px
z-index: 999
class:
- cell-open-button
- card-opened-fade-out
- component: f7-card-content
slots:
default:
- component: oh-button
config:
iconF7: xmark_circle_fill
iconSize: 25px
color: black
style:
position: absolute
top: 0
right: 0
padding-top: 30px
padding-bottom: 65px
z-index: 999
class:
- card-opened-fade-in
- cell-close-button
- card-close
- component: f7-block
config:
class:
- no-padding
- card-prevent-open
style:
margin: 0px
height: 135px
slots:
default:
- component: f7-row
slots:
default:
- component: f7-col
config:
style:
width: 30%
slots:
default:
- component: oh-button
config:
iconF7: lightbulb_fill
iconSize: 65px
color: white
iconColor: "=items[props.dimmeritem].state != '0' ? 'yellow' : 'gray'"
action: toggle
actionItem: =props.dimmeritem
actionCommand: ON
actionCommandAlt: OFF
class:
- card-prevent-open
style:
padding-top: 0px
height: 85px
- component: f7-col
config:
style:
width: 70%
slots:
default:
- component: Label
config:
text: '=props.itemname ? props.itemname : "Bitte Namen eingeben."'
class:
- card-prevent-open
style:
padding-top: 15px
padding-left: 5px
font-size: 15px
font-weight: 650
- component: Label
config:
text: "=items[props.dimmeritem].state != '0' ? 'Eingeschalten' : 'Ausgeschalten'"
class:
- card-prevent-open
style:
padding-left: 5px
- component: f7-block
config:
class:
- card-prevent-open
- card-content-padding
slots:
default:
- component: f7-row
slots:
default:
- component: f7-col
config:
style:
padding-left: calc(50% - 100px)
slots:
default:
- component: oh-slider
config:
title: Leuchtintensität
vertical: 1
label: true
scale: true
releaseOnly: true
item: =props.dimmeritem
style:
width: 200px
height: 400px
--f7-range-bar-active-bg-color: rgba(255,204,0,255)
--f7-range-bar-size: 150px
--f7-range-bar-border-radius: 20px
--f7-range-knob-color: transparent
--f7-range-label-bg-color: white
--f7-range-knob-size: 0px
--f7-range-label-border-radius: 5px
--f7-range-label-font-size: 25px
--f7-range-label-font-weight: 400
--f7-range-label-padding: 0px 2px
--f7-range-label-size: 40px
--f7-range-label-text-color: black
On desktops it looks like:
If the light is dimmable, it’s possible to control the light level with this little gear icon. By clicking on this gear icon, an additional popup will appear:
So far so good. Unfortunately, the popup looks on iPhones (with this little notch on top) a bit misplaced.
To mitigate this issue, I have some ideas, but I don’t know how to implement them:
- Detect if the popup has been opened and move the content (text and icon) a little bit down
- Don’t open the popup on smartphones in full screen (don’t know if this is even possible)
Do you have a better idea, or do you know how to implement one of my ideas into this widget?
Your help is appreciated!