Automations: Learned values

A rule with a learned time window

Some fields of a rule can take a learned value instead of a fixed number or time. The node learns the value from your devices and your house, and the rule uses it as soon as it is known. A rule still never changes by itself. The rule keeps the learned value only because you chose it in the editor.

Which fields take a learned value

Each of these fields has a switch between Fixed value and Learned value:

  • the threshold of a balance condition,
  • the value of a topic or entity condition, with above or below only,
  • the start and the end of a time window,
  • the hold time of every condition except the chain conditions.

Bounds, fallback and shift

A time window that follows a learned switch off time, with its bounds, fallback, shift and origin line

A learned value always needs three settings:

  • At least and At most for numbers, or Earliest and Latest for times. The learned value is kept between these bounds.
  • Without a learned value is the fallback. It applies when nothing has been learned yet, when the stored value cannot be read, or when it is older than 7 days. The fallback must lie between the bounds, and the minimum must not be above the maximum. The editor says so if it is not.
  • Shift is optional. It is added after the value has been kept within the bounds, in the unit of the field, so minutes for times. A shift lets a time window keep its length, because its end moves with its start.

The age limit is max_age_s in the rule file. It defaults to 604800 seconds, which is 7 days. Older values count as missing, and the fallback applies.

The house is quiet

The condition type House state is met when the learned house state equals House is quiet or House is active. Without a fresh value, the choice Without a fresh value applies. The template Off when the house is quiet switches a device off in that case. It sets its age limit to 2 hours (7200 seconds) instead of 7 days.

What the rule card shows

A condition that takes a learned value shows three things:

  • a chip with the name of the learned value and its current value,
  • a range scale with the bounds and the current value,
  • an origin line that says where the value comes from. It reads Learned from N days or Learned from N runs, with the time since the last change. When the value was clamped, it reads Set to the bound, the learned value is …. When the fallback applies, it reads Fallback value, because nothing has been learned yet or the value is too old.

Year course of a learned value

The rule card draws the course of a learned value over the year as a small line under its scale. A sentence names the month with the highest value and the month with the lowest. The line appears from 8 weeks of data on.

Learned value condition

The condition type Learned value compares a learned number with a threshold. Use it for numbers such as the PV reserve. The condition is met when the learned number is above or below the threshold. The threshold is a fixed number, or a reference to another learned value with its bounds. You choose the type in the rule editor, and in scenarios too.

Field Meaning
learned The learned number, for example site/pv_reserve_w
comparison above or below
threshold A fixed number, or a learned reference
hysteresis Gap around the threshold, so the condition does not flicker
fallback The number compared when the learned value is missing or older than max_age_s
max_age_s Age limit in seconds, 604800 (7 days) by default
hold_seconds Time the condition must stay met before it counts

The hysteresis works as for balance conditions. With above the condition turns on at the threshold and turns off at the threshold minus the hysteresis.

Written for Energy Node v0.12.0.

Edit on GitHub