4 ms·
My main problem with Home assistant is the automation language. It could be very powerful, but isn't. I feel that if there was a way to introduce temporary sta
by maweki 5y ago
My main problem with Home assistant is the automation language. It could be very powerful, but isn't.
I feel that if there was a way to introduce temporary state and force an expression as the value of a switch it could be great. I would love for something ASP/Datalog based.
Having a light that's just on if some expression is True and off if the expression is false is more difficult than it should be. The automations are not goal-based. But maybe in a decade the next project will do it that way.
- Denvercoder9 5y agoYou can try pyscript (https://github.com/custom-components/pyscript https://github.com/custom-components/pyscript), which allows you to write automations in plain Python.
- maweki 5y agoThat's not AI/Logic programming though. Ideally I'd write a boolean formula and the system tries to make it true by adjusting the values it can adjust. Say I want something like the light should be off it is dark and the window is open (bugs), but if the window is closed and it is dark, the light should be on. dark & window.open -> !light dark & !window.open -> light Obviously, it can't close the window. But it can turn the light to make the formulas true. If this were answer-set-based, the system could find multiple ways to make the formulas true (that's why I say goal-based) and act in a truly intelligent manner. Edit: if it could close the window, it had a second way to make the formulas true. That would be nice as well, that the window closes when I turn on the light. Edit 2: note that at daytime the formulas are always true, such that I can adjust the light and window as I like. Edit 3: We could also rewrite this as dark -> (window.open != light) And it is great that we could reason about our rules in that manner.
- Denvercoder9 5y agoThat's an interesting idea, and I agree it would make a great addition to HA. From an outside standpoint it doesn't even seem to be that hard to implement, all the pieces are already there, "just" needs some glue.
- aequitas 5y ago> And it is great that we could reason about our rules in that manner. That's what I've been missing as well. Node-RED comes close, but is event based. I've been thinking of implementing this kind of system. It has similar principles to functional languages or a reactive system like Mgmt[0]. But I foresee a few issues that would render potential simple formulae into complex ones. Things like keeping state on event based inputs (push-type wall switches), time based decisions and outputs that don't provide feedback on their current state. If I ever find the time to get practical with the idea and work out these issues I might put it into a Show HN. [0] https://github.com/purpleidea/mgmt https://github.com/purpleidea/mgmt
- colordrops 5y agoYes, I added some simple automation scripts to calculate bandwidth being used on my router from snmp data and it eats up 100% CPU. The calculations are super simple and shouldn't take almost any CPU.
- moritonal 5y agoAt the risk of sounding like a broken-record, Node-Red is a very easy but flexible visual-scripting engine and has a good integration with Home Assistant. It could be a solution for the places where HA is lacking. https://community.home-assistant.io/t/home-assistant-community-add-on-node-red/55023 https://community.home-assistant.io/t/home-assistant-communi...
- edelans 5y agoHave you considered AppDaemon ? https://github.com/AppDaemon/appdaemon https://github.com/AppDaemon/appdaemon
- jayelbe 5y agoThis is dead easy to do in Home Assistant if you use a jinja-based template as the automation trigger. Any template that will evaluate to true will trigger the automation. Templates are re-evaluated every time the state of the object changes or (if you use a time function, or don't reference any objects) every minute. Here's a simple example that would send a notification if I left my kitchen LEDs on 200 brightness or more for longer than two hours. alias: Kitchen description: '' trigger: - platform: template value_template: ' {{ state_attr('light.kitchen_led', 'brightness')|int >= 200 and as_timestamp(states.light.kitchen_led.last_updated) + 3600 < as_timestamp(now()) }} ' condition: [] action: - service: notify.my_phone data: title: Kitchen lights still on message: The kitchen LEDs have been on very bright for more than 2 hours. mode: single
- maweki 5y agoThat's absolutely not what I meant. The trigger condition is not the problem. The action is. It is not goal-based. I can't give a target value (as template) and the system tries to bring the entity to that state. I have to have another check (or two automations) to trigger the off/on-action. Home assistant basically has no idea how to bring entities to a desired state.