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

MQTT Alarm Keypad will not display in Lovelace without a fixed "code" number #47234

Closed
rocket4321 opened this issue Mar 1, 2021 · 13 comments
Closed
Assignees

Comments

@rocket4321
Copy link

The problem

First - I may not know if I'm setting up this component properly, as I translating an older HTTP alarm (polling data retrieval) component to use MQTT (for reduced latency).

Next, this request could be interpreted as either an improvement or issue. I hope since this change appears to be fairly small, and provides functionality that I assume should be available, that it's content is pushed forward for review. After all, at a high level, this change provides a functioning keypad for MQTT alarm. Currently, the keypad does not appear to work (for my use case).

What is version of Home Assistant Core has the issue?

Home Assistant 2021.2.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

mqtt

Link to integration documentation on our website

https://www.home-assistant.io/integrations/alarm_control_panel.mqtt/

Example YAML snippet

  - platform: mqtt
    state_topic: "tele/alarm/partitions/1/state"
    command_topic: "cmnd/alarm/set"
    code_arm_required: false
    code_disarm_required: true
    name: "alarm"
    retain: true

Anything in the logs that might be useful for us?

# Put your logs below this line

The above configuration will NOT produce a keypad in lovelace, since within the code below and config above, code is not defined, so no format is returned:

--- components/mqtt/alarm_control_panel.py

...
    def code_format(self):
        """Return one or more digits/characters."""
        code = self._config.get(CONF_CODE)
        if code is None:
            return None
...

Currently, if a code is defined, such as "0000" then a keypad is displayed in lovelace, but ONLY that code is transmitted to the alarm for actions. This hard-coded value negates the value of having a keypad displayed to the user.

Rather, the code that the user enters in the keypad should be transmitted to the device only when a code is NOT defined. (Right?) So how can we make sure the keypad is displayed? Here is my proposed solution:

-- Create of new optional config element for mqtt alarm:

...
# Add this to consts
CONF_CODE_FORMAT = "code_format"

# In PLATFORM_SCHEMA
            vol.Optional(CONF_CODE_FORMAT, default=None): cv.string,

# Replace
    def code_format(self):
        """Return one or more digits/characters."""
        code_format = self._config.get(CONF_CODE_FORMAT)
        if code_format is not None:
            return code_format
        code = self._config.get(CONF_CODE)
        if code is None:
            return None
        if isinstance(code, str) and re.search("^\\d+$", code):
            return alarm.FORMAT_NUMBER
        return alarm.FORMAT_TEXT
  - platform: mqtt
    state_topic: "tele/nx584/partitions/1/state"
    command_topic: "cmnd/nx584/action"
    command_template: "{{action}},1,{{code}}"
    code_arm_required: false
    code_disarm_required: true
    code_format: "number"
    name: "security"
    retain: true
@probot-home-assistant
Copy link

mqtt documentation
mqtt source
(message by IssueLinks)

@rocket4321

This comment was marked as abuse.

@rocket4321

This comment was marked as abuse.

@emontnemery
Copy link
Contributor

Not at all pushy, a PR would be highly appreciated 👍

@rocket4321

This comment was marked as abuse.

@emontnemery
Copy link
Contributor

MQTT configuration through yaml is fully supported and not planned to be removed or deprecated.

@rocket4321

This comment was marked as abuse.

@emontnemery
Copy link
Contributor

Let me put it this way:
If you go ahead and open a PR improving/extending MQTT alarm_control_panel as you propose in the description of this issue, that PR won't be rejected based on ADR-0007 or ADR-0010.

@rocket4321

This comment was marked as abuse.

@frenck
Copy link
Member

frenck commented Mar 22, 2021

Am I reading this wrong?

@rocket4321 Yes, you are. Please read ADR-0010, you will notice that it applies to integrations that connects to a device or service. MQTT defines a transport, to which ADR-0010 does not apply to. As a matter of fact, MQTT is even listed as an example in that ADR.

I'm sorry you feel bad for what happened, but that is the design decision taken by the project and its members. I rather close fast with the reason, than one put in even more energy (with a non-merge as a result).

@rocket4321

This comment was marked as abuse.

@frenck
Copy link
Member

frenck commented Mar 22, 2021

Alright, that is your call.

@emontnemery
Copy link
Contributor

I'm closing this since it's basically a feature request.

@rocket4321 Again, a PR to add this support to MQTT alarm_control_panel would be appreciated.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants