[][src]Crate new_home_application

New Home Application

This is the New Home Application framework used to create application for the New Home project. The New Home project aims to make a Smart Home (more or less) simple for people who are willing to tinker a bit around with electronics and software (Or knows someone who is).

For a more detailed description on what this project exactly is, for who it is and how to setup a "New Home" follow the documentation in the main project


To implement a Method it is recommended to use the new_home_application_macro crate.

To get the whole application up and running you will have to build the application using the ApplicationBuilder. This will help you configure the application and get it running. For a more detailed implementation on how to use the builder you can take a look into the examples/example-application.rs file.


In order to be fully complient with the New Home system and especially with the Core and UI, you will have to create implement some methods. These methods are:

get_scriptCoreProvides a JavaScript file. Has to be in the message.script key.
device_actionUIProvides the info on what should happen when clicking on the device button in the room/device overview.
config_rootUIProvides the info on what should happen when the application button is clicked.


An example on how to implement a method with the macro is in the new_home_application_macro crate.

An example on how to implement the same structure is in the examples/example-method.rs

The short version (without the main part) is also here:

use serde_json::Value;
use new_home_application::method::{MethodCallable, Method, MethodError};
use new_home_application::communication::{MethodCall, MethodResult};
use std::collections::HashMap;

struct ExampleMethod {
    pub word: Value,

    pub uppercase: Value,

impl Method for ExampleMethod {
    fn name(&self) -> String {

    fn description(&self) -> String {
        String::from(r#"Can convert a word into uppercase"#)

    fn help(&self) -> String {
        String::from(r#"Will convert the word to uppercase if uppercase flag is set"#)

    fn set_arguments(
        &mut self,
        arguments: HashMap<String, Value>,
    ) -> Result<(), MethodError> {
        match arguments.get("word") {
            Some(value) => {
                self.word = value.clone();
            _ => {
                return Err(MethodError::message(
                    "Missing value for word",
        self.uppercase = arguments

impl MethodCallable for ExampleMethod {
    fn call(&mut self, _: MethodCall) -> MethodResult {

This is the same example the derived (macro) one and by that I mean, that this is the cargo expand result.



In this module there is the main framework/application part. All the logic for receiving data and calling methods is stored here.


The communication module contains all the structs used during communication with the core and/or the client at the end of the UI.


This module contains all required structs to implement a method