二值传感器映射
binary_sensor_map 传感器平台允许您将多个 二值传感器
映射到单个值。根据每个二值传感器的状态、其关联的配置参数以及此传感器的映射类型,
binary_sensor_map 发布单个数值。
使用此传感器将一个或多个二值传感器的 ON 或 OFF 状态组合为数值。一些可能的用例包括
触摸设备和确定事件的贝叶斯概率。
此平台支持三种测量类型:BAYESIAN、GROUP 和 SUM。
您需要使用 type: 配置值指定所需的映射。
当使用 BAYESIAN 类型时,将二值传感器作为 observations 添加到二值传感器映射中。
如果使用 GROUP 或 SUM 类型,将二值传感器作为 channels 添加。
支持的最大观察值/通道数为 64。
BAYESIAN此类型复制 Home Assistant 的 贝叶斯传感器。根据观察值状态,此传感器返回特定事件发生的贝叶斯概率。配置的prior:概率是贝叶斯事件为真的可能性,忽略所有外部影响。每个观察值都有自己的prob_given_true和prob_given_false参数。prob_given_true:值是在贝叶斯事件为true时观察值二值传感器为ON的概率。prob_given_false:值是在贝叶斯事件为false时观察值二值传感器为ON的概率。使用 模拟阈值 通过设置适当的阈值,将此传感器的概率转换为二值ON或OFF。
# Example configuration entrysensor: - 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: # If the Bayesian probability is greater than 0.6, # then predict the event is occurring - platform: analog_threshold name: "Bayesian Event Predicted State" sensor_id: bayesian_prob threshold: 0.6 # ...GROUP每个通道都有自己的value。传感器发布所有活动 二值传感器的平均值,如果没有传感器活动则发布NAN。
# Example configuration entrysensor: - 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 componentmpr121: id: mpr121_first address: 0x5A
binary_sensor: - platform: mpr121 channel: 0 id: touchkey0 # ...SUM每个通道都有自己的value。传感器发布所有活动 二值传感器值的总和,如果没有传感器活动则发布0。
# Example configuration entrysensor: - 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 pin: GPIOXX id: bit0
- platform: gpio pin: GPIOXX id: bit1
- platform: gpio pin: GPIOXX id: bit2
- platform: gpio pin: GPIOXX id: bit3 # ...-
type (必选, string): 传感器类型。应为以下之一:
BAYESIAN、GROUP或SUM。 -
channels (GROUP 或 SUM 类型必填): 映射到特定值的通道列表。
-
binary_sensor (必选): 要作为此传感器的通道添加的 二值传感器 的 id。
-
value (必选): 当其二值传感器活动时,此通道应报告的值。
-
-
prior (BAYESIAN 类型必填, 0 到 1 之间的 float): 事件的先验概率。
-
observations (BAYESIAN 类型必填): 影响事件贝叶斯概率的观察值列表。
-
binary_sensor (必选): 要作为观察值添加的 二值传感器 的 id。
-
prob_given_true (必选, 0 到 1 之间的 float): 假设事件为真,此观察值为开的概率。
-
prob_given_false (必选, 0 到 1 之间的 float): 假设事件为假,此观察值为开的概率。
-
-
来自 Sensor 的所有其他选项。