File: sensor.md

package info (click to toggle)
python-xknx 3.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,012 kB
  • sloc: python: 39,710; javascript: 8,556; makefile: 27; sh: 12
file content (48 lines) | stat: -rw-r--r-- 1,513 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
---
layout: default
title: Sensor
parent: Devices
nav_order: 8
---

# [](#header-1)Sensor - Monitor values of KNX

## [](#header-2)Overview

Sensors are monitoring temperature, air humidity, pressure etc. from KNX bus.

## [](#header-2)Interface

- `xknx` is the XKNX object.
- `name` is the name of the object.
- `group_address_state` is the KNX group address of the sensor device.
- `sync_state` defines if the value should be actively read from the bus. If `False` no GroupValueRead telegrams will be sent to its group address. Defaults to `True`
- `always_callback` defines if a callback shall be triggered for consecutive GroupValueWrite telegrams with same payload. Defaults to `False`
- `value_type` controls how the value should be rendered in a human readable representation. The attribute may have may have the values `percent`, `temperature`, `illuminance`, `speed_ms` or `current`.
- `device_updated_cb` Callback for each update.

## [](#header-2)Example

```python
sensor = Sensor(
    xknx=xknx,
    name='DiningRoom.Temperature.Sensor',
    always_callback=False,
    group_address_state='6/2/1',
    sync_state=True,
    value_type='temperature'
)
xknx.devices.async_add(sensor)

# Requesting current state via KNX GroupValueRead from the bus
await sensor.sync(wait_for_result=True)

# Returns the value of in a human readable way
sensor.resolve_state()

# Returns the unit of the value as string
sensor.unit_of_measurement()

# Returns the last received telegram or None
sensor.last_telegram
```