Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Main UI] Added Badge for BatteryLow warning #1063

Merged
merged 3 commits into from
May 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Member

@ghys ghys May 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just realizing now that lines 75 & 76 here might even be unnecessary - these prioritize points directly under the Location over those under an Equipment... but having LowBattery points directly under a Location makes little sense I think, you would expect batteries to be under Equipment all the time?

Edit: Never mind, let's be open-minded, some locations might have batteries, whataver that means :)

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