Giter Club home page Giter Club logo

owfs2mqtt-agent's Introduction

owfs-agent

HOME-ASSISTANT configuration

# Sensors
sensor:
  - platform: mqtt
    name: "Sensor1"
    state_topic: "onewire/28.F2FBE3467CC2"
    unit_of_measurement: '°C'
    value_template: "{{ value_json.temperature }}"

INSERT YOUR APP DESCRIPTION HERE

Development

Following scripts are available to you (in the package.json):

  • start Starts the webserver (executes lib/index.js)
  • start:watch Same as start but restarts when file changes are detected
  • build Compliles the typescript sources to javascript
  • build:docker Builds sources, packages them into a docker image and push it to the DockerHub repository
  • test Runs all specs
  • test:coverage Runs all specs and generates a coverage report
  • watch Same as build but stays active and watches for file changes

You can run them using yarn run [script]

Want to use mongoose in your service?

Run yarn run yarn:install:mongoose

Next add following imports

import * as bluebird from 'bluebird';
import * as mongoose from 'mongoose';

After that you can add this snippet in your application

// Use bluebird
declare module 'mongoose' {
  type Promise<T> = bluebird<T>;
}
(mongoose as any).Promise = bluebird;
const options = { promiseLibrary: bluebird };
mongoose.connect('mongodb://mongodb:27017/test', options);
const db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', console.info.bind(console, 'connection open:'));

Now you should have an active mongodb connection and can create schemas and model to make use of it. For more details take a look at the offical mongoose documentation or the README for the mongoose typings to see the correct TypeScript syntax.

Want to build graphql a service?

Run yarn run yarn:install:graphql

Next add following imports

import * as bodyParser from 'body-parser';
import * as express from 'express';
import { graphiqlExpress, graphqlExpress } from 'graphql-server-express';
import { makeExecutableSchema } from 'graphql-tools';

Now replace the restify server with the following snippet which will give you a basic graphql server based on express

const typeDefs = [`
type Query {
  hello: String
}

schema {
  query: Query
}`];

const resolvers = {
  Query: {
    hello(root) {
      return 'world';
    }
  }
};

const schema = makeExecutableSchema({typeDefs, resolvers});
const server = express();
server.use('/graphql', bodyParser.json(), graphqlExpress({schema}));
server.use('/graphiql', graphiqlExpress({endpointURL: '/graphql'}));
server.listen(4000, () => console.log('Now browse to localhost:4000/graphiql'));

owfs2mqtt-agent's People

Contributors

vaceslav avatar

Watchers

James Cloos avatar Jörg Ruwe avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.