This binding makes use of the CAN over Ethernet feature of the C.M.I. from Technische Alternative.
Since I only have the new UVR16x2, it has only been tested with this controller.
The binding supports two ways to interact with the C.M.I. and all devices connected to the C.M.I. via the CAN bus.
These modes are:
Via a "Schema API Page"
* Read values from output nodes
* Change values for controllable nodes
CoE (CAN over Ethernet) Connection
* Receive data from analog CAN-outputs defined in TAPPS2
* Receive data from digital CAN-outputs defined in TAPPS2
* Send ON/OFF to digital CAN-inputs defined in TAPPS2
* Send numeric values to analog CAN-inputs defined in TAPPS2
Depending on what you want to achieve, either the "Schema API Page" or the CoE way might be better.
As rough guidance: Anything you want to provide to the TA equipment it has to work / operate with the CoE might be better.
If you plan things mainly for user interaction the "Schema API Page" might be better.
## Prerequisites
### Setting up the "Schema API Page"
The "Schema API page" is a special schema page created via TA's *TA-Designer* application available as download on their web site.
This page just needs to exist and be deployed on the C.M.I. but it dosn't need to be linked by the other schema pages you are using to control your TA installation.
All objects from this special 'API' page are automatically mapped as channels of this thing, so the labels of the objects on this page have to follow a specific schema.
When adding objects to this page, the schema for the Object's *Pre-Text* field has to follow the schema `<channelName> <channel description>: `.
The Text from the *Pre-Text* will be used to define the channel.
The first word *tempCollector* (highlighted in the screenshot) will be used as channel name, so it has to be unique.
Everything else till the final *:* will be used as channel description.
Be sure to have at least 2 words in the *Pre-Text* as we need both - the channel name and a description.
The binding will log an error otherwise.
Also keep in mind: for the channel name we have to adhere to the openHAB channel name conventions - so just use letters and numbers without any special sings here.
The type of the channel will be automatically determined by the type of the object added.
Also don't forget the final colon - this is the separator between the label and the value.
Without the colon the parser couldn't build up a working channel for this value.
The first sample is a sensor reading, but also the 'operation mode' of a heating circuit could be added:
| C.M.I. IP Address | host | Host name or IP address of the C.M.I | host name or ip |
| Username | username | Username for authentication on the C.M.I. | string with username |
| Password | password | Password for authentication on the C.M.I. | string with password |
| API Schema ID | schemaId | ID of the schema API page | 1-256 |
| Poll Interval | pollInterval | Poll interval (in seconds) how often to poll the API Page | 1-300; default 10 |
This thing doesn't need a bridge. Multiple of these things for different C.M.I.'s could be defined within a openHAB instance.
### TA C.M.I. CoE Connection
The _TA C.M.I. CoE Connection_ has to be manually configured.
This thing reflects a connection to a node behind a specific C.M.I.. This node could be every CAN-Capable device from TA which allows to define an CAN-Input.
| C.M.I. IP Address | host | Host name or IP address of the C.M.I | host name or ip |
| Node | node | The CoE / CAN Node number openHAB should represent | 1-64 |
The thing has no channels by default - they have to be added manually matching the configured inputs / outputs for the related CAN Node. Digital and Analog channels are supported. Please read TA's documentation related to the CAN-protocol - multiple analog (4) and digital (16) channels are combined so please be aware of this design limitation.
| Update Policy | updatePolicy | Update policy for this channel. Default means "On-Change" for channels that can be modified and "On-Change" for read-only channels. | 0 (Default), 1 (On-Fetch), 2 (On-Change) |
The behavior in detail:
*`Default` (`0`): When the channel is 'read-only' the update-policy defaults to _On-Fetch_ . When the channel is linked to something that can be modified it defaults to _On-Change_ .
*`On-Fetch` (`1`): This is the default for read-only values. This means the channel is updated every time the schema page is polled. Ideally for values you want to monitor and log into charts.
*`On-Change` (`2`): When channel values can be changed via OH it is better to only update the channel when the value changes. The binding will cache the previous value and only send an update when it changes to the previous known value. This is especially useful if you intend to link other things (like i.e. ZigBee or Shelly switches) to the TA via OH that can be controlled by different sources. This prevents unintended toggles or even toggle-loops.
Some comments on the CoE Connection and channel configuration:
As you might already have taken notice when studying the TA's manual, there are always a multiple CoE-values updated within a single CoE-message.
This is a design decision made by TA.
But this also means for CoE-Messages from openHAB to TA C.M.I. we have to send multiple values at once.
But due to OH's design there is no default restore of previous values out of the box.
So after OH startup the _output thing channels_ are either initialized with it's configured default value or flagged as 'unknown' until the first update on the channel happens.
You could either use some 'illegal' value as initial value and use _CoE Value Validation_ on the TA side to detect invalid values.
An other option would be to use only every 4th analog and 16th digital channel if you only need a few channels.
Additionally you could use [OH's persistence service](https://www.openhab.org/docs/configuration/persistence.html#restoring-item-states-on-restart) and it's option to [restore the item states](https://www.openhab.org/docs/configuration/persistence.html#restoring-item-states-on-restart) during OH startup.
As this only restores the item states you have to write a rule issuing _postUpdates_ on the items with the item's current value so the channel for the binding is updated.
You might already have noticed that some state information is in German.
As I have set the `Accept-Language`-Http-Header to `en` for all request and found no other way setting a language for the schema pages I assume it is a lack of internationalization in the C.M.I.
You could circumvent this by creating map files to map things properly to your language.
If you want to see the possible options of a multi-state field you could open the *schema API page* with your web browser and click on the object.
A Popup with an option field will be shown showing all possible options, like in this screenshot:
Please be also aware that there are field having more 'state' values than options, i.E. a manual output override: It has 'Auto/On', 'Auto/Off', 'Manual/On', 'Manual/Off' as state, but only 'Auto', 'Manual/On' and 'Manual/Off' as updateable option.
You only set it to 'Auto' and the extension On/Off is added depending on the system's current state.