Add CO2 measurement badge to location card (#2068)

Closes #2067.

This PR introduces CO2 measument badge to the location card in MainUI.
It is same logic as other measuments badges, i.e. average from items
with Measurement and CO2 Semantic tags.

---------

Signed-off-by: David Kesl <davidkesl76@gmail.com>
pull/2075/head
Davek145 2023-09-16 18:49:17 +02:00 committed by GitHub
parent 2f7b1d7823
commit e1d90f706a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 1 deletions

View File

@ -100,6 +100,7 @@ A card showing model items in a certain location
<PropOption value="speakers" label="Speakers/AV Receivers Powered On" />
<PropOption value="temperature" label="Average Temperature (+ Setpoint)" />
<PropOption value="humidity" label="Average Humidity" />
<PropOption value="co2" label="Average CO2" />
<PropOption value="luminance" label="Average Luminance" />
</PropOptions>
</PropBlock>

View File

@ -115,6 +115,7 @@ export const OhLocationCardParameters = () => new WidgetDefinition('oh-location-
{ value: 'speakers', label: 'Speakers/AV Receivers Powered On' },
{ value: 'temperature', label: 'Average Temperature (+ Setpoint)' },
{ value: 'humidity', label: 'Average Humidity' },
{ value: 'co2', label: 'Average CO2' },
{ value: 'luminance', label: 'Average Luminance' }
], true, true)
])

View File

@ -34,6 +34,7 @@ export default {
badgeConfigs: {
temperature: { icon: 'f7:thermometer', unit: '°' },
humidity: { icon: 'f7:drop', unit: '%' },
co2: { icon: 'f7:wind', unit: 'ppm' },
luminance: { icon: 'f7:sun_min', unit: 'lx' }
}
}
@ -59,6 +60,10 @@ export default {
direct = findPoints(this.element.properties, 'Point_Measurement', true, 'Property_Humidity')
if (direct.length) return direct
return findPoints(allEquipmentPoints(this.element.equipment), 'Point_Measurement', true, 'Property_Humidity')
case 'co2':
direct = findPoints(this.element.properties, 'Point_Measurement', true, 'Property_CO2')
if (direct.length) return direct
return findPoints(allEquipmentPoints(this.element.equipment), 'Point_Measurement', true, 'Property_CO2')
case 'luminance':
direct = findPoints(this.element.properties, 'Point_Measurement', true, 'Property_Light')
if (direct.length) return direct

View File

@ -14,7 +14,7 @@
</span>
</div>
<div class="location-stats margin-top-half" v-if="!config.disableBadges">
<span v-for="badgeType in ['temperature', 'humidity', 'luminance']" :key="badgeType">
<span v-for="badgeType in ['temperature', 'humidity', 'co2', 'luminance']" :key="badgeType">
<measurement-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>