2f37fcf Got bitten by using lazy sequences with side effects.
~jeeger pushed to ~jeeger/kodi-autodim git
This program listens to Kodi's playing status via a TCP connection, activates a configurable scene when it detects something starting to play, and restores the old lighting state on pausing and stopping.
Clone the repository and run clj -T:build uber
. The resulting jar is executable, just copy it anywhere. Alternatively, if you have Nix installed, you can run nix run 'git+https://git.sr.ht/~jeeger/kodi-autodim'
or integrate the flake into your system however you wish.
You'll need to have an Ikea Trådfri installation set up, with at least one scene defined for when you start watching. Additionally, you'll need to enable the JSON-RPC interface on Kodi.
When you have all of this set up, you'll need to generate an API secret for the gateway. kodi-autodim can do this with the -r
command line parameter: java -jar kodi-autodim-0.1.0.jar -r <username> <gateway host> <gateway code>
will print a shared key to insert into your configuration (see below).
kodi-autodim accepts configuration via environment variables, values provided on the command line or configuration files. All values need to be provided, none are currently optional.
TODO: Change this for at least the Kodi port.
The configuration file is in EDN syntax located at either $XDG_CONFIG_HOME/kodi-autodim/config.edn
or /etc/kodi-autodim/config.edn
. You can specify a different config file with the -c
command line argument.
The following keys are required:
Key | Description |
---|---|
:kodi-host | DNS name or IP address of your Kodi server |
:kodi-port | Port for Kodi JSON-RPC. Normally 9090 |
:gateway-host | The DNS name or IP address of your Ikea Trådfri gateway |
:gateway-username | The username that should be used to access Trådfri |
:gateway-password | The password that should be used to access Trådfri |
:playing-scene-name | The scene that should be activated when Kodi starts playing |
You can set or override any key in the configuration file via either environment variables or command line arguments.
The environment variable for a config key is AUTODIM_
followed by the upcased name of the config
option, with dashes replaced by underscores (like AUTODIM_KODI_PORT
, for example). For command
line arguments, use the format <env-name>=<value>
(AUTODIM_KODI_HOST=raspi3
, for example).
Run the jar with java -jar
. kodi-autodim will start running and output information while running. You can see debug output by starting kodi-autodim with -v
, which will show more information on what scene is being set, and which lighting settings are being restored.