8000 Minor update to manual alarm_control_panel to publish the arming/pending duration by jcooper-korg · Pull Request #41872 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Minor update to manual alarm_control_panel to publish the arming/pending duration #41872

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

Closed
wants to merge 5 commits into from
Closed
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
7 changes: 7 additions & 0 deletions homeassistant/components/manual/alarm_control_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@

ATTR_PREVIOUS_STATE = "previous_state"
ATTR_NEXT_STATE = "next_state"
ATTR_STATE_DURATION = "state_duration"


def _state_validator(config):
Expand Down Expand Up @@ -395,9 +396,15 @@ def _validate_code(self, code, state):
def device_state_attributes(self):
"""Return the state attributes."""
if self.state == STATE_ALARM_PENDING or self.state == STATE_ALARM_ARMING:
state_duration = (
self._pending_time(self._previous_state)
if self.state == STATE_ALARM_PENDING
else self._arming_time(self._state)
)
return {
ATTR_PREVIOUS_STATE: self._previous_state,
ATTR_NEXT_STATE: self._state,
ATTR_STATE_DURATION: state_duration.total_seconds(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't set config values in the state machine.

}
return {}

Expand Down
0