FutureTense / keymaster

Home Assistant integration for managing Z-Wave enabled locks
MIT License
219 stars 43 forks source link

ISSUE: Creating a child lock under a parent removes all Entities with the name "input_text" and breaks the parent #231

Closed WaveSigns closed 2 years ago

WaveSigns commented 2 years ago

I am working on a brand new home assistant installation with HACS and KeyMaster.

When I create a new keymaster lock and add codes. Things work as expected. What is puzzling is when I add a 2nd lock with a parent - all of the entities with the name "input_text" are deleted/removed, which then breaks the Lovelace integration. If I remove the child association with the key master, things work as expected.

Logs The configuration for HA also gets corrupted with the following error and gets resolved once I remove the new Keymaster entry.

Invalid config for [input_text]: invalid slug reard_Front_parent (try reard_front_parent) for dictionary value @ data['input_text']. Got OrderedDict([('reard_name_1', OrderedDict([('name', 'Name')])), ('reard_pin_1', OrderedDict([('name', 'PIN'), ('mode', 'password')])), ('reard_name_2', OrderedDict([('name', 'Name')])), ('reard_pin_2', OrderedDict([('name', 'PIN'), ('mode', 'password')])), ('reard_name_3', OrderedDict([('name', 'Name')])), ('reard_pin_3', OrderedDict([('name', 'PIN'), ('mode', 'password')])), ('reard_name_4', OrderedDict([('name', 'Name')])), ('reard_pin_4', OrderedDict([('name', 'PIN'), ('mode', 'password')].... (See ?, line ?).

The first two lines are when I made the second key master entry without a parent. It had two minor warnings. When I added the parent, errors came up.

Warnings ``` 2021-09-27 21:11:37 WARNING (MainThread) [homeassistant.helpers.service] Unable to find referenced entities timer.keymaster_reard_autolock 2021-09-27 21:14:24 WARNING (MainThread) [homeassistant.helpers.service] Unable to find referenced entities timer.keymaster_doorrear_autolock 2021-09-27 21:15:50 ERROR (MainThread) [homeassistant.components.automation.keymaster_override_parent_doorrear_1_state_change] keymaster_override_parent_doorrear_1_state_change: Error executing script. Service not found for call_service at pos 1: Unable to find service script.keymaster_doorrear_copy_from_parent_1 2021-09-27 21:15:50 ERROR (MainThread) [homeassistant.components.automation.keymaster_override_parent_doorrear_1_state_change] Error while executing automation automation.keymaster_override_parent_doorrear_1_state_change: Unable to find service script.keymaster_doorrear_copy_from_parent_1 2021-09-27 21:15:50 ERROR (MainThread) [homeassistant.components.automation.keymaster_override_parent_doorrear_2_state_change] keymaster_override_parent_doorrear_2_state_change: Error executing script. Service not found for call_service at pos 1: Unable to find service script.keymaster_doorrear_copy_from_parent_2 2021-09-27 21:15:50 ERROR (MainThread) [homeassistant.components.automation.keymaster_override_parent_doorrear_2_state_change] Error while executing automation automation.keymaster_override_parent_doorrear_2_state_change: Unable to find service script.keymaster_doorrear_copy_from_parent_2 2021-09-27 21:15:50 ERROR (MainThread) [homeassistant.components.automation.keymaster_override_parent_doorrear_3_state_change] keymaster_override_parent_doorrear_3_state_change: Error executing script. Service not found for call_service at pos 1: Unable to find service script.keymaster_doorrear_copy_from_parent_3 2021-09-27 21:15:50 ERROR (MainThread) [homeassistant.components.automation.keymaster_override_parent_doorrear_3_state_change] Error while executing automation automation.keymaster_override_parent_doorrear_3_state_change: Unable to find service script.keymaster_doorrear_copy_from_parent_3 2021-09-27 21:15:50 ERROR (MainThread) [homeassistant.components.automation.keymaster_override_parent_doorrear_4_state_change] keymaster_override_parent_doorrear_4_state_change: Error executing script. Service not found for call_service at pos 1: Unable to find service script.keymaster_doorrear_copy_from_parent_4 2021-09-27 21:15:50 ERROR (MainThread) [homeassistant.components.automation.keymaster_override_parent_doorrear_4_state_change] Error while executing automation automation.keymaster_override_parent_doorrear_4_state_change: Unable to find service script.keymaster_doorrear_copy_from_parent_4 2021-09-27 21:15:50 ERROR (MainThread) [homeassistant.components.automation.keymaster_override_parent_doorrear_5_state_change] keymaster_override_parent_doorrear_5_state_change: Error executing script. Service not found for call_service at pos 1: Unable to find service script.keymaster_doorrear_copy_from_parent_5 2021-09-27 21:15:50 ERROR (MainThread) [homeassistant.components.automation.keymaster_override_parent_doorrear_5_state_change] Error while executing automation automation.keymaster_override_parent_doorrear_5_state_change: Unable to find service script.keymaster_doorrear_copy_from_parent_5 2021-09-27 21:15:50 ERROR (MainThread) [homeassistant.components.automation.keymaster_override_parent_doorrear_6_state_change] keymaster_override_parent_doorrear_6_state_change: Error executing script. Service not found for call_service at pos 1: Unable to find service script.keymaster_doorrear_copy_from_parent_6 2021-09-27 21:15:50 ERROR (MainThread) [homeassistant.components.automation.keymaster_override_parent_doorrear_6_state_change] Error while executing automation automation.keymaster_override_parent_doorrear_6_state_change: Unable to find service script.keymaster_doorrear_copy_from_parent_6 ```
firstof9 commented 2 years ago

Please verify if this is still broken in 0.0.76.

SomeComputerGuy commented 2 years ago

I am running into the same issue in 0.0.76:

Logger: homeassistant.components.automation.keymaster_override_parent_side_door_1_state_change Source: helpers/script.py:1344 Integration: Automation (documentation, issues) First occurred: 5:43:21 PM (1 occurrences) Last logged: 5:43:21 PM

keymaster_override_parent_side_door_1_state_change: Error executing script. Service not found for call_service at pos 1: Unable to find service script.keymaster_side_door_copy_from_parent_1

Error while executing automation automation.keymaster_override_parent_side_door_4_state_change: Unable to find service script.keymaster_side_door_copy_from_parent_4 5:43:21 PM – (ERROR) Automation

Error while executing automation automation.keymaster_override_parent_side_door_3_state_change: Unable to find service script.keymaster_side_door_copy_from_parent_3 5:43:21 PM – (ERROR) Automation

Error while executing automation automation.keymaster_override_parent_side_door_2_state_change: Unable to find service script.keymaster_side_door_copy_from_parent_2 5:43:21 PM – (ERROR) Automation Error while executing automation automation.keymaster_override_parent_side_door_1_state_change: Unable to find service script.keymaster_side_door_copy_from_parent_1 5:43:21 PM – (ERROR) Automation

keymaster_override_parent_side_door_4_state_change: Error executing script. Service not found for call_service at pos 1: Unable to find service script.keymaster_side_door_copy_from_parent_4 5:43:21 PM – (ERROR) Automation

keymaster_override_parent_side_door_3_state_change: Error executing script. Service not found for call_service at pos 1: Unable to find service script.keymaster_side_door_copy_from_parent_3 5:43:21 PM – (ERROR) Automation

keymaster_override_parent_side_door_2_state_change: Error executing script. Service not found for call_service at pos 1: Unable to find service script.keymaster_side_door_copy_from_parent_2 5:43:21 PM – (ERROR) Automation

keymaster_override_parent_side_door_1_state_change: Error executing script. Service not found for call_service at pos 1: Unable to find service script.keymaster_side_door_copy_from_parent_1

Logger: homeassistant.config Source: config.py:464 First occurred: 5:43:18 PM (153 occurrences) Last logged: 5:43:28 PM

Invalid config for [automation]: Service {% if (states.input_boolean.fri_inc_Inside Door_4.state == 'on') %} input_boolean.turn_on {% else %} input_boolean.turn_off {% endif %} does not match format . for dictionary value @ data['action'][0]['service_template']. Got None. (See ?, line ?). Invalid config for [automation]: invalid template (TemplateSyntaxError: expected token 'end of print statement', got 'Door_4') for dictionary value @ data['action'][0]['data']. Got None. (See ?, line ?). Invalid config for [automation]: Service {% if (states.input_boolean.sat_Inside Door_4.state == 'on') %} input_boolean.turn_on {% else %} input_boolean.turn_off {% endif %} does not match format . for dictionary value @ data['action'][0]['service_template']. Got None. (See ?, line ?). Invalid config for [automation]: Service {% if (states.input_boolean.sat_inc_Inside Door_4.state == 'on') %} input_boolean.turn_on {% else %} input_boolean.turn_off {% endif %} does not match format . for dictionary value @ data['action'][0]['service_template']. Got None. (See ?, line ?). Invalid config for [input_text]: invalid slug side_door_Inside Door_parent (try side_door_inside_door_parent) for dictionary value @ data['input_text']. Got OrderedDict([('side_door_name_1', OrderedDict([('name', 'Name')])), ('side_door_pin_1', OrderedDict([('name', 'PIN'), ('mode', 'text')])), ('side_door_name_2', OrderedDict([('name', 'Name')])), ('side_door_pin_2', OrderedDict([('name', 'PIN'), ('mode', 'text')])), ('side_door_name_3', OrderedDict([('name', 'Name')])), ('side_door_pin_3', OrderedDict([('name', 'PIN'), ('mode', 'text')])), ('side_door_name_4', OrderedDict([('name', 'Name')])), ('side_door_pin_4', OrderedDict([('name', 'PIN'), (.... (See ?, line ?). Please check the docs at https://www.home-assistant.io/integrations/input_text

firstof9 commented 2 years ago

Make sure you regenerate the yaml files, either via the service call or by reconfiguring the integration.

SomeComputerGuy commented 2 years ago

I believe I did what you are asking, but still have the same problem.

I removed all Keymaster integrations, rebooted, added Inside Door, then added a second instance of the integration Side Door.

I still am having the same behavior - when I copy over the inside_door_lovelace code over, I see the broken Input Text fields.

I tried going back and re-configuring each of the integrations after adding them, and I still get the same result.

Am I missing a step here?

firstof9 commented 2 years ago

states.input_boolean.fri_inc_Inside Door_4.state some how your getting a space in the name.

Whole different issue than what's reported here.

SomeComputerGuy commented 2 years ago

OK - that was a hint. I was able to get it to work now.

When configuring the integration, there is a field called "Lock Name (ie. frontdoor)". I had this field set to "Inside Door" (with the space).

When I removed everything and re-configured without the space (instead using "inside_door" and "side_door" respectively), I no longer see the Input Text field errors.

I removed the working automation, and again tried a setup with a space in the Lock Name field, and it again fails with Input Text errors.

I made it work again (removed the spaces) and am testing it now. Thanks for the pointer!

kaechele commented 2 years ago

Seems like still not everything is correctly slugified on 0.0.77:

Logger: homeassistant.config
Source: config.py:464
First occurred: 1:12:55 PM (382 occurrences)
Last logged: 1:20:40 PM

Invalid config for [automation]: Service {% if (states.input_boolean.fri_inc_Front Door_5.state == 'on') %} input_boolean.turn_on {% else %} input_boolean.turn_off {% endif %} does not match format <domain>.<name> for dictionary value @ data['action'][0]['service_template']. Got None. (See ?, line ?).
Invalid config for [automation]: template value should be a string for dictionary value @ data['action'][0]['data']. Got None. (See ?, line ?).
Invalid config for [automation]: Service {% if (states.input_boolean.sat_Front Door_5.state == 'on') %} input_boolean.turn_on {% else %} input_boolean.turn_off {% endif %} does not match format <domain>.<name> for dictionary value @ data['action'][0]['service_template']. Got None. (See ?, line ?).
Invalid config for [automation]: Service {% if (states.input_boolean.sat_inc_Front Door_5.state == 'on') %} input_boolean.turn_on {% else %} input_boolean.turn_off {% endif %} does not match format <domain>.<name> for dictionary value @ data['action'][0]['service_template']. Got None. (See ?, line ?).
Invalid config for [input_text]: invalid slug garage_door_Front Door_parent (try garage_door_front_door_parent) for dictionary value @ data['input_text']. Got OrderedDict([('garage_door_name_1', OrderedDict([('name', 'Name')])), ('garage_door_pin_1', OrderedDict([('name', 'PIN'), ('mode', 'password')])), ('garage_door_name_2', OrderedDict([('name', 'Name')])), ('garage_door_pin_2', OrderedDict([('name', 'PIN'), ('mode', 'password')])), ('garage_door_name_3', OrderedDict([('name', 'Name')])), ('garage_door_pin_3', OrderedDict([('name', 'PIN'), ('mode', 'password')])), ('garage_door_name_4', OrderedDict([('name', 'Name')])), ('garage_door_pin_4', Ord.... (See ?, line ?). Please check the docs at https://www.home-assistant.io/integrations/input_text
kaechele commented 2 years ago

Needs to be slugified as well: https://github.com/firstof9/keymaster/blob/main/custom_components/keymaster/services.py#L345

"PARENTLOCK": "" if primary_lock.parent is None else slugify(primary_lock.parent),
firstof9 commented 2 years ago

Feel free to submit a PR

kaechele commented 2 years ago

Will do :) After I'm done with work for the day.