Skip to content

Commit

Permalink
Merge pull request #10 from Schm1tz1/remote-vcontrold
Browse files Browse the repository at this point in the history
Added feature to switch to remote vcontrold
  • Loading branch information
Alexandre-io committed Jan 24, 2023
2 parents e96b041 + 966f6da commit 1968352
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 6 deletions.
7 changes: 6 additions & 1 deletion vcontrold/DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ Example: Writing a value to the topic `openv/setTempWWSoll` will set the target
## Configuration

### Add-On Configuration
In the configuration section, you need to set the USB/TTY device that uses an **Optolink** interface to connect to the **Vitodens** device. Select a _refresh rate_ that defines the interval used for polling your device and the _device id_ (typically also seen in the device identifier string) which is used to select the correct mapping for the commands that are executed.
In the configuration section, you have 2 choices to connect to your **Vitodens** device using an an **Optolink** interface:
1. For a locally connected **Optolink** cable, set the USB/TTY device. The add-on will pass through that USB port run **vcontrold** locally inside docker.
2. For a remotely running **vcontrold** (e.g. RPi connected to your **Vitodens** device), select its hostname and port (_Vcontrold host/port_). These settings are by default set to localhost:3002.

Select a _refresh rate_ that defines the interval used for polling your device and the _device id_ (typically also seen in the device identifier string) which is used to select the correct mapping for the commands that are executed.


The commands section can be edited and extended in YAML mode, e.g.
```yaml
Expand Down
8 changes: 6 additions & 2 deletions vcontrold/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ options:
tty: "/dev/ttyUSB0"
refresh: 30
device_id: "2098"
vcontrol_host: localhost
vcontrol_port: 3002
debug: false
commands:
- getTempA:FLOAT
Expand Down Expand Up @@ -58,8 +60,10 @@ schema:
tty: "str"
refresh: "int"
device_id: "str"
debug: "bool"
commands:
vcontrol_host: "str?"
vcontrol_port: "int?"
debug: "bool?"
commands:
- "str"
image: "alexandreio/{arch}-homeassistant-vcontrol"
usb: true
Expand Down
6 changes: 5 additions & 1 deletion vcontrold/rootfs/etc/services.d/vclient_pub/run
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ else
export MQTT_PASSWORD=$(bashio::services mqtt "password")
export MQTT_TOPIC="openv"

export VCONTROL_HOST=$(bashio::config 'vcontrol_host')
export VCONTROL_PORT=$(bashio::config 'vcontrol_port')
bashio::log.info "Setting vcontrold host to $VCONTROL_HOST and port to $VCONTROL_PORT ..."

## Run your program
while sleep $refresh_rate; do
vclient -h 127.0.0.1 -p 3002 -f /etc/vcontrold/1_mqtt_commands.txt -t /etc/vcontrold/2_mqtt.tmpl -x /etc/vcontrold/3_mqtt_pub.sh
vclient -h $VCONTROL_HOST -p $VCONTROL_PORT -f /etc/vcontrold/1_mqtt_commands.txt -t /etc/vcontrold/2_mqtt.tmpl -x /etc/vcontrold/3_mqtt_pub.sh
bashio::log.info "Looping vclient..."
done
fi
6 changes: 5 additions & 1 deletion vcontrold/rootfs/etc/services.d/vclient_sub/run
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ else
export MQTT_PASSWORD=$(bashio::services mqtt "password")
export MQTT_TOPIC="openv"

bashio::log.info "Setting vcontrold host and port ..."
export VCONTROL_HOST=$(bashio::config 'vcontrol_host')
export VCONTROL_PORT=$(bashio::config 'vcontrol_port')

## Run your program
while true ; do
mosquitto_sub -v -h $MQTT_HOST -p $MQTT_PORT -u $MQTT_USER -P $MQTT_PASSWORD -t "$MQTT_TOPIC/#" | while read -r payload
Expand All @@ -28,7 +32,7 @@ else
if [[ $topic =~ "/set" ]]; then
command=$(echo $topic | cut -d'/' -f2)
bashio::log.info "Sending command: [${command}]: ${value}"
vclient -h 127.0.0.1 -p 3002 -o /dev/stdout -c "${command} ${value}"
vclient -h $VCONTROL_HOST -p $VCONTROL_PORT -o /dev/stdout -c "${command} ${value}"
fi
done
sleep $refresh_rate
Expand Down
11 changes: 10 additions & 1 deletion vcontrold/rootfs/etc/services.d/vcontrold/run
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@

# Declare variables
declare config_tty
declare config_deviceid
declare config_commands
declare config_debug
declare vcontrol_host

## Get the 'message' key from the user config options.
config_tty=$(bashio::config 'tty')
config_deviceid=$(bashio::config 'device_id')
config_debug=$(bashio::config 'debug')
config_commands=$(bashio::config 'commands')
vcontrol_host=$(bashio::config 'vcontrol_host')

# Cleanup scripts
rm /etc/vcontrold/1_mqtt_commands.txt || /bin/true
Expand Down Expand Up @@ -52,4 +55,10 @@ else
fi

## Run your program
exec /usr/sbin/vcontrold -n -U root -d $config_tty
if [ "$vcontrol_host" = "localhost" ] ; then
bashio::log.info "Starting local vcontrold..."
exec /usr/sbin/vcontrold -n -U root -d $config_tty
else
# do nothing - needed as a dummy job to keep the dependency job running
tail -f /dev/null
fi
6 changes: 6 additions & 0 deletions vcontrold/translations/de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ configuration:
device_id:
name: "Device ID"
description: "Viessmann Gerätekennung (2098 => V200KW2 , 2053 => GWG_VBEM, 20CB => VScotHO1 , 2094 => V200KW1)"
vcontrol_host:
name: "Vcontrold Host"
description: "vcontrold host für die Verbindung (default: localhost)"
vcontrol_port:
name: "Vcontrold Port"
description: "vcontrold für die Verbindung (default: 3002)"
debug:
name: "Debug"
description: "Ausgabe von Debug-Nachrichten"
Expand Down
6 changes: 6 additions & 0 deletions vcontrold/translations/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ configuration:
device_id:
name: "Device ID"
description: "The device identifier. (2098 => V200KW2 , 2053 => GWG_VBEM, 20CB => VScotHO1 , 2094 => V200KW1)"
vcontrol_host:
name: "Vcontrold Host"
description: "vcontrold host to connect to (default: localhost)"
vcontrol_port:
name: "Vcontrold Port"
description: "vcontrold port to connect to (default: 3002)"
debug:
name: "Debug"
description: "Output of debug messages"
Expand Down

0 comments on commit 1968352

Please sign in to comment.