Skip to content

Commit

Permalink
Vcontrold: allow custom vito.xml
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre-io committed Oct 30, 2023
1 parent 302c14d commit f4ef77d
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 2 deletions.
5 changes: 5 additions & 0 deletions vcontrold/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<!-- https://developers.home-assistant.io/docs/add-ons/presentation#keeping-a-changelog -->

## 1.9.0

- Allow custom vito.xml
- Upgrade debian to bookworm

## 1.8.4

- Added polish translation (@Qbunjo)
Expand Down
9 changes: 9 additions & 0 deletions vcontrold/DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,12 @@ mqtt:
state_on: 1
state_off: 0
```
### Custom vito.xml configuration file
The module use the `config` option (refer to https://developers.home-assistant.io/docs/add-ons/configuration/#add-on-advanced-options) for mounting a custom configuration file. It verifies the existence of a 'vito.xml' file during startup.

Ensure the file is placed in the specified path:
```
config/vcontrold/vito.xml
```

4 changes: 3 additions & 1 deletion vcontrold/config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# https://developers.home-assistant.io/docs/add-ons/configuration#add-on-config
name: Vcontrol add-on
version: "1.8.4"
version: "1.9.0"
slug: vcontrold
description: Vcontrol add-on
url: "https://github.com/Alexandre-io/homeassistant-vcontrol"
Expand Down Expand Up @@ -83,3 +83,5 @@ devices:
- /dev/ttyUSB1
- /dev/ttyUSB2
- /dev/ttyUSB3
map:
- config
11 changes: 11 additions & 0 deletions vcontrold/rootfs/etc/services.d/vcontrold/run
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

# Declare variables
declare config_tty
declare config_file
declare config_deviceid
declare config_commands

Expand All @@ -14,9 +15,16 @@ declare config_commands

## Get the 'message' key from the user config options.
config_tty=$(bashio::config 'tty')
config_file=vito.xml
config_deviceid=$(bashio::config 'device_id')
config_commands=$(bashio::config 'commands')

## Check if custom vito.xml file exist
if [ -f "/config/vcontrold/vito.xml" ]; then
bashio::log.info "Using a custom vito.xml file"
config_file=/config/vcontrold/vito.xml
fi

# Cleanup scripts
rm /etc/vcontrold/1_mqtt_commands.txt || /bin/true
rm /etc/vcontrold/2_mqtt.tmpl || /bin/true
Expand Down Expand Up @@ -48,6 +56,9 @@ done
# Set device ID
sed -i "s/#DEVICEID#/$config_deviceid/g" /etc/vcontrold/vcontrold.xml

# Set vito.xml
sed -i "s|#VITOXML#|$config_file|g" /etc/vcontrold/vcontrold.xml

if bashio::config.true 'debug'; then
sed -i "s/#DEBUG#/y/g" /etc/vcontrold/vcontrold.xml
else
Expand Down
2 changes: 1 addition & 1 deletion vcontrold/rootfs/etc/vcontrold/vcontrold.xml
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,6 @@
</protocol>
</protocols>
<extern xmlns:xi="http://www.w3.org/2003/XInclude">
<xi:include href="vito.xml" parse="xml"/>
<xi:include href="#VITOXML#" parse="xml"/>
</extern>
</V-Control>

0 comments on commit f4ef77d

Please sign in to comment.