FutureTense / keymaster

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

[Feature Request]: Stop using helpers and entities/solve the problem a different way #334

Open fireboy1919 opened 1 year ago

fireboy1919 commented 1 year ago

Is your feature request related to a problem? Please describe. Consider this function which I use to set the temperature in pyscript: def set_cooling(): climate_config = pyscript.config['apps']['climate'] if(float(input_number.disable_away_mode) > 0): log.debug("Away mode locked - ignoring temp changes") return configs = [climate_config[person[7:]] for person in state.names("person") \ if state.get(person) == "home" and ( person[7:] in climate_config ) ] if len(configs) > 0: target_max = min([ c['max'] for c in configs ]) target_min = max([ c['min'] for c in configs ]) else: log.debug("Setting away mode temps") target_max = climate_config['default']['max'] target_min = climate_config['default']['min'] if pyscript.lock_temperature != '1': target_temp(target_min, target_max)

@time_active("range(sunrise, 22:00)") @time_trigger("period(0:00, 3 min)") def scheduled_update(): set_cooling()

I have ONE SCRIPT that is checking the temperature for any interval that I want to use, and it is using a configuration file to figure out what to do. I don't need any entities, helpers, or automations to do this.

Creating hundreds of automations for this purpose is a bad solution. The system has to loop through all of them, and there's a lot that can go wrong.

I have thirty lock codes, which means I have over a THOUSAND helpers and automations generated by this. That's a problem. It could (and should) require about five functions and be less than 200 lines altogether.

Describe the solution you'd like Pick a different technology thats lets you do more with less. I don't care which one, but you're just asking for bugs with what you have. Likely most of the issues you have here are a result of this design flaw.

Describe alternatives you've considered Pyscript, Jinja Templates, and app daemon can all be made to do this.

The code produced would also be a fraction of the size of the code you're maintaining here.

raman325 commented 1 year ago

I have ONE SCRIPT that is checking the temperature for any interval that I want to use, and it is using a configuration file to figure out what to do. I don't need any entities, helpers, or automations to do this.

You are right that keymaster has some unnecessary complexity/surface area, but by comparing it to this script you are ignoring a lot of what keymaster does. Ultimately, I'd like keymaster to be more modular because a lot of people don't need all of the features that keymaster offers, but that's a significant rewrite and would not be made simpler by moving to pyscript or App Daemon.

there's a lot that can go wrong.

Like what?

I have thirty lock codes, which means I have over a THOUSAND helpers and automations generated by this. That's a problem.

What's the problem? From a user experience perspective it's crappy for sure because all of those automations/helpers create a lot of noise on certain pages, but it doesn't have any functional impact.

It could (and should) require about five functions and be less than 200 lines altogether.

If this is something you feel that confidently about, feel free to submit a PR for this or a fork.

Pick a different technology thats lets you do more with less. I don't care which one, but you're just asking for bugs with what you have. Likely most of the issues you have here are a result of this design flaw.

  1. What different technology are you referring to? pyscript and App Daemon are not different technologies, they're scripting languages built on top of Home Assistant constructs. And they make a lot of things simpler to write (I have many automations running via pyscript), but that doesn't make them a magic bullet for every problem.
  2. There is no design flaw. At the time that keymaster was originally created, the implementation was the only solution given what was available. There's a path to a better solution but that's only been made available recently, and that path does not involve pyscript or App Daemon.

Pyscript, Jinja Templates, and app daemon can all be made to do this.

The code produced would also be a fraction of the size of the code you're maintaining here.

Great - have at it and please share once it's built!