Client for the Calaos v3 home automation server. This client keeps the home, rooms and items status in cache, in order to reduce the quantity of requests towards the Calaos server.
Use pycalaos.discover
to discover the Calaos server IP address.
Use pycalaos.Client
to connect to the Calaos server.
This library has been developed with Home Assistant in mind.
This integration is an independent project: the Calaos team is by no means involved in its development.
The pycalaos.discover
function broadcasts a discovery message on the network
and returns the IP address of a discovered Calaos instance, or raises
pycalaos.NoDiscoveryError
.
pycalaos.Client
is a client that connects to a Calaos server.
Initialize it with:
from pycalaos import Client
client = Client(url, username, password)
When initializing the client, it automatically fetches the Calaos configuration
(rooms and items). In order to reload the configuration,
use client.reload_home()
.
The client has the following methods and properties:
reload_home()
: reload the whole configuration (rooms and items)client.update_all()
: checks and updates state for all known items, and returnspycalaos.item.Event
objects for each change.client.poll()
requests changes since the previous poll:- if there is no previous execution of the
poll
function, it registers for polling and acts asupdate_all
- if there is a previous execution of the
poll
function, it requests only changes for this registration (see the Calaos developer doc for more information) and returnspycalaos.item.Event
objects for each change since the previous poll
- if there is no previous execution of the
client.rooms
: rooms as a list ofpycalaos.client.Room
client.items
: items as dictionary of item ID topycalaos.item.Item
client.item_types
: complete list of item types currently in useclient.items_by_type(type: type)
: returns all items of that type (see types in the 2nd columns of the mapping table)
Calaos rooms are represented in pycalaos as pycalaos.client.Room
objects.
Rooms have the following properties:
name
: name of the roomtype
: type from Calaositems
: items in that room, as a list ofpycalaos.item.common.Item
objects
All Calaos IOs are represented in pycalaos as pycalaos.item.common.Item
objects, or objects that inherit from this one.
Items have the following properties:
info
: item description (id, name, type) as a stringid
: ID from Calaosgui_type
: "gui_type" from Calaosio_type
: "io_type" from Calaosname
: name from Calaosstate
: current item state (see the mapping section below)type
: type from Calaosvar_type
: "var_type" from Calaosvisible
: "visible" according to Calaosroom
: thepycalaos.Room
object this item belongs to
Items also have the following functions for internal use (they should not be called directly):
internal_set_state
internal_from_event
Each state change results in a pycalaos.item.common.Event
object, when calling
client.update_all()
or client.poll()
.
Events have the following properties:
item
: item the event is related to, as apycalaos.item.common.Item
objectstate
: state for this event
Mapping from Calaos IOs to pycalaos items is based on the Calaos type:
Calaos type | pycalaos object type |
---|---|
Generic | |
InPlageHoraire | io.InPlageHoraire |
InputTime | io.InputTime |
InputTimer | io.InputTimer |
InternalBool | io.InternalBool |
InternalInt | io.InternalInt |
InternalString | io.InternalString |
Scenario | io.Scenario |
Wago | |
WIDigitalBP | io.InputSwitch |
WIDigitalLong | io.InputSwitchLongPress |
WIDigitalTriple | io.InputSwitchTriple |
WODali | io.OutputLightDimmer |
WODigital | io.OutputLight |
WOVoletSmart | io.OutputShutterSmart |
Web | |
WebInputAnalog | io.InputAnalog |
WebInputString | io.InputString |
WebInputTemp | io.InputTemp |
Fallback | |
Any other type | common.Item |
- state: string
- methods: none
- state: boolean:
True
orFalse
- methods: none
- state: float
- methods: none
- state: string
- methods: none
- state: boolean:
True
orFalse
- methods: none
- state:
pycalaos.item.io.InputSwitchLongPressState
:NONE
,SHORT
,LONG
- methods: none
- state:
pycalaos.item.io.InputSwitchTripleState
:NONE
,SINGLE
,DOUBLE
,TRIPLE
- methods: none
- state: float
- methods: none
- state: boolean:
True
orFalse
- methods: none
- state: boolean:
True
orFalse
- methods:
start()
: Start the timerstop()
: Stop the timerreset(hours, minutes, seconds, milliseconds)
: Reset the configured time to a value
- state: boolean:
True
orFalse
- methods:
true()
: Set a value to truefalse()
: Set a value to falsetoggle()
: Invert boolean valueimpulse(*pattern)
: Do an impulse on boolean value with a pattern. Arguments may be durations (in ms) or "old" to reset to the previous state after the impulse
- state: integer
- methods:
set(value)
: Set a specific integer valueinc()
: Increment value with configured stepdec()
: Decrement value with configured stepinc(value)
: Increment value by valuedec(value)
: Decrement value by value
- state: string
- methods:
set(value)
: Set a specific string value
- state: boolean:
True
orFalse
- methods:
true()
: Switch the light onfalse()
: Switch the light offtoggle()
: Invert light stateimpulse(*pattern)
: Do an impulse on light state with a pattern. Arguments may be durations (in ms) or "old" to reset to the previous state after the impulse
- state: integer between 0 and 100
- methods:
true()
: Switch the light onfalse()
: Switch the light offtoggle()
: Invert light stateimpulse(*pattern)
: Do an impulse on light state with a pattern. Arguments may be durations (in ms) or "old" to reset to the previous state after the impulseset_off(value)
: Set light value without switching on. This will be the light intensity for the next ONset(value)
: Set light intensity and swith on if light is offup(value)
: Increase intensity by X percentdown(value)
: Decrease intensity by X percenthold_press()
: Dynamically change light intensity when holding a switch (press action)hold_stop()
: Dynamically change light intensity when holding a switch (stop action)
- state: dictionary, with two elements:
action
:pycalaos.item.io.OutputShutterAction
:STATIONARY
,UP
,DOWN
,STOP
,CALIBRATION
position
: integer between 0 and 100
- methods:
up()
: Open the shutterdown()
: Close the shutterstop()
: Stop the shuttertoggle()
: Invert shutter stateimpulse_up(duration)
: Open shutter for X msimpulse_down(duration)
: Close shutter for X msset(value)
: Set shutter at position X in percentup(value)
: Open the shutter by X percentdown(value)
: Close the shutter by X percentcalibrate()
: Start calibration on shutter. This opens fully the shutter and resets all internal position values. Use this if shutter sync is lost.
- state: boolean:
True
orFalse
- methods:
true()
: Start the scenariofalse()
: Stop the scenario (only for special looping scenarios)