Hi,
I’m at the point not to implement new features but to optimize my code and make it more efficient.
Does anybody have an idea or can push me into the right direction, to write this template more efficient and make it maybe faster:
It looks like old visual basic code ;-).
I have some more of these endles if…then…else templates
PS: This code is inefficient due to the fact, the when moving around, the old motion sensor is still ‘on’ meanwhile the next one turns to ‘on’. I would like to catch always the last one which changed to ‘on’
PS2: This issue is solved. I’m writing the friendly name of every sensor into a variable when turning on. That’s more efficient. But this, we call it spaghetti code, is still not elegant. Are there better notations? Did not found something via google
Thanks for the hint. You’re right.
When reacting on different states of one entity, it’s better to safe it into a variable and play with it later.
In my case, I made something similar when saving the name of the entity into a variable after being triggered.
Thanks again. I will examin my code for cases similar to the one you pointed out.
By the way, do you have a good documentation in order to learn more about jinja.
My knowledge comes from VB.net, PL/SQL, and C# 20 years ago.
So the basics are there but I’m missing the syntax in jinja or python
Yees, you caught me.
Never had that case but its for sure possible and in order to accurate guidelines to be guarded.
Edit: But this case is interesting.
What could be a good else. ?
switching on any input_boolean would cause confusion
Here, I would have a log entry but the user simply recognizes that nothing happens an try again.
What I’m missing is an error handler at the end where I can inform the user that something was wrong or call last_called_alexa again
2nd edit: Ok, i can implement a condition upfront and check the sensor.
3 edit: Ok choose would be the right way.
in case of an empty sensor - initiate a notify else do the work
ergo - no need for an else based guarding