HA scripting: Are real scripting languages possible? What are the performance differences?

You must be doing it wrong then. Rock-solid and dependable for years here.

Once-per-second polling is your better alternative?!

I don’t dispute that offloading very complex stuff might be preferable in certain situations, but in general this doesn’t sound like a great idea.

This isn’t me railing against tools I don’t know, either: I’ve written thousands of lines of JS, node.js projects etc.

You must be doing it wrong then.

Well, easy assumption but as engineer who’s spent the last 7 years writing machine code, developing industrial automation systems from the ground up for municipal water treatment, oil refineries and other industries and being intimately familiar with the electronics, software and mechanical aspects of industrial automation. I’m completely baffled and underwhelmed with the experience I’ve had, particularly the performance and reliability of the automations.

Maybe the types of automations your doing aren’t plagued by the out of order sequencing issues i cant resolve given the available tools in the GUI. Or maybe im just clueless, but if I cant get anywhere with automations for my usecase, then im definitely not alone.

Once-per-second polling is your better alternative?!

Uhm yeah. I guess once every 5 seconds could work fine aswell but quicker than once a second and it appears HA will fall on its face, HA isn’t very quick on it’s heals it would appear.

That being said, If i can offload the responsibility of critical logic from an observably unreliable system that i can’t control compared to a system that is reliable that i can intimately control, then im completely fine with that. I dont need things to happen at lightening speed that HA couldn’t even deliver on a good day but i do have thousands of dollars worth of pumps and equipment that could go up in smoke if left at the mercy of HA automation.

Websocket seems to be a better approach if you want to offload all the logic from HA to NodeJS. Ill be sure and post here when i have a good working example. Until then, once a second fetching is working great. I dont even want to know why my automations arnt working properly at this point; i dont even want to use HA for anything but an android GUI or maybe a web GUI. I think it’s great for that, but its automation, logic and data management strategy is a ghastly creation and i personally dont care for it. Using helpers is such an afterthought. I cannot stand yaml and the HA core being written in python just makes me cringe. Fetching once a second or even faster would be completely acceptable even if it were the only method but i admit websocket is probably a much better approach.

I’m sure the experts here could help with the issues you’re finding. I exclusively use YAML rather than the UI, which undoubtably helps.

AppDaemon is another alternative. API connection and Python scripting:

https://appdaemon.readthedocs.io/en/latest/HASS_TUTORIAL.html

1 Like

The issues im having are partly a result of the HA core being multi threaded and that alone is presenting a huge coding challenge just to deal with and doing it in YAML doesnt alleviate that caveat. Also the implementation leaves a lot to be desired for in terms of state management and logic which makes overcoming the aforementioned challenges all the more difficult. It’s a far better approach to use NodeJS for the logic but i agree fetching once a second isn’t particularly elegant and might not work for some use cases.

I think the possibility of using NodeJS seamlessly with HA using a more elegant API that uses websocket for example is very exciting. I never used python in automation because i just dont trust it when a lot of money is on the line (go figure) but purely as a GUI i think is where HA and python really shine.

If anyone can provide an example of using NodeJS with websocket and HA please share.

Persons interested in using NodeJS, have a look at my NodeJS Home Assistant example framework.

To discuss this further, go to this topic.