Skip to content

Commit

Permalink
Refactored reading & updating settings
Browse files Browse the repository at this point in the history
  • Loading branch information
harriedegroot committed Feb 26, 2019
1 parent d0677da commit 8503dfa
Show file tree
Hide file tree
Showing 10 changed files with 446 additions and 308 deletions.
8 changes: 4 additions & 4 deletions DeviceManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ class DeviceManager {
return device;
if (this.deviceNames && this.deviceNames.has(device))
return this.deviceNames.get(device);
if (this.deviceTopics && this.deviceTopics.has(device))
return this.deviceTopics.get(device);
if (this.deviceTopics && this.deviceTopics.has(normalize(device)))
return this.deviceTopics.get(normalize(device));
} else if (typeof device === 'object') {
if (device.id)
return device.id;
if (device.name) {
if (this.deviceNames && this.deviceNames.has(device.name))
return this.deviceNames.get(device.name);
if (this.deviceTopics && this.deviceTopics.has(device.name))
return this.deviceTopics.get(device.name);
if (this.deviceTopics && this.deviceTopics.has(normalize(device.name)))
return this.deviceTopics.get(normalize(device.name));
}
}
}
Expand Down
1 change: 1 addition & 0 deletions EventHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class EventHandler {
}
}

unsubscribe(callback) { return this.remove(callback); }
remove(callback) {
this._listeners = this._listeners.filter(c => c !== callback);
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Furthermore it provides an interface to read the full system state & and allows

## What can it be used for?
Some of the many possibilities:
- Integrate with other home automation systems: [OpenHab](https://www.openhab.org/), [Home Assistant](https://www.home-assistant.io/), [Domiticz](http://www.domoticz.com/), etc.
- Integrate with other home automation systems: [OpenHab](https://www.openhab.org/), [Home Assistant](https://www.home-assistant.io/), [Domoticz](http://www.domoticz.com/), etc.
- Create custom dashboards: [TileBoard](https://community.home-assistant.io/t/tileboard-new-dashboard-for-homeassistant/57173), [HABPanel](https://www.openhab.org/docs/configuration/habpanel.html), [Node RED Dashboard](https://flows.nodered.org/node/node-red-dashboard), etc.
- Create advanced flows and logic: [Node RED](https://nodered.org/), etc.
- Use native mobile apps (3rd party): [MQTT Dash](https://play.google.com/store/apps/details?id=net.routix.mqttdash), etc.
Expand Down
46 changes: 25 additions & 21 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,22 @@ BUGS:
- [BUG] client/hub registration?

Settings:
! HASS settings (enable disable discovery + topic root)
! seperate root topics (homie, HASS, system state, custom, etc.)
! Make class constants configurable
! Split hiding of controls & applying default (protocol) settings
! settings default vs disabled controls
! settings restore app defaults button
! [CHECK] initial settings @ clean install
! Clear command & system state topics when changeing topic
! Check 'App' initilaized (prevent settings crash)
! Update Instructions
! [CHECK] Load deviceId @ first load
! [CHECK] initial settings @ clean install
! Allow all chars for DeviceId, normalize for topics (based on setting)
! Inject deviceId (normalized) in topics
! [CHECK] broadcast on settings changes (if needed)
! [CHECK] en.json translations
- optional normalization for custom protocol
- system info topic configurable
- Enable/disable all devices
- display broadcast progress (loader)
- Birth & Last will topics + messages
- enable/disable set command handler
- Disable device capabilities
- Show number of messages per device
- Display number of messages in queue (fill 100% === number of devices)
- Seperate call for device enable/disable

HASS:
! Enable/disable (broadcast / clear messages)
! Clear all HASS messages (Register all topics &clear @ settings topic change)
! Color temperature (read & write)
! Update correct HSV values when setting one of the values (color topic)
! Implement full reload @ settings change
! Clear all HASS messages
- Set numeric values? input_number: https://www.home-assistant.io/components/input_number/?
- Remaining device types (Alarm control panels, Binary sensors, Cameras, Covers, Fans, HVACs, Lights, Locks, Sensors, Switches, Vacuums)
- thermostat modes
Expand All @@ -52,6 +37,7 @@ Homie:
- Button-press & non-retained messages?

App:
! Adjust documentation for HA Discovery & changed settings (readme)
- [Check] shutdown procedure
- [Check] Refresh devices on device/zone changes + Broadcast
- Uninstall app => unsubscribe from topics on MQTT lient
Expand All @@ -63,7 +49,7 @@ Homey:

Discovery (auto discover external devices):
- Implement Homie discovery
- Implement HASS Discovery
- Implement HA discovery
- Create virtual devices from MQTT discovery

Commands:
Expand All @@ -78,13 +64,13 @@ Commands:

System info:
- Publish system info on seperate topics (i.s.o. json)

- (All) Prometheus functionality


======= DONE =======
- Normalize device name
- Fix getDeviceName for homey 1.5.13
- MQTT discovery (see OpenHAB / Domiticz)
- MQTT discovery (see OpenHAB / Domoticz)
- Implement Homie convention (Homey v1.5.13)
- Homie Convention for Homey v2.0
- Normalization BUG
Expand Down Expand Up @@ -134,3 +120,21 @@ x test internal MQTT client ('socket hang up' fix? duplicate mem usage, config &
- HASS enable device => send discover config
- HASS Keep track of device topics & remove messages from queue when disabling device
- Send empty messages to clear devices
- [BUG] set command not working when deviceId or topic root is empty
- HASS settings (enable disable discovery + topic root)
- seperate root topics (homie, HASS, system state, custom, etc.)
- Make class constants configurable
- Re-factor settings
- settings restore app defaults button
- [CHECK] Load deviceId @ first load
- Allow all chars for DeviceId, normalize for topics (based on setting)
- Inject deviceId (normalized) in topics
- Skip reloading when changing birth & last will messages
- HASS: Implement full reload @ settings change
- optional normalization for custom protocol
- system info topic configurable
- Birth & Last will topics + messages
- enable/disable set command handler
- HASS: Enable/disable
x Settings: Split hiding of devices & applying default (protocol) settings
- [CHECK] broadcast on settings changes (if needed)
Loading

0 comments on commit 8503dfa

Please sign in to comment.