WTF {% %} {{ }} Jinja2

Now I got it, but that’s more of a physics or statistics problem than a code problem… Depending on the information you are counting with it might just be a rule of three… once you get the formulas figured out it will be irrelevant whether you use NR or jinja or whatever…

Anyways, I’m not sure this way of achieving this is worth the extra effort vs simpler solutions.

I’m not sure too, it heavily depends on how difficult is to implement it. If it is simple, it’s free energy saving, small or big.
Anyway it’s only an idea - I’d like to work on it soon, if you like it too, we can work on it on a separate thread.
What about automatically selecting furnace or HVAC depending on what is more efficient at a certain temperature? Possibly using an efficiency curve calculated from real data? Measure its degradation to understand when filters are clogged or there is some circuit leak? Develop a strategy to automatically disconnect less important loads to reduce maximum consumption and have a smaller electrical contract?
For me, having brought electrical devices under computer control means playing with ideas like that, not struggling to learn simple boring automation…

If you are aiming to achieve a real advantatge vs simpler things I suspect it will become difficult to implement. I mean, with simpler conditions like “is somebody home?”, “is everybody sleeping?”, “is the room empty?”, etc, you achieve, let’s say, a 90+% efficiency effortlessly, it’s bread and butter. It’s really up to you whether that remaining 10% is worth the effort. It sounds to me like you are trying to apply rocket science to design a pencil, but hey, if you are really willing to go this route I’ll be pleased to see how far you get. You’ll need at lest some basic knownledge, if not advanced, of Thermodynamics and of course statistics to figure out the real scenario your house is in order to get some extra %'s of efficiency.

I tend to agree. I avoid crazy automations for my smart thermostat because it’s already smarter than me with it’s setpoints and target temperatures. Then again, my house is newer and energy efficient. Takes 4-6 hours to drop 3 degrees :confused: . I have to turn off the heat at 6pm so that it’s cold for sleeping.

3 Likes

If there is one thing from this thread which I think could be realistically implemented would be a common, recognizable badge to be added to all the text inputs that supports templates.

1 Like

Pyscript unstable? Running fine here and reliable.

I know this is an old post, but I think a very good point and opportunity was missed here. I found this post because I ran into the exact problem described by @mumon66 - the lack of any mention of the .split function in the Jinja2 template documentation page linked on the Template tab of the Developer Tools. As @petro correctly points out, the .split function (and many other very useful details) are documented with Python. I think it would be very helpful (and easy) to include some of the points that @petro made on the Template tab with a third link to this documentation.

1 Like

Question tho, would it ever be possible to add Lua support in place of Jinja?

I mean we could still have Jinja, but having Lua as a native alternative is more intuitive for anyone who can code (more so than Jinja).

Coming from someone who likes to write blueprints - but really hate Jinja with a passion.

*Without resorting to pyscript, node-red, etc etc

You can add any language you want if you have your mind set on it. HA is open source after all. That’s how things like pyscript started.

This thread is a case-study in why open source projects often have such low quality. Someone provides legitimate feedback, and is immediately shot down with:

  • “that’s impossible” (no way another language could be added alongside Jinja)
  • “the docs are fine” (if people can’t find or understand them, then they’re obviously not)
  • “just learn it” (amazingly helpful suggestion)
  • “no improvement needed; it’s already so easy: just read these two separate sets of docs, figure out the overlap, then read the source for all the undocumented stuff”

Then finally, the ultimate classic, “it’s open source, do it yourself”.

3 Likes
1 Like

Fortunately this doesn’t apply to HA! :slight_smile:

1 Like

One of the benches in the park had a nail sticking out of it. Someone who loved the park, but was busy or didn’t have the skills to fix the bench, suggested “hey, this nail could injure the kids; could you fix it?”

Instead of saying “sure, we don’t have time right now, but it’s a valid concern, and we’ll get to it as we can”, the volunteers got defensive. They took the suggestion as a complaint; as criticism. They felt indignant: why was this lazy person, who hadn’t contributed anything, questioning their work?

They responded with things like “well, don’t sit on the nail, then”, or “it’s a pretty obvious nail; why can’t you see it?”, or “it’s a free park; go somewhere else if you don’t like it”, or “this park is run by volunteers, so just fix it yourself instead of whining”.

The person who had made the suggestion was sad, because they wanted to see something good get better, and that seemed increasingly unlikely to happen.

1 Like

There’s a bulletin board for reporting protruding nails and problems like that get fixed.

What we have here is someone asking WTF we don’t replace the existing, functional slide with one they would prefer.

If the idea inspires no one to do it, it doesn’t get done. Explaining why their wish is unlikely to be fulfilled is all part of the discussion.


EDIT

The irony is that little parable was written 5 years ago in response to users who were bitter that no one appeared to be listening to their complaints. They made dire predictions about Home Assistant’s future unless their suggestions were followed.

When informed they’re free to contribute in many ways, like enhance the documentation or report bugs in the appropriate Github repo or participate in beta testing, they balked at the very idea. Their concept of open-source was “free software for me, someone else does what I want”.

3 Likes

It’s a perfect WTH suggestion: something that isn’t actually broken (the bench is still usable), but can cause a lot of pain to first-timers who don’t know about the nail. If few people feel that it’s worth working on, that’s fine; there’s no need to forcibly reject the suggestion. Maybe over time others will find it, like I did, and upvote.

I was going to just click the button and move on, but I have a visceral dislike for condescending “just send a PR” style responses, and made the mistake of reacting to that.

Many years ago, I worked on an open source project. Took time out to spend quite a few hours with one potential user demonstrating the package. He asked for a couple of customisations, and got most upset when asked how much he was willing to pay… “But it is free software, you do this for fun” was his cry.
If I have to take time out of earning a living, it is not unreasonable to expect to be paid for the work.

There’s nothing actionable in the first post. The author even begins with the caveat “more of a rant”. Replace Jinja2 with what exactly? It’s unclear what would placate the rant’s author (other than not Jinja2).

The recent suggestion to add Lua (because they “hate jinja with a passion”) at least indicates what should be added.

petro’s reply was succinct and factual. I detected no condescension, just an explanation that it’s possible and someone will need to submit a PR. As he pointed out, that’s how pyscript was added (i.e. someone volunteered their time to create it and submit it as a PR). He’s familiar with the process, having submitted many PRs.

Regarding your bullet points:

  • Some things are in fact impossible. Not just because the idea may be highly disruptive but because some ideas don’t fit with the founder’s vision for the product (Paulus has final say in these matters).

  • Based on my 5+ years of helping thousands of people in this forum, a significant number of reported questions/problems are answered/solved in the documentation. I’m led to conclude they simply didn’t read the documentation, especially when it contains an apt example. So, yeah, often the docs are fine (not perfect, but serviceable) just not read. Where the docs need improvement, everyone is free to enhance them and they do.

  • There are a few users who expect answers/solutions with little investment of their time effort; they want others to do all the work. 'nuf said.

  • Undeniably there are some concepts that are challenging to comprehend and not only require reading the documentation but also perusing the forum for examples (and/or watching video tutorials). If there’s a way to make people learn them with less effort then suggestions are welcome. However, there are also some concepts that are in fact simple but do require some reading. The UI has limitations on just how much it can convey concepts (especially if the concept uses unfamiliar terminology).

  • Many people do in fact “do it” themselves by creating custom cards, integrations, blueprints, etc and share them with others. If one doesn’t have the requisite software development skills then they’ll need to make a compelling case for their idea and hope someone implements it for them (or someone shows them an existing alternative).

1 Like

I’m sorry? Where is there any condescension in any of my posts? I’m just explaining what can be done…

3 Likes

I share the same frustration as an occasional user of HA.

Rhetorical question:
Why don’t simply use python or provide it as a supported option to write automatons?

You can with python_scripts and pyscript.

1 Like