Action parameter doesn't longer have to be the first parameter#14815
Action parameter doesn't longer have to be the first parameter#14815fabaff merged 2 commits intohome-assistant:devfrom GruberMischa:fix-unordered-parameters
Conversation
|
Hi @GruberMischa, 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! |
| if button_action not in ['single', 'double', 'long', 'touch']: | ||
| button_action = None | ||
| parameter_list = list(data.keys()) | ||
| for parameter in parameter_list: |
There was a problem hiding this comment.
button_action = next((
parameter for parameter in data
if parameter in self.supported_actions), None)|
Added @MartinHjelmare's suggestion |
|
Documentation update attached because I left |
|
Works with Firmware 2.56 2018-06-05 17:29:40 INFO (MainThread) [homeassistant.components.http.view] Serving /api/mystrom to 192.168.0.227 (auth: True)
2018-06-05 17:29:40 INFO (MainThread) [homeassistant.components.binary_sensor.mystrom] New myStrom button/action detected: button_green/single
2018-06-05 17:29:40 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=binary_sensor.button_green_single, old_state=None, new_state=<state binary_sensor.button_green_single=off; friendly_name=button_green_single @ 2018-06-05T17:29:40.458983+02:00>>Now there is an issue: If there is no password provided for one action of the button and that action is triggered then it's logged as login attempt. 2018-06-05 17:30:15 WARNING (MainThread) [homeassistant.components.http.ban] Login attempt or request with invalid authentication from 192.168.0.227If one uses, let's says, has set |
|
So what do you suggest? Adding a warning about this scenario in the docs? |
Yes, we will cover this in the docs (55580b9). |
…assistant#14815) * Action parameter doesn't longer have to be the first parameter * Minified code upon suggestion
Description:
The component no longer asumes, that the first parameter is the desired action. Looks throw the list and takes the first acceptable action.
Previously if the api_password parameter was passed and it was the first in the list, the component didn't work.
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#5497
Checklist:
tox. Your PR cannot be merged unless tests pass