# BACnet

> Connect BACnet/IP building-automation devices - device instance, object type and instance addressing, Who-Is discovery and presentValue.

The **BACnet** driver talks to building-automation equipment over BACnet/IP.
Every tag reads one BACnet object's **present value** — the live reading of an
analog input, the state of a binary output, the position of a multi-state
value. Add a device under the BACnet driver in the [Connector](connector); the
panel shows only the fields this protocol uses.

## Connection {#connection}

| Field | Meaning | Default |
| --- | --- | --- |
| **Host** | IP address or host name of the BACnet device (or of the router answering for it). | empty |
| **Port** | UDP port of the device. 0 uses 47808, the BACnet/IP standard. | 0 |
| **Device Id** | The device's instance number — the number of its Device object, unique on the BACnet network. | 0 |

The device header shows the assembled endpoint, for example
`bacnet://192.168.0.30:47808/1234`. Connecting sends one request for the size
of the device's object list to confirm the equipment answers; the object list
itself is not walked. That answer is the connection: a device that does not reply
stays offline instead of showing as connected, and the reason (the UDP port
already taken, an address that is not an address) is written to the Events page
and the day's log file. There are no poll-interval fields for this driver: its
tags are read once per second.

## Addressing {#addressing}

A BACnet tag is addressed by two typed fields in the tag's Source card — no
free-text address:

| Field | Meaning | Accepted values | Default |
| --- | --- | --- | --- |
| **Object type** | Which kind of BACnet object to read. | the nine types below | `AnalogInput` |
| **Instance** | The object's instance number within its type. | 0 and up | 0 |

The offered object types and their standard BACnet type codes:

| Object type | Code | Present value holds |
| --- | --- | --- |
| `AnalogInput` | 0 | a measured number |
| `AnalogOutput` | 1 | a commanded number |
| `AnalogValue` | 2 | a stored number |
| `BinaryInput` | 3 | inactive/active |
| `BinaryOutput` | 4 | inactive/active |
| `BinaryValue` | 5 | inactive/active |
| `MultiStateInput` | 13 | a state number from 1 up |
| `MultiStateOutput` | 14 | a state number from 1 up |
| `MultiStateValue` | 19 | a state number from 1 up |

`AnalogInput` 5 on device 1234 means "the present value of analog input 5 of
that device". Every read asks for the object's `presentValue` property; other
properties are not addressable. The Source card's read-only **Source address
(wire)** line shows the assembled `type,instance` pair as you edit.

## Data types {#data-types}

The **Data type** picker offers four types. Pick the one matching the object:

| Data type | Fits | Notes |
| --- | --- | --- |
| Float | analog objects | a Real present value; doubles are narrowed to Float |
| Boolean | binary objects | a Boolean present value, or the enumerated 0 and 1 a binary object answers with |
| Int32 | multi-state and other integer values | signed, unsigned and enumerated answers all arrive here |
| String | character-string values | text as the device sends it |

The picked type has to match what the object holds. A device that answers with
something else fails that tag's read: the tag goes to bad quality and the reason
names what arrived ("The device answered a Single value for a point declared
Integer."), instead of a converted number entering the trend, the history and
the alarms. Reading an analog object as Boolean, or a Real as Int32, is exactly
that case. The rest of the device keeps reading; nothing is reconnected over a
tag whose type is wrong.

## Writes {#writes}

Tags whose **Access** is Read and write or Write only can be written. A write
sets the object's `presentValue`, typed by the tag's data type: Float writes a
BACnet Real, Boolean a BACnet Boolean, Int32 a signed integer and String a
character string. No command priority is sent with the write. Equipment that
insists on a different type for its present value — some binary outputs only
accept an Enumerated value, for example — may reject the write; the tag then
reports the failure instead of faking success. A new tag starts as Read only.

## Discovery {#discovery}

The Connector's Discover button broadcasts a BACnet **Who-Is** and listens for
**I-Am** answers for 10 seconds. Every device that answers becomes a candidate
carrying its address, port and device instance, ready to add with the connection
fields filled in, and it appears in the list the moment it answers rather than at
the end of the ten seconds: a scan you cancel halfway keeps everything that had
already replied. The scan does not browse objects, so candidates arrive with zero
tags; add the object type and instance pairs yourself.

A device that answers **through a BACnet router** is added the same way. Its
candidate carries the router's address and, alongside it, the device's own network
and address on that network; both are kept when you add it, and every read is sent
to the router naming the device inside. A device found this way therefore reads
like any other, and its endpoint reads "device via router". A device added by hand
has no route and is reached directly at its host.

## Good to know {#good-to-know}

- BACnet/IP only: MS/TP or BACnet/SC equipment is reachable only through a
  router that presents it on BACnet/IP, and the scan is what finds it: the route
  a device answers on is kept from the scan, so add it from the discovered list
  rather than typing its fields by hand.
- The driver communicates from the standard BACnet UDP port 47808 on this
  station; another BACnet application holding that port exclusively on the
  same machine can conflict with it.
- Polling is fixed at one second for every tag on this driver; the usual poll
  interval fields are not shown.
