home-assistant-js
JavaScript backend in NuclearJS for Home Assistant. Used by the Home Assistant Polymer frontend.
To see it in action, check out the demo. Debug mode has been enabled for NuclearJS so make sure to open your developer tools!
Cool stuff
In this section some of the cool stuff that I built on top of NuclearJS.
The Rest API module holds the data that is being retrieved from the server. The Rest API module is based on the NuclearJS Rest API example. This module is the foundation for the entity, event and service modules. Each of these implement their own model, based on the ImmutableJS Record object.
The more-info module powers a UI component that shows more information about an entity. The only information that is stored in the store is the ID of the current selected entity. By using composable getters it is able to automatically serve the correct information when an entity is selected or updated. Another nice use of getters can be seen in the config module which allows the dynamic creation of getters to observe if a certain component is loaded.
The stream module streams all events from the Home Assistant server using the HTML5 EventSource API. It dispatches the same actions for received events as when the data would have been loaded using REST api calls.
The voice module allows the user to send voice commands to Home Assistant. The voice is being translated to text using the HTML5 SpeechRecognition API. (Only available in Chrome)
The preferences module tracks certain parts of the global app state and stores them in local storage to persist them between sessions. The preferences object is queried on launch of the application after which startSync()
is called to keep the local storage synced with the global app state.
The navigation module keeps track of which part of the UI is currently visible. It will sync this state to the URL using the HTML5 History API. This allows the users to bookmark a current page in the application and enable the use of browser back and forward buttons. (Not available in Demo mode)
Home Assistant JS can be compiled with the DEMO flag enabled. This will override the callApi()
method to return demo data. The Webpack define plugin is used to convert an environment variable to be available in JS. UglifyJS is used to strip out the demo parts when the demo mode is disabled so it will never ship to production.