From d4685e25a613c4a44ad22d57a1895f2904c04b12 Mon Sep 17 00:00:00 2001 From: firstof9 Date: Fri, 9 Oct 2020 13:27:54 -0700 Subject: [PATCH 1/4] Fix small bug with dirty ui workaround * Updated input_text for pin to input_number where needed --- custom_components/lock-manager/__init__.py | 16 +++++++++------- custom_components/lock-manager/lock_manager.yaml | 2 -- .../lock-manager/lock_manager_common.yaml | 4 ++-- custom_components/lock-manager/lovelace.code | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/custom_components/lock-manager/__init__.py b/custom_components/lock-manager/__init__.py index 4d3a9e3..4690c14 100644 --- a/custom_components/lock-manager/__init__.py +++ b/custom_components/lock-manager/__init__.py @@ -41,14 +41,16 @@ async def async_setup_entry(hass, config_entry): VERSION, ISSUE_URL, ) + generate_package = None # grab the bool before we change it - generate_package = config_entry.data[CONF_GENERATE] + if CONF_GENERATE in config_entry.data.keys(): + generate_package = config_entry.data[CONF_GENERATE] - # extract the data and manipulate it - config = {k: v for k, v in config_entry.data.items()} - config.pop(CONF_GENERATE) - config_entry.data = config + # extract the data and manipulate it + config = {k: v for k, v in config_entry.data.items()} + config.pop(CONF_GENERATE) + config_entry.data = config config_entry.options = config_entry.data config_entry.add_update_listener(update_listener) @@ -65,7 +67,7 @@ async def _generate_package(service): ) if entry.options[CONF_LOCK_NAME] == name: lockname = entry.options[CONF_LOCK_NAME] - inputlockpinheader = "input_text." + lockname + "_pin_" + inputlockpinheader = "input_number." + lockname + "_pin_" activelockheader = "binary_sensor.active_" + lockname + "_" lockentityname = entry.options[CONF_ENTITY_ID] sensorname = lockname @@ -189,7 +191,7 @@ async def _generate_package(service): ) # if the use turned on the bool generate the files - if generate_package: + if generate_package is not None: servicedata = {"lockname": config_entry.options[CONF_LOCK_NAME]} await hass.services.async_call(DOMAIN, SERVICE_GENERATE_PACKAGE, servicedata) diff --git a/custom_components/lock-manager/lock_manager.yaml b/custom_components/lock-manager/lock_manager.yaml index adfb264..f9c9e3f 100644 --- a/custom_components/lock-manager/lock_manager.yaml +++ b/custom_components/lock-manager/lock_manager.yaml @@ -10,8 +10,6 @@ input_number: LOCKNAME_pin_TEMPLATENUM: name: "PIN" mode: box - min: 4 - max: 8 ################# input_datetime: ############## input_datetime: diff --git a/custom_components/lock-manager/lock_manager_common.yaml b/custom_components/lock-manager/lock_manager_common.yaml index 628c037..a4cfd79 100644 --- a/custom_components/lock-manager/lock_manager_common.yaml +++ b/custom_components/lock-manager/lock_manager_common.yaml @@ -379,7 +379,7 @@ automation: {% set index = object_id.rfind('_') + 1 %} {% set code_slot = object_id[index:] %} {% set codetext = 'LOCKNAME_pin_' + code_slot | string %} - {% set code = states['input_text'][codetext].state %} + {% set code = states['input_number'][codetext].state %} {{ code | string }} - conditions: > {{ USINGOZW == False and states('binary_sensor.allow_automation') == "on" }} @@ -398,7 +398,7 @@ automation: {% set index = object_id.rfind('_') + 1 %} {% set code_slot = object_id[index:] %} {% set codetext = 'LOCKNAME_pin_' + code_slot | string %} - {% set code = states['input_text'][codetext].state %} + {% set code = states['input_number'][codetext].state %} {{ code | string }} - alias: CASE_LOCK_NAME Update Code diff --git a/custom_components/lock-manager/lovelace.code b/custom_components/lock-manager/lovelace.code index ede1c99..47f84e5 100644 --- a/custom_components/lock-manager/lovelace.code +++ b/custom_components/lock-manager/lovelace.code @@ -7,7 +7,7 @@ show_header_toggle: false entities: - entity: input_text.LOCKNAME_name_TEMPLATENUM - - entity: input_text.LOCKNAME_pin_TEMPLATENUM + - entity: input_number.LOCKNAME_pin_TEMPLATENUM - entity: input_boolean.enabled_LOCKNAME_TEMPLATENUM - entity: input_boolean.notify_LOCKNAME_TEMPLATENUM - type: divider From 30d2964998c36370f7960ad8e8a550a0c2ba0b7d Mon Sep 17 00:00:00 2001 From: firstof9 Date: Fri, 9 Oct 2020 13:40:10 -0700 Subject: [PATCH 2/4] Forgot input_number limits --- custom_components/lock-manager/lock_manager.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/custom_components/lock-manager/lock_manager.yaml b/custom_components/lock-manager/lock_manager.yaml index f9c9e3f..6df21e9 100644 --- a/custom_components/lock-manager/lock_manager.yaml +++ b/custom_components/lock-manager/lock_manager.yaml @@ -10,6 +10,8 @@ input_number: LOCKNAME_pin_TEMPLATENUM: name: "PIN" mode: box + min: 0 + max: 999999999999 ################# input_datetime: ############## input_datetime: From 3fa15c64c5a01e1fd3a76b892aab54050d11db26 Mon Sep 17 00:00:00 2001 From: firstof9 Date: Fri, 9 Oct 2020 14:09:47 -0700 Subject: [PATCH 3/4] Revert input_number changes --- custom_components/lock-manager/__init__.py | 2 +- custom_components/lock-manager/lock_manager.yaml | 9 +++------ custom_components/lock-manager/lock_manager_common.yaml | 4 ++-- custom_components/lock-manager/lovelace.code | 2 +- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/custom_components/lock-manager/__init__.py b/custom_components/lock-manager/__init__.py index 4690c14..4d3daea 100644 --- a/custom_components/lock-manager/__init__.py +++ b/custom_components/lock-manager/__init__.py @@ -67,7 +67,7 @@ async def _generate_package(service): ) if entry.options[CONF_LOCK_NAME] == name: lockname = entry.options[CONF_LOCK_NAME] - inputlockpinheader = "input_number." + lockname + "_pin_" + inputlockpinheader = "input_text." + lockname + "_pin_" activelockheader = "binary_sensor.active_" + lockname + "_" lockentityname = entry.options[CONF_ENTITY_ID] sensorname = lockname diff --git a/custom_components/lock-manager/lock_manager.yaml b/custom_components/lock-manager/lock_manager.yaml index 6df21e9..70a1440 100644 --- a/custom_components/lock-manager/lock_manager.yaml +++ b/custom_components/lock-manager/lock_manager.yaml @@ -7,12 +7,6 @@ input_number: step: 1 unit_of_measurement: "Openings Left" - LOCKNAME_pin_TEMPLATENUM: - name: "PIN" - mode: box - min: 0 - max: 999999999999 - ################# input_datetime: ############## input_datetime: end_date_LOCKNAME_TEMPLATENUM: @@ -92,6 +86,9 @@ input_text: LOCKNAME_name_TEMPLATENUM: name: "Name" + LOCKNAME_pin_TEMPLATENUM: + name: "PIN" + ################# input_boolean: ################ input_boolean: notify_LOCKNAME_TEMPLATENUM: diff --git a/custom_components/lock-manager/lock_manager_common.yaml b/custom_components/lock-manager/lock_manager_common.yaml index a4cfd79..628c037 100644 --- a/custom_components/lock-manager/lock_manager_common.yaml +++ b/custom_components/lock-manager/lock_manager_common.yaml @@ -379,7 +379,7 @@ automation: {% set index = object_id.rfind('_') + 1 %} {% set code_slot = object_id[index:] %} {% set codetext = 'LOCKNAME_pin_' + code_slot | string %} - {% set code = states['input_number'][codetext].state %} + {% set code = states['input_text'][codetext].state %} {{ code | string }} - conditions: > {{ USINGOZW == False and states('binary_sensor.allow_automation') == "on" }} @@ -398,7 +398,7 @@ automation: {% set index = object_id.rfind('_') + 1 %} {% set code_slot = object_id[index:] %} {% set codetext = 'LOCKNAME_pin_' + code_slot | string %} - {% set code = states['input_number'][codetext].state %} + {% set code = states['input_text'][codetext].state %} {{ code | string }} - alias: CASE_LOCK_NAME Update Code diff --git a/custom_components/lock-manager/lovelace.code b/custom_components/lock-manager/lovelace.code index 47f84e5..ede1c99 100644 --- a/custom_components/lock-manager/lovelace.code +++ b/custom_components/lock-manager/lovelace.code @@ -7,7 +7,7 @@ show_header_toggle: false entities: - entity: input_text.LOCKNAME_name_TEMPLATENUM - - entity: input_number.LOCKNAME_pin_TEMPLATENUM + - entity: input_text.LOCKNAME_pin_TEMPLATENUM - entity: input_boolean.enabled_LOCKNAME_TEMPLATENUM - entity: input_boolean.notify_LOCKNAME_TEMPLATENUM - type: divider From 6b019abb2c8de6b298879c3148294630bf0360a0 Mon Sep 17 00:00:00 2001 From: firstof9 Date: Fri, 9 Oct 2020 14:28:47 -0700 Subject: [PATCH 4/4] Version bump --- custom_components/lock-manager/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/lock-manager/const.py b/custom_components/lock-manager/const.py index af463ad..f287482 100644 --- a/custom_components/lock-manager/const.py +++ b/custom_components/lock-manager/const.py @@ -1,5 +1,5 @@ DOMAIN = "lock-manager" -VERSION = "0.0.20" +VERSION = "0.0.23" ISSUE_URL = "https://github.com/FutureTense/lock-manager" # Configuration Properties