-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
Minor update to manual alarm_control_panel to publish the arming/pending duration #41872
Conversation
…resenting the number of seconds until the state change
Hi @jcooper-korg, It seems you haven't yet signed a CLA. Please do so here. Once you do that we will be able to review and accept this pull request. Thanks! |
not sure what to do about it failing flake8. it says:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
I pushed a couple trivial commits to force it to rerun the flake8 test. but it's still failing due to some server issue. please let me know if there's some other way to retrigger the flake8 test to get this passing! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, we won't accept this PR.
return { | ||
ATTR_PREVIOUS_STATE: self._previous_state, | ||
ATTR_NEXT_STATE: self._state, | ||
ATTR_STATE_DURATION: state_duration.total_seconds(), |
There was a problem hiding this comment.
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.
I'll close here now. Still, thanks for your contribution! |
@MartinHjelmare , thanks for your review. You said
This change is not intended to set a config value. It is publishing the duration of the current state as an attribute (in device_state_attributes), so that it can be accessed from a client like a Lovelace alarm panel card. The duration value is chosen by the alarm state machine, depending on its internal state. Yes, the duration ultimately did come from its config settings, but it had to choose the value based on internal alarm state. Could you please advise how else this value could be obtained to accomplish the same goal? |
I don't have any suggestions at the moment. |
Can you then please cite a more detailed reason why this was rejected? You said "We don't set config values in the state machine", but that's not what this change is doing, IIUC. I'd like to understand what you're saying so I can try to figure out a different way to accomplish it. |
The alarm times are configured. We don't allow storing configuration in the state machine. |
Can you please point me to documentation/advice on how to access config values from a javascript Lovelace card? e.g. if my configuration.yaml has the following, I'd need a way to extract the values for armed_away/arming_time and delay_time.
Thanks again, |
@jcooper-korg If you have development questions, please join our Discord server. We have developer channels over there to provide developer support. Thanks 👍 |
Will do, thanks. |
Add new state_duration attribute when in arming or pending state, representing the number of seconds until the state change.
Proposed change
In order to show a countdown timer in an alarm panel control card, the card needs a way to know the duration of the current alarm state (when the alarm enters the arming/pending states). There is no other way for the card to obtain this time, since it depends on the alarm panel configuration settings for the Home/Away/etc states.
So when the alarm enters the pending/arming state, it simply adds an attribute "state_duration" to the device_state_attributes.
This is a very minor change, but enables a very nice improvement in the alarm control panel GUI.
An example custom alarm card with full config example, explanation and screenshots is at https://github.com/jcooper-korg/AlarmPanel
Type of change
Example entry for
configuration.yaml
:Full example config is at https://github.com/jcooper-korg/AlarmPanel
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: