Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MQTT Discovery Entities for Config Buttons in Home Assistant #542

Merged
merged 2 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 153 additions & 1 deletion insteon_mqtt/data/config-base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ mqtt:
discovery_ha_status: 'homeassistant/status'

# This is a variable that is available for use in all templates, as
# {{device_info_template}}. It is envisioned that it would be used to set
# {{device_info}}. It is envisioned that it would be used to set
# the device map information, see e.g.
# https://www.home-assistant.io/integrations/switch.mqtt/#device
# While the identifiers or (ids) section is listed as optional, it has been
Expand Down Expand Up @@ -389,6 +389,66 @@ mqtt:
{\"timestamp\": {{value_json.timestamp}}, \"mode\": \"{{value_json.mode}}\", \"reason\": \"{{value_json.reason}}\"}
{%- endraw -%}"
val_tpl: "{% raw %}{{value_json.state}}{% endraw %}"
join_button: &join_button
component: 'button'
config:
uniq_id: "{{address}}_join"
name: "Join"
avty_t: "{{availability_topic}}"
ent_cat: "config"
cmd_t: "insteon/command/{{address}}"
cmd_tpl: "{\"cmd\": \"join\", \"session\": \"homeassistant\"}"
device: "{{device_info}}"
pair_button: &pair_button
component: 'button'
config:
uniq_id: "{{address}}_pair"
name: "Pair"
avty_t: "{{availability_topic}}"
ent_cat: "config"
cmd_t: "insteon/command/{{address}}"
cmd_tpl: "{\"cmd\": \"pair\", \"session\": \"homeassistant\"}"
device: "{{device_info}}"
sync_button: &sync_button
component: 'button'
config:
uniq_id: "{{address}}_sync"
name: "Sync"
avty_t: "{{availability_topic}}"
ent_cat: "config"
cmd_t: "insteon/command/{{address}}"
cmd_tpl: "{\"cmd\": \"sync\", \"dry_run\": false, \"session\": \"homeassistant\"}"
device: "{{device_info}}"
refresh_button: &refresh_button
component: 'button'
config:
uniq_id: "{{address}}_refresh"
name: "Refresh"
avty_t: "{{availability_topic}}"
ent_cat: "config"
cmd_t: "insteon/command/{{address}}"
cmd_tpl: "{\"cmd\": \"refresh\", \"force\": true, \"session\": \"homeassistant\"}"
device: "{{device_info}}"
engine_button: &engine_button
component: 'button'
config:
uniq_id: "{{address}}_get_engine"
name: "Get Engine Version"
avty_t: "{{availability_topic}}"
ent_cat: "config"
cmd_t: "insteon/command/{{address}}"
cmd_tpl: "{\"cmd\": \"get_engine\", \"session\": \"homeassistant\"}"
device: "{{device_info}}"
log_sensor: &log_sensor
component: 'sensor'
config:
uniq_id: "{{address}}_log"
name: "Log"
avty_t: "{{availability_topic}}"
ent_cat: "diagnostic"
stat_t: "insteon/command/{{address}}/session/homeassistant"
device: "{{device_info}}"
val_tpl: "{%- raw -%}{% if value_json.type == 'MESSAGE' %} {{value_json.data}} {% else %} {{ 0/0 }} {%endif %}{%- endraw -%}"

dimmer:
#------------------------------------------------------------------------
Expand Down Expand Up @@ -506,6 +566,12 @@ mqtt:
json_attr_tpl: "{%- raw -%}
{\"timestamp\": {{value_json.timestamp}}, \"mode\": \"{{value_json.mode}}\", \"reason\": \"{{value_json.reason}}\"}
{%- endraw -%}"
join_button: *join_button
pair_button: *pair_button
refresh_button: *refresh_button
engine_button: *engine_button
sync_button: *sync_button
log_sensor: *log_sensor

battery_sensor:
#------------------------------------------------------------------------
Expand Down Expand Up @@ -602,6 +668,22 @@ mqtt:
device: "{{device_info}}"
force_update: true
val_tpl: "{%- raw -%}{{as_datetime(value|float|timestamp_local).isoformat()|string}}{%- endraw -%}"
awake_button: &awake_button
component: 'button'
config:
uniq_id: "{{address}}_awake"
name: "Mark Awake"
avty_t: "{{availability_topic}}"
ent_cat: "config"
cmd_t: "insteon/command/{{address}}"
cmd_tpl: "{\"cmd\": \"awake\", \"session\": \"homeassistant\"}"
device: "{{device_info}}"
join_button: *join_button
pair_button: *pair_button
refresh_button: *refresh_button
engine_button: *engine_button
sync_button: *sync_button
log_sensor: *log_sensor

motion:
#------------------------------------------------------------------------
Expand Down Expand Up @@ -675,6 +757,13 @@ mqtt:
{\"timestamp\": {{value_json.timestamp}}}
{%- endraw -%}"
val_tpl: "{% raw %}{{value_json.state}}{% endraw %}"
awake_button: *awake_button
join_button: *join_button
pair_button: *pair_button
refresh_button: *refresh_button
engine_button: *engine_button
sync_button: *sync_button
log_sensor: *log_sensor

hidden_door:
#------------------------------------------------------------------------
Expand Down Expand Up @@ -757,6 +846,13 @@ mqtt:
{\"timestamp\": {{value_json.timestamp}}}
{%- endraw -%}"
val_tpl: "{% raw %}{{value_json.voltage}}{% endraw %}"
awake_button: *awake_button
join_button: *join_button
pair_button: *pair_button
refresh_button: *refresh_button
engine_button: *engine_button
sync_button: *sync_button
log_sensor: *log_sensor

leak:
#------------------------------------------------------------------------
Expand Down Expand Up @@ -815,6 +911,13 @@ mqtt:
device_class: "timestamp"
device: "{{device_info}}"
val_tpl: "{%- raw -%}{{as_datetime(value|float|timestamp_local).isoformat()|string}}{%- endraw -%}"
awake_button: *awake_button
join_button: *join_button
pair_button: *pair_button
refresh_button: *refresh_button
engine_button: *engine_button
sync_button: *sync_button
log_sensor: *log_sensor

remote:
#------------------------------------------------------------------------
Expand Down Expand Up @@ -996,6 +1099,13 @@ mqtt:
{\"timestamp\": {{value_json.timestamp}}}
{%- endraw -%}"
val_tpl: "{% raw %}{{value_json.state}}{% endraw %}"
awake_button: *awake_button
join_button: *join_button
pair_button: *pair_button
refresh_button: *refresh_button
engine_button: *engine_button
sync_button: *sync_button
log_sensor: *log_sensor

smoke_bridge:
#------------------------------------------------------------------------
Expand Down Expand Up @@ -1064,6 +1174,12 @@ mqtt:
avty_t: "{{availability_topic}}"
device_class: "problem"
device: "{{device_info}}"
join_button: *join_button
pair_button: *pair_button
refresh_button: *refresh_button
engine_button: *engine_button
sync_button: *sync_button
log_sensor: *log_sensor

thermostat:
#------------------------------------------------------------------------
Expand Down Expand Up @@ -1174,6 +1290,12 @@ mqtt:
"temp_lo_stat_t": "{{heat_sp_state_topic}}"
"temp_lo_stat_tpl": "{% raw %}{{value_json.temp_f}}{% endraw %}"
"temperature_unit": "F"
join_button: *join_button
pair_button: *pair_button
refresh_button: *refresh_button
engine_button: *engine_button
sync_button: *sync_button
log_sensor: *log_sensor

fan_linc:
#------------------------------------------------------------------------
Expand Down Expand Up @@ -1286,6 +1408,12 @@ mqtt:
json_attr_tpl: "{%- raw -%}
{\"timestamp\": {{value_json.timestamp}}, \"mode\": \"{{value_json.mode}}\", \"reason\": \"{{value_json.reason}}\"}
{%- endraw -%}"
join_button: *join_button
pair_button: *pair_button
refresh_button: *refresh_button
engine_button: *engine_button
sync_button: *sync_button
log_sensor: *log_sensor

keypad_linc:
#------------------------------------------------------------------------
Expand Down Expand Up @@ -1581,6 +1709,12 @@ mqtt:
{\"timestamp\": {{value_json.timestamp}}, \"mode\": \"{{value_json.mode}}\", \"reason\": \"{{value_json.reason}}\"}
{%- endraw -%}"
val_tpl: "{% raw %}{{value_json.state}}{% endraw %}"
join_button: *join_button
pair_button: *pair_button
refresh_button: *refresh_button
engine_button: *engine_button
sync_button: *sync_button
log_sensor: *log_sensor

io_linc:
#------------------------------------------------------------------------
Expand Down Expand Up @@ -1682,6 +1816,12 @@ mqtt:
json_attr_tpl: "{%- raw -%}
{\"timestamp\": {{value_json.timestamp}}, \"mode\": \"{{value_json.mode}}\", \"reason\": \"{{value_json.reason}}\"}
{%- endraw -%}"
join_button: *join_button
pair_button: *pair_button
refresh_button: *refresh_button
engine_button: *engine_button
sync_button: *sync_button
log_sensor: *log_sensor

outlet:
#------------------------------------------------------------------------
Expand Down Expand Up @@ -1767,6 +1907,12 @@ mqtt:
{\"timestamp\": {{value_json.timestamp}}, \"mode\": \"{{value_json.mode}}\", \"reason\": \"{{value_json.reason}}\"}
{%- endraw -%}"
val_tpl: "{% raw %}{{value_json.state}}{% endraw %}"
join_button: *join_button
pair_button: *pair_button
refresh_button: *refresh_button
engine_button: *engine_button
sync_button: *sync_button
log_sensor: *log_sensor

ezio4o:
#------------------------------------------------------------------------
Expand Down Expand Up @@ -1856,5 +2002,11 @@ mqtt:
cmd_t: "{{on_off_topic_4}}"
stat_t: "{{state_topic_4}}"
device: "{{device_info}}"
join_button: *join_button
pair_button: *pair_button
refresh_button: *refresh_button
engine_button: *engine_button
sync_button: *sync_button
log_sensor: *log_sensor

#----------------------------------------------------------------
4 changes: 3 additions & 1 deletion insteon_mqtt/data/config-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ insteon:
type: string
via_device:
type: string
sn:
type: string
allow_unknown:
type: dict
schema:
Expand Down Expand Up @@ -226,7 +228,7 @@ mqtt:
schema: &discovery_entity
component:
type: string
allowed: ['alarm_control_panel', 'binary_sensor', 'camera',
allowed: ['alarm_control_panel', 'binary_sensor', 'button', 'camera',
'cover', 'device_tracker', 'device_trigger', 'fan',
'climate', 'light', 'lock', 'scene', 'sensor',
'switch', 'tag', 'vacuum']
Expand Down
Loading