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

@iobroker/type-detector

v4.0.1

Published

Detects devices in ioBroker for Material, Google home, Homekit, ...

Downloads

7,098

Readme

ioBroker.type-detector

This is not the adapter. This is help function to detect devices from ioBroker states and channels.

You can find the description of devices in DEVICES.md.

How to use

You can use this module in Browser and in Node.js projects.

Just now this module used in material adapter to detect devices and to visualize them.

The following code detects devices in some state's tree:

import ChannelDetector, { DetectOptions } from '@iobroker/type-detector';
const detector = new ChannelDetector();

const keys = Object.keys(objects);				// For optimization
const usedIds = [];                 			// To not allow using of same ID in more than one device
const ignoreIndicators = ['UNREACH_STICKY'];    // Ignore indicators by name
const allowedTypes = ['button', 'rgb', 'dimmer', 'light'];	// Supported types. Leave it null if you want to get ALL devices.

const options: DetectOptions = {
	objects:            this.props.objects,
	id:                 'hm-rpc.0.LEQ1214232.1', // Channel, device or state, that must be detected
	_keysOptional:      keys,
	_usedIdsOptional:   usedIds,
	ignoreIndicators,
//    allowedTypes,
};

let controls = detector.detect(options);
if (controls) {
	controls = controls.map((control: PatternControl) => {
		const id = control.states.find((state: DetectorState) => state.id).id;
		if (id) {
			console.log(`In ${options.id} was detected "${control.type}" with following states:`);
			control.states
                .filter((state: DetectorState) => state.id)
                .forEach((state: DetectorState) => {
                    console.log(`    ${state.name} => ${state.id}`);
                });

			return {control, id};
		}
	});
} else {
	console.log(`Nothing found for ${options.id}`);
}
// Legacy
const { ChannelDetector } = require('iobroker.type-detector');
const detector = new ChannelDetector();

const keys = Object.keys(objects);				// For optimization
const usedIds = [];                 			// To not allow using of same ID in more than one device
const ignoreIndicators = ['UNREACH_STICKY'];    // Ignore indicators by name
const allowedTypes = ['button', 'rgb', 'dimmer', 'light'];	// Supported types. Leave it null if you want to get ALL devices.

const options = {
	objects:            this.props.objects,
	id:                 'hm-rpc.0.LEQ1214232.1', // Channel, device or state, that must be detected
	_keysOptional:      keys,
	_usedIdsOptional:   usedIds,
	ignoreIndicators,
//    allowedTypes,
};

let controls = detector.detect(options);
if (controls) {
	controls = controls.map(control => {
		const id = control.states.find(state => state.id).id;
		if (id) {
			console.log(`In ${options.id} was detected "${control.type}" with following states:`);
			control.states
                .filter(state => state.id)
                .forEach(state => {
                    console.log(`    ${state.name} => ${state.id}`);
                });

			return {control, id};
		}
	});
} else {
	console.log(`Nothing found for ${options.id}`);
}

Changelog

4.0.1 (2024-07-26)

  • (Apollon77) Fix Electricity states for light type
  • (Apollon77) Add Electricity states for more types
  • (Apollon77) Internal Refactoring

3.0.5 (2023-10-24)

  • (bluefox) Implemented @iobroker/type-detector as npm module

2.0.6 (2023-10-18)

  • (bluefox) Removed valve and url as types (they just a slider and image)

2.0.4 (2023-10-13)

  • (bluefox) Removed multiple for weather location

2.0.3 (2023-10-09)

  • (Garfonso) Changed detection of fire and flood sensors
  • (Garfonso) Changed the role of TIME_SUNRISE and TIME_SUNSET

2.0.2 (2023-09-04)

  • (Garfonso) Added rgbwSingle device to types

2.0.1 (2023-08-21)

  • (bluefox) Added rgbwSingle device

2.0.0 (2023-08-21)

  • (bluefox) Removed rgbOld type from 2018

1.1.2 (2023-06-06)

  • (bluefox) Fixed creation of the DEVICES.md
  • (bluefox) Fixed the main attribute in package.json
  • (bluefox) Better detection of the door devices

1.1.1 (2022-11-09)

  • (Garfonso) corrected the double states in light devices
  • (Garfonso) added CIE color type as equivalent to rgbSingle type

1.1.0 (2022-05-22)

  • (Garfonso) blinds: corrected error in the default role for tilt

1.0.17 (2022-01-20)

  • (bluefox) Fixed the main attribute in package.json

1.0.15 (2021-07-09)

  • (algar42) extend the weather forecast device with TIME_SUNRISE and TIME_SUNSET
  • (Garfonso) added weatherForecast tests

1.0.14 (2021-06-30)

  • (bluefox) Added chart device

1.0.13 (2021-06-27)

  • (bluefox) Changed the air conditioner detection
  • (Garfonso) Corrected blind with buttons

1.0.12 (2021-06-16)

  • (bluefox) Changed the air conditioner detection
  • (Garfonso) Corrected blind with buttons

1.0.11 (2021-06-11)

  • (Garfonso) Added buttons to blinds and added THE new type: blinds with only buttons
  • (agross) refactoring
  • (bluefox) Extend socket and light with electricity parameters

1.0.10 (2021-06-07)

  • (bluefox) Added some states to thermostat

1.0.9 (2021-06-06)

  • (bluefox) Added new types: gate, camera, flood alarm, current weather.

1.0.8 (2021-03-11)

  • (bluefox) Escape chars in IDs.

1.0.7 (2020-08-12)

  • (bluefox) Added the vacuum cleaner.

1.0.4 (2020-08-12)

  • (bluefox) Added the air conditioner.

1.0.0 (2020-08-10)

  • (Garfonso) The switch could have the boolean type
  • (Garfonso) Fixed level.dimspeed issue

0.1.10 (2020-06-23)

  • (bluefox) Ignore level.dimspeed for dimmer
  • (bluefox) Added new type button.press

0.1.9 (2020-01-12)

  • (Garfonso) Added "white" to rgb

0.1.7 (2019-08-14)

  • (bluefox) Add default roles

0.1.5 (2019-07-23)

  • (bluefox) Fixed search for multiple items.

0.1.4 (2019-07-19)

  • (bluefox) Added function "getPatterns".

0.1.3 (2019-07-16)

  • (bluefox) Add description to function "detect".

0.1.1 (2019-06-29)

  • (kirovilya) In some cases, devices may not have channels, but immediately have a states. For example, in the zigbee-adapter.

0.1.1 (2019-05-24)

  • (bluefox) added PRECIPITATION to weather
  • (bluefox) added location detection

0.1.0 (2018-08-14)

  • (bluefox) initial commit

License

Copyright (c) 2018-2024 Denis Haev [email protected]

MIT License