Skip to content

Commit

Permalink
Add option for room coloring
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Litzenburger committed Mar 20, 2022
1 parent 2e2d964 commit b887dd9
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 29 deletions.
9 changes: 9 additions & 0 deletions MMM-BoschSmartHome.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
padding: 0.5em;
margin-bottom: 0.5em;
}
.bsh-room-wrapper.bsh-airquality-GOOD {
background-color: rgba(50, 205, 50, 0.5);
}
.bsh-room-wrapper.bsh-airquality-MEDIUM {
background-color: rgba(255, 215, 0, 0.5);
}
.bsh-room-wrapper.bsh-airquality-BAD {
background-color: rgba(255, 0, 0, 0.5);
}
.bsh-room-title {
color: #fff;
display: flex;
Expand Down
4 changes: 2 additions & 2 deletions MMM-BoschSmartHome.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ If you like this module and want to thank, please rate this repository with a st
width: "340px",
displayRoomIcons: false, // Default: false
hideComponents: {}, // See example below. Default: {}
colorizeRoomWithAirQuality: false, // Colorizes room tiles in red/orange/green depending on combined air quality. Only works with Twinguard
roomOrder: [], // Manually set the room order by a list of room names, e.g. ["Livingroom", "Bedroom", "Kitchen"]
airquality: {
purity: "bar", // one of [tile, bar, donut, none]
Expand Down
6 changes: 3 additions & 3 deletions node_helper.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 12 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mmm-bosch-smart-home",
"version": "1.3.0",
"version": "1.4.0",
"description": "A client interface for the Bosch Smart Home System on the MagicMirror² platform.",
"main": "MMM-BoschSmartHome.js",
"repository": {
Expand All @@ -14,7 +14,8 @@
},
"homepage": "https://github.com/jalibu/MMM-BoschSmartHome#readme",
"dependencies": {
"bosch-smart-home-bridge": "^1.0.0"
"bosch-smart-home-bridge": "^1.0.0",
"rxjs": "^7.5.5"
},
"scripts": {
"build": "rollup -c",
Expand Down
10 changes: 6 additions & 4 deletions src/backend/BshClient.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as Log from 'logger'
import * as BSHB from 'bosch-smart-home-bridge'
import * as fs from 'fs'
import { lastValueFrom } from 'rxjs'
import { Config } from '../types/Config'
import { Device } from '../types/Device'
import { Service } from '../types/Service'
Expand Down Expand Up @@ -39,7 +40,8 @@ export default class BshbClient {
.withLogger(this.logger)
.build()

await bshb.pairIfNeeded(this.config.name, this.config.identifier, this.config.password).toPromise()
await lastValueFrom(bshb.pairIfNeeded(this.config.name, this.config.identifier, this.config.password))

this.client = bshb.getBshcClient()

Log.info('Established connection to BSHB')
Expand All @@ -56,7 +58,7 @@ export default class BshbClient {
}

if (!this.rooms) {
const { parsedResponse: rooms } = await this.client.getRooms().toPromise()
const { parsedResponse: rooms } = await lastValueFrom(this.client.getRooms())

// Change room order if configured
this.rooms = rooms.sort((a: Room, b: Room) => {
Expand All @@ -70,13 +72,13 @@ export default class BshbClient {
parsedResponse: devices
}: {
parsedResponse: Device[]
} = await this.client.getDevices().toPromise()
} = await lastValueFrom(this.client.getDevices())

const {
parsedResponse: services
}: {
parsedResponse: Service[]
} = await this.client.getDevicesServices().toPromise()
} = await lastValueFrom(this.client.getDevicesServices())

for (const device of devices) {
device.services = services.filter((service) => service.deviceId === device.id)
Expand Down
1 change: 1 addition & 0 deletions src/frontend/Frontend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Config } from '../types/Config'

Module.register<Config>('MMM-BoschSmartHome', {
defaults: {
colorizeRoomWithAirQuality: false,
mocked: false,
debug: false,
host: '192.168.0.150',
Expand Down
Loading

0 comments on commit b887dd9

Please sign in to comment.