npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

domoticz-api-linker

v0.3.0

Published

Domoticz API Javascript Bridge Connector

Downloads

16

Readme

domoticz-api

⚠️ Warning : Work in progress.

The goal of this project is to have an object to easely access a Domoticz instance. Devices, user variables, send notifications, etc. will be accessible with just function calls. With Domoticz API, it's very easy to build awesome frontend with javascript frameworks like Vue / React / Angular.

This API uses the interfaces as defined at Domoticz API/JSON URL's. This page does not describe all available url's. This API also includes some 'undocumented' api url's.

All the API was rewritten in TypeScript. With full definition of Domoticz Enums & Types.

This is a "working" but beta version

You can use this lib as an import, or directly thru the browser.

Installation:

Download this repository to get an up to date version or :

npm install domoticz-api-linker

Browser usage :

Place this into your HTML head section :

<script src="path_to/domoticz-api/dist/domoticz-api.iife.js"></script>
<script>
  const domoticz = DomoticzApi.useDomoticz({
    hostname: YOUR_HOST,
    port: YOUR_PORT,
    username: YOUR_USERNAME,
    password: YOUR_PASSWORD,
    useSSL: true
  });
</script>

To see it in action, clone this repo, and go to demo/browser, then open index.html in you browser.

Usage in React/Vue/xxx :

import { Domoticz } from "domoticz-api-linker/src/index.esm.js";

const domoticz = useDomoticz({
  hostname: YOUR_HOST,
  port: YOUR_PORT,
  username: YOUR_USERNAME,
  password: YOUR_PASSWORD,
  useSSL: true
});

You can use index.cjs.js if you're using CommonJS.

Usage

// Get All devices:
const items = await domoticz.devicesManager.items();

// Get all lights :
import { DOMOTICZ_DEVICE } from "domoticz-api-linker/src/index.esm.js";
const lights = await domoticz.getByType(DOMOTICZ_DEVICE.LIGHT);

// Switch on the first light :
import { DOMOTICZ_SWITCHCMD } from "domoticz-api-linker/src/index.esm.js";
domoticz.switch(lights.results[0].idx, DOMOTICZ_SWITCHCMD.ON);

Using another HTTP layer

By default DomoticzApi use fetch. If you want to use axios :

  • Create a new class (eg. DomoticzApiProviderAxios which extends the DomoticzApiProvider class
  • Implement the __generic() function to deal with axios
  • Pass this class in the api parameter in options like this:
import { DomoticzApiProviderAxios } from "domoticz-api-linker";
const domoticz = Domoticz(YOUR_HOST, {
  useSSL: true,
  username: YOUR_USERNAME,
  password: YOUR_PASSWORD,
  api: DomoticzApiProviderAxios,
});

Imports

All things can be imported :

| Import | Description | | -------------------------- | ------------------------------------------------------------------- | | Domoticz | The main Domoticz object, giving you access to all the managers | | DomoticzApiProvider | A class used to override the HTTP api call with you prefered flavor | | DomoticzApiProviderFetch | Defaut HTTP api call layer using native javascript fetch object | | deviceTypes | Contain the Domoticz devices types | | deviceHumidityTypes | Contain the Domoticz humidity types | | deviceHumidityGeneralTypes | Contain the Domoticz humidity types for 'General' devices | | useDevices(api) | methods available in Domoticz.deviceManager | | useCameras(api) | methods available in Domoticz.cameraManager | | useEvents(api) | methods available in Domoticz.eventManager | | useNotifications(api) | methods available in Domoticz.notificationManager | | useScenes(api) | methods available in Domoticz.sceneManager | | useSystem(api) | methods available in Domoticz.systemManager |


🎯 Todos:

  • [x] Refactoring API
  • [x] Full rewrite in TypeScript
  • [ ] Adding management functions (WIP)
  • [ ] Digging into Domoticz Source Code to implement undocumented functions

📜 API Documentation: