Scenarios

Tools → Scenarios

Keyboard/Mouse Shortcuts

As the true “brain” of home automation, scenarios allow you to interact with the real world in an intelligent way.

Management

Here you’ll find a list of your Jeedom scenarios, along with features to help you manage them effectively:

My Scenarios

In this section, you’ll find a list of scenarios that you’ve created. They’re sorted by their group, if one has been defined for each scenario. Each scenario is displayed with its name and parent object. The grayed-out scenarios are the ones that are disabled.

Tip

You can open a scenario by doing the following:

  • Click on one of them.
  • Ctrl-click or middle-click to open it in a new browser tab.

You have a search engine that allows you to filter the display of scenarios. Pressing the Esc key cancels the search. To the right of the search field, there are three buttons that appear in several places throughout Jeedom:

Once you’re in the scenario configuration screen, right-clicking on the scenario tabs will bring up a context menu. You can also use Ctrl+click or the middle mouse button to open another scenario directly in a new browser tab.

Create | Edit a scenario

After clicking Add, you must choose a name for your scenario. You will then be redirected to the page with its general settings. Before that, at the top of the page, you’ll find some useful features for managing this scenario:

Tips

Two tools will also be invaluable to you when setting up scenarios: > - Variables, visible in Tools → Variables > - The expression tester, accessible via Tools → Expression Tester

Clicking the Run button while holding down the Ctrl key allows you to save, run, and view the scenario log directly (provided the log level is not set to None).

General Tab

In the General tab, you’ll find the main settings for the scenario:

IMPORTANT

Multiple launches occur within the same second; in other words, if you have two launches in the same second without the checkbox selected, the scenario will still run twice (even though it shouldn’t). Similarly, when there are multiple launches in the same second, some launches may lose their tags. In conclusion, you MUST avoid multiple launches in the same second.

Tip

In triggered mode, conditions can now be entered. For example: #[Garage][Open Garage][Ouverture]# == 1 Note: You can have a maximum of 28 triggers/schedules for a scenario.

Scheduled Tip Mode

The scheduled mode uses Cron syntax. For example, you can run a scenario every 20 minutes with */20 * * * *, or at 5 a.m. to set up a variety of things for the day with 0 5 * * *. The ? to the right of a schedule allows you to configure it without needing to be an expert in Cron syntax. You can also specify a start time in the format Gi (time without leading zeros and minutes, example for 09h15 => 915 or for 23h40 => 2340). This time can be the result of a calculation (using a command or a tag), for example: #sunset# + 10 for a launch 10 minutes after sunset. Note that for a launch 1 hour and 30 minutes after sunset, you must set #sunset# + 130. Please note that when using a syntax other than cron, Jeedom will not be able to provide you with the dates of previous or subsequent runs.

“Scenario” tab

This is where you’ll build your scenario. After creating the scenario, its content is empty, so it won’t do… anything. You’ll need to start by adding a block using the button on the right. Once a block has been created, you can add another block or an action to it.

For added convenience and to avoid having to constantly rearrange blocks in the scenario, a block is added after the field where the mouse cursor is located. For example, if you have about ten blocks, and you click in the IF condition of the first block, the new block will be added after that block, at the same level. If no field is active, it will be added at the end of the scenario.

Tip

In conditions and actions, it’s best to use single quotes (‘) instead of double quotes (“).

Tip

Pressing Ctrl+Shift+Z or Ctrl+Shift+Y allows you to undo or redo a change (adding an action, a block, etc.).

Blocks

Here are the different types of blocks available:

Each block has its own options to make it easier to use:

If/Then/Else Blocks | Loop | In | A

When it comes to conditions, Jeedom tries to make it possible to write them in natural language as much as possible while remaining flexible.

You MUST NOT use [ ] in conditional tests; only parentheses () are allowed.

There are three buttons on the right side of this type of block for selecting an item to test:

Note

On “If/Then/Else” blocks of type Si/Alors/Sinon, circular arrows located to the left of the condition field allow you to enable or disable the repetition of actions if the condition evaluation yields the same result as the previous evaluation. IF expression != 0 is equivalent to IF expression, and IF expression == 0 is equivalent to IF NOT expression

Tip

There is a list of tags that provide access to variables from the current or another scenario, as well as the time, date, a random number, and more. See the sections on commands and tags below for more information.

Once you’ve entered the condition, click the “Add” button on the left to add a new block or an action to the current block.

Code Block

The Code block allows you to execute PHP code. It is therefore very powerful but requires a solid understanding of the PHP language.

Access to commands (sensors and actuators)

Access to logs

Access to Scenarios

Tip

Added a search function to the Code block: Search: Ctrl + F, then Enter; Next result: Ctrl + G; Previous result: Ctrl + Shift + G

Scenarios: Little codes among friends

Comment Block

The Comment block behaves differently when it is hidden. Its buttons on the left and the block title disappear, and reappear when you hover over them. Similarly, the first line of the comment is displayed in bold. This allows you to use this block as a purely visual separator within the scenario.

Actions

Actions added to blocks have several options:

Tip

Depending on the selected command, various additional fields may appear on the screen.

Possible substitutions

Triggers

There are specific triggers (other than those provided by the commands):

You can also trigger a scenario using the HTTP API described here.

You can use any of the following symbols for comparisons in conditions:

You can combine any comparison with the following operators:

Whether you’re comparing different devices or the same one, you must always specify the device. [Salle de bain][Hydrometrie][température] >= 18 && [Salle de bain][Hydrometrie][température] <= 22

Tags

When a scenario is executed, a tag is replaced with its value. You can use the following tags:

Tip

To display leading zeros, use the Date() function. See here.

You also have the following additional tags if your scenario was triggered by an interaction:

Important

When a scenario is triggered by an interaction, it is always executed in fast mode. This means it runs in the interaction’s thread rather than in a separate thread.

Calculation functions

Several functions are available for the devices:

The time periods and intervals for these functions can also be used with PHP expressions such as:

Here are some practical examples to help you understand the values returned by these different functions:

Outlet settings: 000 (for 10 minutes) 11 (for 1 hour) 000 (for 10 minutes)
average(prise,période) Returns the average of the 0s and 1s (may
  be influenced by polling)
averageBetween(#[Salle de bain][Hydrometrie][Humidité]#,2015-01-01 00:00:00,2015-01-15 00:00:00) Returns the average command amount between January 1, 2015, and January 15, 2015
min(prise,période) Returns 0: the outlet was successfully turned off during the period
minBetween(#[Salle de bain][Hydrometrie][Humidité]#,2015-01-01 00:00:00,2015-01-15 00:00:00) Shows the minimum command amount between January 1, 2015, and January 15, 2015
max(prise,période) Returns 1: The outlet was turned on during the period
maxBetween(#[Salle de bain][Hydrometrie][Humidité]#,2015-01-01 00:00:00,2015-01-15 00:00:00) Shows the highest command amount between January 1, 2015, and January 15, 2015
duration(prise,1,période) Returns 60: The outlet was on (set to 1) for 60 minutes during the period
durationBetween(#[Salon][Prise][Etat]#,0,Last Monday,Now) Returns the number of minutes the outlet has been off since last Monday.
statistics(prise,count,période) Returns 8: There were 8 status updates during the period
tendance(prise,période,0.1) Returns -1: downward trend
stateDuration(prise) Returns 600: The outlet has been in its current state for 600 seconds (10 minutes)
lastChangeStateDuration(prise,0) Returns 600: The outlet turned off (switched to 0) for the last time 600 seconds (10 minutes) ago
lastChangeStateDuration(prise,1) Returns 4200: the outlet turned on (state changed to 1) for the last time 4200 seconds ago (1 hour and 10 minutes)
lastStateDuration(prise,0) Returns 600: The outlet has been off for 600 seconds (10 minutes)
lastStateDuration(prise,1) Returns 3600: The outlet was last turned on 3600 seconds (1 hour) ago
stateChanges(prise,période) Returns 3: the outlet changed state 3 times during the period (if the info command is of type binary)
stateChanges(prise,0,période) Count 2: The outlet turned off (change to 0) twice during the period
stateChanges(prise,1,période) Return 1: The outlet turned on (changed to 1) once during the period
lastBetween(#[Salle de bain][Hydrometrie][Température]#,Yesterday,Today) Returns the last temperature recorded yesterday.
variable(plop,10) Returns the value of the variable plop or 10 if it is empty or does not exist
scenario(#[Salle de bain][Lumière][Auto]#) Returns 1 if running, 0 if stopped, -1 if disabled, -2 if the scenario does not exist, and -3 if the state is inconsistent
lastScenarioExecution(#[Salle de bain][Lumière][Auto]#) Returns 300 if the scenario was last run 5 minutes ago
collectDate(#[Salle de bain][Hydrometrie][Humidité]#) Posted February 14, 2021, 5:50:12 PM
valueDate(#[Salle de bain][Hydrometrie][Humidité]#) Posted on February 14, 2021, at 5:45:12 PM
eqEnable(#[Aucun][Basilique]#) Returns -2 if the device cannot be found, 1 if the device is active, and 0 if it is inactive
tag(montag,toto) Returns the value “montag” if it exists; otherwise, returns the value “toto”
name(eqLogic,#[Salle de bain][Hydrometrie][Humidité]#) Back to Hydrometry

Mathematical Functions

A toolkit of generic functions can also be used to perform conversions or calculations:

And here are some practical examples:

Function example Returned result
randText(il fait #[salon][oeil][température]#;La température est de #[salon][oeil][température]#;Actuellement on a #[salon][oeil][température]#) The function will return one of these texts at random each time it is executed.
randomColor(40,60) Returns a random color close to green.
round(#[Salle de bain][Hydrometrie][Humidité]# / 10) Returns 9 if the humidity percentage is 85
odd(3) Returns 1
median(15,25,20) Returns 20
avg(10,15,18) Returns 14.3
time_op(#time#, -90) if it is 4:50 p.m., returns: 1650 - 0130 = 1520
formatTime(1650) Posted at 4:50 p.m.
floor(130/60) Returns 2 (minutes if 130s, or hours if 130m)
convertDuration(3600) Returns 1h 0min 0s
convertDuration(duration(#[Chauffage][Module chaudière][Etat]#,1, first day of this month)*60) Returns the time in days/hours/minutes that the module has been in state 1 since the first day of the month

Various Features

Specific Commands

In addition to home automation commands, you have access to the following actions:

Scenario template

This feature allows you to convert a scenario into a template so that you can, for example, apply it to another Jeedom instance.

Clicking the template button at the top of the page opens the template management window.

From here, you can:

By clicking on a template, you can:

Below, you’ll find the section where you can apply your template to the current scenario.

Since commands may vary from one Jeedom system to another or from one setup to another, Jeedom asks you to map the commands used when creating the template to the ones in your system. Simply fill in the command mappings and then apply the changes.

Adding a PHP function

IMPORTANT

Adding PHP functions is for advanced users only. Even the slightest error can be fatal for your Jeedom.

Setup

Go to Jeedom’s configuration, then OS/DB, and launch the file editor.

Go to the “data” folder, then to “PHP,” and click on the file “user.function.class.php.”

This is the class where you can add your functions; you’ll find an example of a basic function there.

IMPORTANT

If you encounter a problem, you can always revert to the original file by copying the contents of user.function.class.sample.php in user.function.class.php

Nous utilisons des cookies pour vous garantir la meilleure expérience sur notre site web. Si vous continuez à utiliser ce site, nous supposerons que vous en êtes satisfait.