mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-08-27 21:20:03 +00:00
Home Assistant: enable expose binary as switch for boolean values. https://github.com/Koenkk/zigbee2mqtt/issues/7797
This commit is contained in:
@@ -346,16 +346,18 @@ class HomeAssistant extends Extension {
|
||||
* https://github.com/Koenkk/zigbee2mqtt/issues/7740
|
||||
* Dont expose boolean values for now: https://github.com/Koenkk/zigbee2mqtt/issues/7797
|
||||
*/
|
||||
if (firstExpose.access & ACCESS_SET && typeof firstExpose.value_on !== 'boolean') {
|
||||
if (firstExpose.access & ACCESS_SET) {
|
||||
discoveryEntry = {
|
||||
type: 'switch',
|
||||
object_id: endpoint ?
|
||||
`switch_${firstExpose.name}_${endpoint}` :
|
||||
`switch_${firstExpose.name}`,
|
||||
discovery_payload: {
|
||||
value_template: `{{ value_json.${firstExpose.property} }}`,
|
||||
payload_on: firstExpose.value_on,
|
||||
payload_off: firstExpose.value_off,
|
||||
value_template: typeof firstExpose.value_on === 'boolean' ?
|
||||
`{% if value_json.${firstExpose.property} %} true {% else %} false {% endif %}` :
|
||||
`{{ value_json.${firstExpose.property} }}`,
|
||||
payload_on: firstExpose.value_on.toString(),
|
||||
payload_off: firstExpose.value_off.toString(),
|
||||
command_topic: true,
|
||||
command_topic_prefix: endpoint,
|
||||
command_topic_postfix: firstExpose.property,
|
||||
|
||||
Reference in New Issue
Block a user