Configuration¶
File Structure¶
Knut is configured by a YAML configuration file. Knut objects are defined
directly in the configuration and are initialize from the file (see
KnutConfig
for more details). To define a Knut
object in the configuration, the tag !knutobject
is used:
!knutobject
module: module
class: Class
attribute: value
...
The keys module
and class
are mandatory and specify the Class and the
module containing it to load. The keys after the two mandatory are the arguments
of the classes __init__()
method. For example, the
knut.server.tcpserver.KnutTCPServer
would be configured as
following:
!knutobject
module: knut.server.tcpserver
class: KnutTCPServer
address: 127.0.0.1
port: 8080
If no configuration is found, default values are used which are documented in the following sections.
For more details, see the Example Configuration.
Knut Configuration Reference¶
server¶
Configuration options to setup the
KnutTCPServer
. The TCP server is bound to the
address
on the specified port
. The default values are for the address
127.0.0.1
and for the port 8080
:
server:
!knutobject
module: knut.server.tcpserver
class: KnutTCPServer
address: 127.0.0.1
port: 8080
lights¶
Configures all light back-ends which are subclassed from the
Light
superclass. To add a back-end service,
the back-end object needs to be add to the lights sequence. For example, a
PyTradfriLight
light is add as following:
lights:
- !knutobject
module: knut.services.light.pytradfri
class: PyTradfriLight
location: Sideboard
unique_name: table_living_room
room: Living Room
device_id: 65536
host: 192.168.0.2
psk_id:
psk:
On default, no light is configured.
local¶
Configures the Local
service. The local service
has the configuration keys location
, longitude
, latitude
and
elevation
. Note that the degree values are decimal values and the elevation
is in metres. By default, a local at latitude 0, longitude 0 and elevation 0 is
configured. For example, Hamburg in Germany would be defined as following:
local:
!knutobject
module: knut.services.local
class: Local
location: Hamburg
unique_name: hamburg
latitude: 53.5506401
longitude: 9.9917872
elevation: 18
task¶
Configuration options for the Task
service. Each
task is written to a file in the directory task_dir
. The default directory
is ~/.local/share/knut/tasks
:
task:
!knutobject
module: knut.apis
class: Task
task_dir: "~/.local/share/knut/tasks"
temperature¶
Configures all temperature back-ends which are subclassed from the
Temperature
superclass. Each back-end
must have a unique_name
which is used as identifier in the Knut system. The
key location
defines the location name where the temperature is measured
e.g. a room or city name. The temperature back-ends are added analog to the
temperature
sequence as light back-ends are add to the lights
sequence.
For example, a temperature back-end with the unique name localWeather
using
the OpenWeatherMap
service
with it’s additional argument appid
is add to the temperature sequence:
temperature:
- !knutobject
module: knut.services.temperature.openweathermap
class: OpenWeatherMap
location: Hamburg
unique_name: localWeather
appid:
Example Configuration¶
Example configuration etc/example.yml
:
# _ __ _
# | |/ /_ __ _ _| |_
# | ' /| '_ \| | | | __|
# | . \| | | | |_| | |_
# |_|\_\_| |_|\__,_|\__|
#
# Default values are commented. Uncomment and edit to change them.
#
# Most apis or services are configured by constructing a corresponding
# object from this configuration file. Therefore, the !knutobject tag
# is used with a mapping following it. The mapping has the two
# mandatory keys module and class. Those define the module of the
# class to be loaded. For example, the class Bar of the module foo is
# configured as following:
#
# !knutobject
# module: foo
# class: Bar
#
---
# Knut's TCP server
# The TCP server is bound to the address on the specified port.
server:
!knutobject
module: knut.server.tcpserver
class: KnutTCPServer
#address: 127.0.0.1
#port: 8080
# Light back-ends
# To add a back-end service, the back-end object needs to be add to
# the lights sequence. For example, a TRADFRI light is add as
# following:
#
# lights:
# - !knutobject
# module: knut.services.light..pytradfri
# class: PyTradfriLight
# location: Sideboard
# uid: table_living_room
# room: Living Room
# device_id: 65536
# host: 192.168.0.2
# psk_id:
# psk:
#
lights:
- !knutobject
module: knut.services.light.dummylight
class: DummyLight
location: Sideboard
uid: sideboard_light
room: Dinning Room
dimlevel: true
color: false
temperature: true
- !knutobject
module: knut.services.light.dummylight
class: DummyLight
location: Table
uid: dinningtable_light
room: Dinning Room
dimlevel: true
color: false
temperature: true
- !knutobject
module: knut.services.light.dummylight
class: DummyLight
location: Pool
uid: pool_light
room: Pool House
dimlevel: false
color: false
temperature: false
- !knutobject
module: knut.services.light.dummylight
class: DummyLight
location: Pool House
uid: pool_house_light
room: Pool House
dimlevel: true
color: true
temperature: false
- !knutobject
module: knut.services.light.dummylight
class: DummyLight
location: Windowsill
uid: windowsill_light
room: Bedroom
dimlevel: true
color: false
temperature: true
- !knutobject
module: knut.services.light.dummylight
class: DummyLight
location: Chandelier
uid: entry_hall_light
room: Entry Hall
dimlevel: true
color: false
temperature: false
# The Local service
local:
!knutobject
module: knut.services.local
class: Local
location: Beverly Hills
uid: home
latitude: 34.091944
longitude: -118.401667
elevation: 209
# Tasks
# Each task is written to a file in the task_dir.
task:
!knutobject
module: knut.apis
class: Task
#task_dir: "~/.local/share/knut/tasks"
# Temperature back-ends
# Analog to the lights back-ends, a temperature back-end is configured
# by adding a back-end object to the temperature sequence. For
# example, to configure an OpenWeatherMap back-end, add the following
# to temperature:
#
# temperature:
# - !knutobject
# module: knut.services.temperature.openweathermap
# class: OpenWeatherMap
# location: Hamburg
# uid: localWeather
# appid:
#
temperature:
- !knutobject
module: knut.services.temperature.dummytemperature
class: DummyTemperature
location: Pool House
uid: poolHouse
- !knutobject
module: knut.services.temperature.dummytemperature
class: DummyTemperature
location: Pool
uid: pool
- !knutobject
module: knut.services.temperature.dummytemperature
class: DummyTemperature
location: Entry Hall
uid: entryHall
- !knutobject
module: knut.services.temperature.dummytemperature
class: DummyTemperature
location: Beverly Hills
uid: localWeather