ioBroker / ioBroker.scenes

Group states to scenes and control them.
MIT License
27 stars 17 forks source link
automation iobroker scenes-adapter smarthome

Logo

ioBroker scenes adapter

Number of Installations Number of Installations NPM version

Test and Release Translation status Downloads

scenes Adapter can create scenes and execute them in ioBroker environment.

This adapter uses Sentry libraries to automatically report exceptions and code errors to the developers. For more details and for information how to disable the error reporting see Sentry-Plugin Documentation! Sentry reporting is used starting with js-controller 3.0.

This adapter can create three types of scenes:

Scenes

Scenes will be created if setting "set on false" are not used. Every scene can be configured individually, so you can have scenes and groups in one instance of adapter. The scene is just a list of states id and values, that these states must have by activation of the scene. E.g. we have created on the scene scene.allLightInBath:

  scene.allLightInBath
  |- hm-rpc.0.BOTTOM_LIGHT.STATE  - true
  +- hm-rpc.0.TOP_LIGHT.STATE     - true

To activate the scene, we must set scene.allLightInBath to true (e.g., over a script or vis). Then both states will be set to desired values, to true. The value of scene.allLightInBath will be true too. If we manually switch to the top light, the value of the scene.allLightInBath will go to false. And again to true if we will manually switch the light on.

Let's add to the scene the fan:

  scene.allLightInBath
  |- hm-rpc.0.BOTTOM_LIGHT.STATE  - true
  |- hm-rpc.0.TOP_LIGHT.STATE     - true
  |- hm-rpc.0.FAN.STATE          - true
  |- hm-rpc.0.FAN.STATE          - false (delay 60000ms)

In this case, the fan will be switched on ba activation of the scene and will be switched off in one minute. After the fan will be switched off the value of scene.allLightInBath will go to false, because not all states are equal to desired values. States with delay are not participated in calculations.

You can test the scene with a "play" button. Additionally, you can link this scene direct with other scene ID. E.g. if you have a sensor on the door, you can select it as a trigger:

  trigger
    id:        hm-rpc.0.DOOR_SENSOR.STATE
    condition: ==
    value:     true

And every time you open the door in the bath, all lights with fan will be switched on.

Groups

Groups are like virtual channels. You can create with the help of groups virtual device from several actuators and control them together, like one device. Let's modify our sample with the bath's lights.

  scene.allLightInBath             "set on true"    "set on false" 
  |- hm-rpc.0.BOTTOM_LIGHT.STATE  - true             false
  +- hm-rpc.0.TOP_LIGHT.STATE     - true             false

If you link this group with the door sensor like:

  trigger on true
    id:        hm-rpc.0.DOOR_SENSOR.STATE
    condition: ==
    value:     true

  trigger on false
    id:        hm-rpc.0.DOOR_SENSOR.STATE
    condition: ==
    value:     false

Every time you open the door, all lights in a bath will be switched on. The value of the scene.allLightInBath will go to true. If you close the door, the lights will be switched off, and the value of scene.allLightInBath will go to false.

It is useless, but it is good as an example.

If you manually switch on one light, the value of the scene.allLightInBath will go to uncertain.

Delays can be used in the group too, but the states with delay are not participated in calculations of the current value of group.

Virtual groups

Virtual groups are like virtual channels and like groups, but can have any kind of values: numbers, strings, and so on. You can create a virtual group to control all shutters in living room. By writing 40% into a virtual group all shutters will be set to 40%.

Additionally, you can define the behavior for which value should be taken for the group if not all states of the group have the same value.

You can provide following aggregations (available only in advanced mode):

Save actual states as a scene

To save actual states in some scene, you can send a message to the adapter:

sendTo(
    'scenes.0', 
    'save', 
    {sceneId: 
        'scene.0.SCENE_ID', // scene ID 
        isForTrue: true     // true if actual values must be saved for `true` state and `false` if for false 
    }, 
    result => result.err && console.error(result.error) // optional
);

The adapter will read all actual values for IDs defined in this scene and save it as configured ones.

Disable or enable scene via message

To disable or enable some scene, you can send a message to the adapter:

// enable
sendTo(
    'scenes.0', 
    'enable', 
    'scene.0.SCENE_ID', 
    result => result.err && console.error(result.error) // optional
);
// disable
sendTo(
    'scenes.0', 
    'disable', 
    'scene.0.SCENE_ID', 
    result => result.err && console.error(result.error) // optional
);
// or
sendTo(
    'scenes.0', 
    'disable', // 'enable' to enable
    {sceneId: 'scene.0.SCENE_ID'}, 
    result => result.err && console.error(result.error) // optional
);

Changelog

3.2.1 (2024-06-21)

3.1.1 (2024-06-21)

3.0.4 (2024-04-27)

3.0.3 (2024-02-25)

3.0.1 (2024-02-16)

2.4.2 (2024-02-12)

2.4.0 (2022-12-23)

2.3.9 (2022-02-13)

2.3.8 (2021-08-31)

2.3.6 (2021-01-22)

2.3.5 (2021-01-22)

2.3.4 (2021-01-16)

2.3.3 (2020-12-06)

2.3.1 (2020-11-06)

2.3.0 (2020-11-02)

2.1.7 (2020-10-30)

2.1.6 (2020-09-25)

2.1.3 (2020-09-18)

2.1.2 (2020-07-08)

2.0.17 (2020-06-29)

2.0.13 (2020-06-27)

2.0.12 (2020-06-26)

2.0.10 (2020-06-20)

2.0.9 (2020-06-17)

2.0.8 (2020-06-16)

2.0.3 (2020-06-14)

1.1.1 (2019-05-26)

1.1.0 (2018-04-24)

1.0.2 (2018-01-21)

1.0.0 (2017-11-11)

0.2.7 (2017-08-14)

0.2.6 (2016-06-21)

0.2.5 (2016-02-03)

0.2.4 (2016-01-24)

0.2.3 (2015-12-10)

0.2.2 (2015-11-22)

0.2.1 (2015-10-27)

0.2.0 (2015-10-27)

0.1.3 (2015-09-19)

0.1.2 (2015-08-15)

0.1.1 (2015-08-10)

0.1.0 (2015-08-09)

0.0.2 (2015-08-05)

0.0.1 (2015-07-29)

License

The MIT License (MIT)

Copyright (c) 2015-2024, Bluefox (dogafox@gmail.com)

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.