2019-05-28 20:41:02 +02:00
Binary Sensor Map
=================
.. seo ::
:description: Instructions for setting up a Binary Sensor Map
:image: binary_sensor_map.jpg
2023-04-13 07:12:39 +02:00
The `` binary_sensor_map `` sensor platform allows you to map multiple :doc: `binary sensor </components/binary_sensor/index>`
2024-05-07 07:40:12 +02:00
to an individual value. Depending on the state of each binary sensor, its associated configured parameters, and this sensor's mapping type,
2023-04-13 07:12:39 +02:00
the `` binary_sensor_map `` publishes a single numerical value.
2019-05-28 20:41:02 +02:00
2024-05-07 07:40:12 +02:00
Use this sensor to combine one or more binary sensors' `` ON `` or `` OFF `` states into a numerical value. Some possible use cases include
2023-04-13 07:12:39 +02:00
touch devices and determining Bayesian probabilities for an event.
2019-05-28 20:41:02 +02:00
2023-04-13 07:12:39 +02:00
This platform supports three measurement types: `` BAYESIAN `` , `` GROUP `` , and `` SUM `` .
You need to specify your desired mapping with the `` type: `` configuration value.
2019-05-28 20:41:02 +02:00
2024-05-07 07:40:12 +02:00
When using the `` BAYESIAN `` type, add your binary sensors as `` observations `` to the binary sensor map.
If you use the `` GROUP `` or `` SUM `` type, add your binary sensors as `` channels `` .
2023-04-13 07:12:39 +02:00
The maximum amount of observations/channels supported is 64.
2019-05-28 20:41:02 +02:00
2023-04-13 07:12:39 +02:00
- `` BAYESIAN `` This type replicates Home Assistant's `Bayesian sensor <https://www.home-assistant.io/integrations/bayesian/> `__ . Based on the observation states, this sensor returns the Bayesian probability of a particular event occurring. The configured `` prior: `` probability is the likelihood that the Bayesian event is true, ignoring all external influences. Every observation has its own `` prob_given_true `` and `` prob_given_false `` parameters. The `` prob_given_true: `` value is the probability that the observation's binary sensor is `` ON `` when the Bayesian event is `` true `` . The `` prob_given_false: `` value is the probability that the observation's binary sensor is `` ON `` when the Bayesian event is `` false `` . Use an :doc: `/components/binary_sensor/analog_threshold` to convert this sensor's probability to a binary `` ON `` or `` OFF `` by setting an appropriate threshold.
.. code-block :: yaml
# Example configuration entry
sensor:
- platform: binary_sensor_map
id: bayesian_prob
name: 'Bayesian Event Probability'
type: bayesian
prior: 0.4
observations:
- binary_sensor: binary_sensor_0
prob_given_true: 0.9
prob_given_false: 0.2
- binary_sensor: binary_sensor_1
prob_given_true: 0.6
prob_given_false: 0.1
binary_sensor:
2024-05-07 07:40:12 +02:00
# If the Bayesian probability is greater than 0.6,
2023-04-13 07:12:39 +02:00
# then predict the event is occuring
- platform: analog_threshold
name: "Bayesian Event Predicted State"
sensor_id: bayesian_prob
2024-05-07 07:40:12 +02:00
threshold: 0.6
2023-04-13 07:12:39 +02:00
# ...
- `` GROUP `` Each channel has its own `` value `` . The sensor publishes the average value of all active
binary sensors or `` NAN `` if no sensors are active.
2019-05-28 20:41:02 +02:00
.. code-block :: yaml
# Example configuration entry
sensor:
- platform: binary_sensor_map
id: group_0
name: 'Group Map 0'
type: GROUP
channels:
- binary_sensor: touchkey0
value: 0
- binary_sensor: touchkey1
value: 10
- binary_sensor: touchkey2
value: 20
- binary_sensor: touchkey3
value: 30
# Example binary sensors using MPR121 component
mpr121:
id: mpr121_first
address: 0x5A
binary_sensor:
- platform: mpr121
channel: 0
id: touchkey0
# ...
2024-05-07 07:40:12 +02:00
2023-04-13 07:12:39 +02:00
- `` SUM `` Each channel has its own `` value `` . The sensor publishes the sum of all the active
binary sensors values or `` 0 `` if no sensors are active.
2022-08-31 06:52:35 +02:00
.. code-block :: yaml
# Example configuration entry
sensor:
- platform: binary_sensor_map
id: group_0
name: 'Group Map 0'
type: sum
channels:
- binary_sensor: bit0
value: 1
- binary_sensor: bit1
value: 2
- binary_sensor: bit2
value: 4
- binary_sensor: bit3
value: 8
binary_sensor:
- platform: gpio
2024-05-07 07:40:12 +02:00
pin: GPIOXX
2022-08-31 06:52:35 +02:00
id: bit0
- platform: gpio
2024-05-07 07:40:12 +02:00
pin: GPIOXX
2022-08-31 06:52:35 +02:00
id: bit1
- platform: gpio
2024-05-07 07:40:12 +02:00
pin: GPIOXX
2022-08-31 06:52:35 +02:00
id: bit2
- platform: gpio
2024-05-07 07:40:12 +02:00
pin: GPIOXX
2022-08-31 06:52:35 +02:00
id: bit3
# ...
2019-05-28 20:41:02 +02:00
Configuration variables:
------------------------
- **name** (**Required** , string): The name of the sensor.
2023-04-13 07:12:39 +02:00
- **type** (**Required** , string): The sensor type. Should be one of: `` BAYESIAN `` , `` GROUP `` , or `` SUM `` .
- **channels** (**Required for GROUP or SUM types** ): A list of channels that are mapped to certain values.
2019-05-28 20:41:02 +02:00
- **binary_sensor** (**Required** ): The id of the :doc: `binary sensor </components/binary_sensor/index>`
to add as a channel for this sensor.
- **value** (**Required** ): The value this channel should report when its binary sensor is active.
2024-05-07 07:40:12 +02:00
- **prior** (**Required for BAYESIAN type** , float between 0 and 1): The prior probability of the event.
2023-04-13 07:12:39 +02:00
- **observations** (**Required for BAYESIAN type** ): A list of observations that influence the Bayesian probability of the event.
- **binary_sensor** (**Required** ): The id of the :doc: `binary sensor </components/binary_sensor/index>`
to add as an observation.
- **prob_given_true** (**Required** , float between 0 and 1): Assuming the event is true, the probability this observation is on.
- **prob_given_false** (**Required** , float between 0 and 1): Assuming the event is false, the probability this observation is on.
2019-05-28 20:41:02 +02:00
- All other options from :ref: `Sensor <config-sensor>` .
See Also
--------
- :doc: `/components/binary_sensor/mpr121`
2023-04-13 07:12:39 +02:00
- :doc: `/components/binary_sensor/analog_threshold`
2019-05-28 20:41:02 +02:00
- :ref: `sensor-filters`
- :apiref: `binary_sensor_map/binary_sensor_map.h`
2023-04-13 07:12:39 +02:00
- `Bayesian sensor in Home Assistant <https://www.home-assistant.io/integrations/bayesian/> `__
2019-05-28 20:41:02 +02:00
- :ghedit: `Edit`