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.smartstate

v0.0.5

Published

smartstate

Downloads

1

Readme

Logo

ioBroker.smartstate

NPM version Downloads Number of Installations Current version in stable repository

NPM

Tests: Test and Release

smartstate adapter for ioBroker

With this adapter you can create states which are calculated by other states A good example is when you want to create a state that counts the lights that are on (see examples) The handling is very easy. Add a new smart state, define it's name and type and add child states which will be used to calculate the states value by the given type (operator)

Getting started

Add a new smartstate by using the left + icon on the top left of the settings page. Then you can add following parameters.

  • Smartstate settings | Field | Description | |-------------|-------------| | Name | The name of the smartstate | | Id | The id of the smartstate | | Type | Calculation type which defines how the smartstate uses the child to calculate its value | | Path | The folder/path where the state should be | Calc only for ACK values | If checked, only state values which are acknowledged will trigger a recalulation |
  • Child Settings | Field | Description | |-------------|-------------| | Type | the state type will allow a selection of one statethe pattern type will allow a state selection pattern | | Id/Pattern | the state id or the pattern | | Value function | a valid javacsript code to change the value for the state before the operator/calculation type is applied eg: return !valueThe value var holds the state value |

Important

  • A smartstate can use another smartstate as child state, but please be sure you do not create a recursion (State A has State B as child and State B has State A as child). Those recursions are not caught by the validation and will lead to endless loops and therfore will break the adapter or even the whole system
  • The adapter converts pattern subscription to state subscriptions, so states created in other adapters (after the smartstate adapter was started) which matches a pattern in a state child will not apply to the pattern selection. In this cas a restart of the smartstate adapter is necessary.
  • Using the state selector dialog in the child table may take a while when first opening. I am open for contributions to open a better, newer dialog

Example

Here is an example of a state that counts the lights that are on(in this case kitchen) and another one which indicates if a light in the kitchen is on. image

In the second screenshot you can see that we are using the first smartstate for generating a boolean state which will indicate if a light is on. That can be done by using the or operator image

This one shows the use of a pattern to determine if any dmx light is on image

And here we use a function to count all lights (in this case kitchen) which are off image

Those smart states settings will create following states in the object tree image

Using the "State Info Type"

A smartstate has the ability to create an extra object/state which will include the id's of the "used states" by the smartstate The behaviour how this works differs from calulation type to calcualtion type

  • For count or and and the states which resolve as true will be filled
  • For sum and avg all the states will be filled
  • For min the state with the minimal value will be filled
  • For max the state with the maximal value will be filled
  • For equals all states which are euqal to the "first state value" in the child list will be filled

The 'State Info Type' will set if, and how the values are beeing presented

  • No info will not create the state info object
  • JSON array will create a json array of the "used states"
  • JSON object will create a json object of the "used states" where the properties reflect the state id's
  • String will create a string which is semicollon seperated

The value which is beeing stored is delivered by the State info type function and will be defaulted to the full id of the state, but the user can change this by changing this function. The function has to be a valid javascript code! The variable params can be used and it has following properties

| Field | Description | |-------------|-------------| | id | The name of the smartstate | | stateObject | The object of the state | | deviceObject | This is the object of the parent device for the state (if there is a device), otherwise it's null |

The objects (stateObject, stateObjectInfo) are those you can see in the iobroker object list, e.g.: image

So for having the name inserted instead the id you can change te default function string to: image

Changelog

0.0.5 (2023-04-09)

  • (ChriD) Fixed Problem with "AVG" calculation type when using patterns

0.0.4 (2023-02-07)

  • (ChriD) Hotfix adapter crash on startup

0.0.3 (2023-02-07)

  • (ChriD) added option to create a datapoint/state which will show some combined state information values from the states which are used by the smart state
  • (ChriD) fixed multilayer path creation

0.0.2 (2023-01-29)

  • (ChriD) added ability to define a 'value function' which can be used to change the value for the state before the operator is applied

0.0.1 (2023-01-24)

  • (ChriD) initial version

License

MIT License

Copyright (c) 2023 ChriD [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.