Skip to content

Commit

Permalink
[Main UI] Added Badge for BatteryLow warning (#1063)
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Weitkamp <[email protected]>
  • Loading branch information
cweitkamp authored May 21, 2021
1 parent c6d707c commit c71db73
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const OhLocationCardParameters = () => new WidgetDefinition('oh-location-
pb('disableBadges', 'Disable badges', 'Do not examine items to display badges - can help with performance if you don\'t need them.'),
pt('badges', 'Enabled badges', 'Select the badges you wish to show in the header of the card. Display all if none are selected.')
.o([
{ value: 'battery', label: 'Low Battery Warning' },
{ value: 'lights', label: 'Lights On' },
{ value: 'windows', label: 'Open Windows' },
{ value: 'doors', label: 'Open Doors' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default {
return {
badgeConfigs: {
alarms: { icon: 'f7:exclamationmark_triangle_fill' },
battery: { icon: 'f7:battery_25', state: 'on' },
lights: { icon: 'oh:lightbulb' },
windows: { icon: 'oh:window', state: 'open' },
doors: { icon: 'oh:door', state: 'open' },
Expand Down Expand Up @@ -70,6 +71,10 @@ export default {
query () {
let direct, equipment, allPoints, points
switch (this.type) {
case 'battery':
direct = findPoints(this.element.properties, 'Point_Status_LowBattery', true)
if (direct.length) return direct
return findPoints(allEquipmentPoints(this.element.equipment), 'Point_Status_LowBattery', true)
case 'lights':
direct = findPoints(this.element.properties, 'Point_Control', true, 'Property_Light')
if (direct.length) return direct
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<generic-widget-component :context="childContext(slotComponent)" v-for="(slotComponent, idx) in context.component.slots.glance" :key="'glance-' + idx" @command="onCommand" />
</div>
<div class="location-stats margin-top" :class="config.invertText ? 'invert-text' : ''" v-if="!config.disableBadges">
<span v-for="badgeType in ['alarms', 'lights', 'windows', 'doors', 'garagedoors', 'blinds', 'presence', 'lock', 'climate', 'screens', 'projectors', 'speakers']" :key="badgeType">
<span v-for="badgeType in ['alarms', 'battery', 'lights', 'windows', 'doors', 'garagedoors', 'blinds', 'presence', 'lock', 'climate', 'screens', 'projectors', 'speakers']" :key="badgeType">
<status-badge v-if="!config.badges || !config.badges.length || config.badges.indexOf(badgeType) >= 0"
:store="context.store" :element="element" :type="badgeType" :invert-color="config.invertText" :badgeOverrides="badgeOverrides" />
</span>
Expand Down

0 comments on commit c71db73

Please sign in to comment.