Commit Graph

358 Commits

Author SHA1 Message Date
8982e9c165 feat(config)!: Put automation modules in namespace
All checks were successful
Build and deploy / build (push) Successful in 13m33s
Build and deploy / Deploy container (push) Successful in 39s
All lua modules that originate from automation_rs are now prefixed with
`automation:`.
2025-09-11 04:12:15 +02:00
4e28ad0f85 feat!: Improve device type registration
All checks were successful
Build and deploy / build (push) Successful in 10m37s
Build and deploy / Deploy container (push) Successful in 38s
Instead of one function that contains all the device types available in
`automation_devices` a global registry is used were each device can
register itself.
2025-09-10 03:02:05 +02:00
f0e4c9dd21 chore!: Remove unused notification setters
Since the creation of notifications has moved entirely to lua these
setters were not being used anymore.
2025-09-10 02:56:56 +02:00
5271e5ad81 refactor(config)!: Moved Timeout into utils module and moved module
All checks were successful
Build and deploy / build (push) Successful in 10m43s
Build and deploy / Deploy container (push) Successful in 39s
The module is now setup in automation_lib::lua::utils.
2025-09-10 02:11:11 +02:00
1d28b43264 refactor: Move module load code into separate function 2025-09-10 02:11:11 +02:00
da04fad520 refactor(config)!: Move device proxies into module
Instead of registering the device proxies in the global namespace they
are now registered in a module called `devices`.
2025-09-10 02:11:09 +02:00
84e4b30b6a feat!: Improve lua module registration
Instead of having to call all the module registration functions in one
place it is possible for each module to register itself in a global registry.
During startup all the all the modules will be registered
automatically.

This does currently have one weakness, to need to ensure that the crate
is linked.
2025-09-10 02:10:45 +02:00
95a8a377e8 feat!: Removed AddAdditionalMethods
It has been replaced with the add_methods device attribute.
2025-09-10 01:58:48 +02:00
23355190ca feat: Added attribute to easily register additional lua methods
Previously this could only be done by implementing a trait, like
`AddAdditionalMethods`, that that has an add_methods function where you
can put your custom methods. With this new attribute you can pass in a
register function directly!
2025-09-10 01:58:48 +02:00
2dbd491b81 refactor!: Rewrote device implementation macro once again
This time with a bit more though put into the design of the code, as a
result the macro should be a lot more robust.

This did result in the macro getting renamed from LuaDevice to Device as
this should be _the_ Device macro.
The attribute also got renamed from traits() to device(traits()) and the
syntax got overhauled to allow for a bit more expression.
2025-09-10 01:58:48 +02:00
aad089aa10 chore: Removed old leftover contact sensor presence config 2025-09-10 01:46:16 +02:00
18e40726fe refactor: Remove unneeded wrapper functions when specifying callbacks
These wrappers can be moved up to where the callback itself is defined
instead of having to wrap the call manually. This also works a lot nicer
now that it is possible to provide multiple callback functions.
2025-09-10 01:46:16 +02:00
1925bac73c fix: Front door presence does not get cleared properly 2025-09-10 01:46:16 +02:00
5383e7265d feat!: ActionCallback can now receive any amount of arguments
ActionCallback now only has one generics argument that has to implement
IntoLuaMulti, this makes ActionCallback much more flexible as it no
longer always requires two arguments.
2025-09-10 01:46:12 +02:00
352654107a feat: Added derive macro to implement IntoLua on structs that implement Serialize
This can be very useful if you want to convert a data struct to a lua
table without having to write the boilerplane (however small it may
be).

It also adds the macro on several state structs so they can be
converted to lua in the upcoming ActionCallback refactor.
2025-09-08 04:06:00 +02:00
3a7f2f9bd7 fix: IkeaRemote callback is missing default specifier 2025-09-08 04:05:43 +02:00
3be11b0c6a feat: Allow for multiple callbacks inside of an ActionCallback
This also results in the conversion being performed when the
ActionCallback is instantiated instead of when it is called, this should
make it easier to catch errors.
2025-09-08 04:02:47 +02:00
e880efe4cf refactor: Store callback function directly instead of in the registry 2025-09-08 04:02:47 +02:00
e2fb680cd6 feat: Log version string during startup 2025-09-08 04:02:40 +02:00
edee032b91 chore: Set RUST_LOG to something sensible by default when running with cargo
Some checks failed
Build and deploy / Deploy container (push) Blocked by required conditions
Build and deploy / build (push) Has been cancelled
2025-09-05 04:48:00 +02:00
8bb17e1440 feat(config)!: Reworked how configuration is loaded
The environment variable `AUTOMATION_CONFIG` has been renamed to
`AUTOMATION__ENTRYPOINT` and can now also be set in `automation.toml` by
specifying:
```
automation = "<path>"
```

Directly accessing the environment variables in lua in no longer
possible. To pass in configuration or secrets you can now instead make
use of the `variables` and `secrets` modules.

To set values in these modules you can either specify them in
`automation.toml`:
```
[variables]
<name> = <value>

[secrets]
<name> = <value>
```
Note that these values will get converted to a string.

You can also specify the environment variables
`AUTOMATION__VARIABLES__<name>` and `AUTOMATION__SECRETS__<name>` to
set variables and secrets respectively. By adding the suffix `__FILE` to
the environment variable name the contents of a file can be loaded into
the variable or secret.

Note that variables and secrets are identical in functionality and the
name difference exists purely to make it clear that secret values are
meant to be kept secret.
2025-09-05 04:48:00 +02:00
ba37de3939 feat(config)!: Move new_mqtt_client out of global automation table into separate module
The function `new_mqtt_client` was the last remaining entry in the
global `automation` table. The function was renamed to `new` and placed
in the new `mqtt` module. As `automation` is now empty, it has been
removed.
2025-09-05 03:55:04 +02:00
22fee0ed77 feat(config)!: Move device_manager out of global automation table into separate module
Moved `automation.device_manager` into a separate module called
`device_manager`
2025-09-05 03:55:03 +02:00
5aebab28ed feat(config)!: Move util out of global automation table into separate module
Move `automation.util` into a separate module called `utils`.
2025-09-05 03:55:03 +02:00
e626caad8a feat(config)!: Fulfillment config is now returned at the end of the config
Previously the fulfillment config was set by setting
`automation.fulfillment`, this will no longer work in the future when
the global automation gets split into modules.
2025-09-05 03:55:03 +02:00
0090a77dc1 style: Sort crates by name 2025-09-05 03:55:03 +02:00
4d356001c3 style: Enforce conventional commits formatting 2025-09-05 03:55:03 +02:00
aa22132dd6 chore: Put typos config in Cargo.toml 2025-09-04 04:28:02 +02:00
1db269f65e chore: Update pre-commit hooks 2025-09-04 04:28:02 +02:00
77d7881a57 chore: Update/upgrade dependencies
There was a potential vulnerability in tracing-subscriber, so I took
this as an opportunity to update/upgrade all dependencies
2025-09-04 04:28:02 +02:00
f3b1854beb fix: Crash if hallway automation is called before door/trash have been initialized
Resolves: #4
2025-09-04 04:27:49 +02:00
8109dcf2f5 feat: Added low battery notification and made mqtt message parsing more robust
Resolves: #1
2025-09-04 04:26:34 +02:00
1b8566e593 refactor: Switch to async closures 2025-09-04 04:15:08 +02:00
e21ea0f34e Implement custom lua print function that calls info
All checks were successful
Build and deploy / build (push) Successful in 11m54s
Build and deploy / Deploy container (push) Successful in 45s
2025-09-01 02:47:47 +02:00
fb7e1f1472 Small cleanup 2025-09-01 02:47:29 +02:00
45de83ef2f Removed old presence system 2025-08-31 23:57:59 +02:00
2a1f75f158 Move front door presence logic to lua 2025-08-31 23:57:59 +02:00
74568b4e1f Handle turning off devices when away through lua 2025-08-31 23:57:59 +02:00
fefccf03d7 Removed DebugBridge as it no longer served a purpose 2025-08-31 23:57:59 +02:00
b56a16d0d7 Moved presence debug mqtt message to lua 2025-08-31 23:57:59 +02:00
1530875045 Presence and light sensor call all function in array 2025-08-31 23:57:58 +02:00
9616017c8f Print lua version on startup 2025-08-31 23:57:56 +02:00
6db5831571 Removed old darkness system 2025-08-31 23:56:28 +02:00
aa730c9738 Moved darkness debug mqtt message to lua 2025-08-31 05:41:49 +02:00
c362952f7c Feature: Get current ms since unix epoch in lua 2025-08-31 05:41:49 +02:00
dd379e4077 Feature: Send mqtt messages from lua 2025-08-31 05:41:48 +02:00
549d821e3a Moved hue bridge on darkness to lua 2025-08-31 05:41:46 +02:00
4980f4888e Removed unused event code 2025-08-31 05:01:56 +02:00
eb36d41f17 Move ntfy and presence to automation_devices 2025-08-31 04:57:31 +02:00
03dcd44e0e Removed old notification system
All checks were successful
Build and deploy / build (push) Successful in 8m50s
Build and deploy / Deploy container (push) Successful in 39s
2025-08-31 03:55:08 +02:00