mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-21 16:27:19 +00:00
Added templates to Bayesian sensor (#8408)
* Added templates to Bayesian sensor * change quotes * more changes * Added raw/endraw tags
This commit is contained in:
parent
3274e7127e
commit
e9c3cedc0a
@ -57,10 +57,21 @@ observations:
|
|||||||
required: true
|
required: true
|
||||||
type: list
|
type: list
|
||||||
keys:
|
keys:
|
||||||
entity_id:
|
platform:
|
||||||
description: Name of the entity to monitor.
|
description: >
|
||||||
|
The supported platforms are `state`, `numeric_state`, and `template`.
|
||||||
|
They are modeled after their corresponding triggers for automations,
|
||||||
|
requiring `to_state` (for `state`), `below` and/or `above` (for `numeric_state`) and `value_template` (for `template`).
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
|
entity_id:
|
||||||
|
description: Name of the entity to monitor.
|
||||||
|
required: true (for `state` and `numeric_state`)
|
||||||
|
type: string
|
||||||
|
value_template:
|
||||||
|
description: Defines the template to be used.
|
||||||
|
required: true (for `template`)
|
||||||
|
type: template
|
||||||
prob_given_true:
|
prob_given_true:
|
||||||
description: The probability of the observation occurring, given the event is `true`.
|
description: The probability of the observation occurring, given the event is `true`.
|
||||||
required: true
|
required: true
|
||||||
@ -70,17 +81,10 @@ observations:
|
|||||||
required: false
|
required: false
|
||||||
type: float
|
type: float
|
||||||
default: "`1 - prob_given_true` if `prob_given_false` is not set"
|
default: "`1 - prob_given_true` if `prob_given_false` is not set"
|
||||||
platform:
|
|
||||||
description: >
|
|
||||||
The only supported observation platforms are `state` and `numeric_state`,
|
|
||||||
which are modeled after their corresponding triggers for automations,
|
|
||||||
requiring `below` and/or `above` instead of `to_state`.
|
|
||||||
required: true
|
|
||||||
type: string
|
|
||||||
to_state:
|
to_state:
|
||||||
description: The target state.
|
description: The target state.
|
||||||
required: true
|
required: true (for `state`)
|
||||||
type: string
|
type: string
|
||||||
{% endconfiguration %}
|
{% endconfiguration %}
|
||||||
|
|
||||||
## {% linkable_title Full examples %}
|
## {% linkable_title Full examples %}
|
||||||
@ -95,23 +99,23 @@ binary_sensor:
|
|||||||
prior: 0.25
|
prior: 0.25
|
||||||
probability_threshold: 0.95
|
probability_threshold: 0.95
|
||||||
observations:
|
observations:
|
||||||
- entity_id: 'sensor.living_room_motion'
|
- platform: 'state'
|
||||||
|
entity_id: 'sensor.living_room_motion'
|
||||||
prob_given_true: 0.4
|
prob_given_true: 0.4
|
||||||
prob_given_false: 0.2
|
prob_given_false: 0.2
|
||||||
platform: 'state'
|
|
||||||
to_state: 'off'
|
to_state: 'off'
|
||||||
- entity_id: 'sensor.basement_motion'
|
- platform: 'state'
|
||||||
|
entity_id: 'sensor.basement_motion'
|
||||||
prob_given_true: 0.5
|
prob_given_true: 0.5
|
||||||
prob_given_false: 0.4
|
prob_given_false: 0.4
|
||||||
platform: 'state'
|
|
||||||
to_state: 'off'
|
to_state: 'off'
|
||||||
- entity_id: 'sensor.bedroom_motion'
|
- platform: 'state'
|
||||||
|
entity_id: 'sensor.bedroom_motion'
|
||||||
prob_given_true: 0.5
|
prob_given_true: 0.5
|
||||||
platform: 'state'
|
|
||||||
to_state: 'on'
|
to_state: 'on'
|
||||||
- entity_id: 'sun.sun'
|
- platform: 'state'
|
||||||
|
entity_id: 'sun.sun'
|
||||||
prob_given_true: 0.7
|
prob_given_true: 0.7
|
||||||
platform: 'state'
|
|
||||||
to_state: 'below_horizon'
|
to_state: 'below_horizon'
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -126,8 +130,27 @@ binary_sensor:
|
|||||||
prior: 0.2
|
prior: 0.2
|
||||||
probability_threshold: 0.9
|
probability_threshold: 0.9
|
||||||
observations:
|
observations:
|
||||||
- entity_id: 'sensor.outside_air_temperature_fahrenheit'
|
- platform: 'numeric_state'
|
||||||
|
entity_id: 'sensor.outside_air_temperature_fahrenheit'
|
||||||
prob_given_true: 0.95
|
prob_given_true: 0.95
|
||||||
platform: 'numeric_state'
|
|
||||||
below: 50
|
below: 50
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Finally, here's an example for `template` observation platform,
|
||||||
|
as seen in the configuration it requires `value_template` and does not use `entity_id`.
|
||||||
|
|
||||||
|
{% raw %}
|
||||||
|
```yaml
|
||||||
|
# Example configuration.yaml entry
|
||||||
|
binary_sensor:
|
||||||
|
name: 'Paulus Home'
|
||||||
|
platform: 'bayesian'
|
||||||
|
prior: 0.5
|
||||||
|
probability_threshold: 0.9
|
||||||
|
observations:
|
||||||
|
- platform: template
|
||||||
|
value_template: >
|
||||||
|
{{is_state('device_tracker.paulus','not_home') and ((as_timestamp(now()) - as_timestamp(states.device_tracker.paulus.last_changed)) > 300)}}
|
||||||
|
prob_given_true: 0.95
|
||||||
|
```
|
||||||
|
{% endraw %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user