Integrations

Derivative

Spook adds an action to the derivative sensor that changes its time window, so an automation can smooth it more or less without a trip to the helper's options.

The derivative sensor helper tells you how fast a value changes: how many watts a minute the power use of the house climbs, how many degrees an hour the boiler warms up. A time window smooths it: the sensor averages the changes over that window, so one jumpy reading does not swing it all over the place.

The time window is set in the helper's options, and only there. An automation cannot change it: not a calmer window at night, when the fridge and the heat pump switching on and off make the power meter jump.

Spook adds an action for that: set time window.

Actions

Spook adds one action to the derivative integration. You find it wherever you add an action, marked with a 👻.

Set time window

Changes the time window of one or more derivative sensors, like the options of the helper do. The rest of their settings stay as they are: the sensor they follow, the units, the rounding.

The change goes through the helper's own options, so Home Assistant checks it the same way it checks what you fill in there. Then Home Assistant reloads the sensor, as it does after you save its options. The action returns once the sensor is reloaded, so the next step of your automation already works with the new window. A sensor that already has the time window you give is left alone, without a reload.

A time window of 0 is no window: every change of the source counts on its own.

The options of the helper only offer sources with the unit of the current one, and they read that unit from the source as it is now. A source that is not there at all, like one of an integration that is still starting up, is not among them, and the options refuse to keep it. When the window of such a sensor has to change, Spook says so with an error naming the source. A source that is unavailable is fine.

Every entity is checked before the first sensor changes. An entity that is not a derivative sensor, one set up in YAML, or one whose window has to change while its source is not there, is refused with an error, and nothing changes. The sensors change one at a time, in the order you give them. When the source of a sensor goes away while the ones before it reload, the action stops with an error that names that sensor. The sensors before it in the list did change; the ones after it did not.

Run by hand, the action takes an administrator, like the options of a helper do. Your automations can always run it. So can your scripts, unless a user who is not an administrator starts one.

How to use it

  1. Open the automation or script that should change the time window, and select Add action.
  2. Search for set time window, and select Derivative: Set time window 👻.
  3. Choose the derivative sensors.
  4. Fill in the new time window.
  5. Select Save.

Missing something here?

An action, an entity or a repair this integration should have? Say so. Stuck, or found a bug? There is help.