TaliaBeeIO is a Python interface to TaliaBee API. TaliaBeeIO can be used to monitor and to control the I/O pins of the TaliaBee box through API.
- Python 3.x
- Python Requests module
pip3 install taliabeeio
>>> from taliabeeio import TaliaBeeIO
>>> io = TaliaBeeIO()
>>>
>>> # read from the analog input 3
>>> print(io.ai3)
0
>>> # write to the analog output 4
>>> io.ao4 = 250
>>>
>>> # set the relay output 13
>>> io.ro13 = True
>>>
>>> # reset the digital output 9
>>> io.do9 = False
>>>
>>> # read the temperature
>>> print(io.temperature)
37.125
>>> # reset all outputs
>>> io.reset()
TaliaBeeIO(url='http://127.0.0.1', timeout=10, verify=False)
Create a new TaliaBeeIO instance. The instance communicates with the TaliaBee box at the given url
. The default value is http://127.0.0.1
and the instance communicates with the local box, if there is no given url
.
timeout
sets the socket timeout value. The default value is 10 seconds.
verify
is the SSL certificate verification when HTTPS is used in url
. Set False
when the self-signed certificate is used and this is the situation in most cases.
>>> from taliabeeio import TaliaBeeIO
>>> io = TaliaBeeIO()
>>> print(io.ai3)
1350
>>> io_remote = TaliaBeeIO(url='http://192.168.0.10')
>>> print(io_remote.ai3)
0
Read-only digital inputs. diN
where N is a number from 1
to 16
. Its value is either 0
or 1
.
>>> print(io.di5)
0
Writable digital outputs. doN
where N is a number from 1
to 12
. Its value is either 0
/False
or 1
/True
.
>>> print(io.do12)
0
>>> io.do12 = True
>>> print(io.do12)
1
Writable relay outputs. roN
where N is a number from 13
to 16
. Its value is either 0
/False
or 1
/True
.
>>> print(io.ro14)
0
>>> io.ro14 = True
>>> print(io.ro14)
1
Read-only 12 bit analog inputs. aiN
where N is a number from 1
to 4
. Its value is between 0 and 4095.
>>> print(io.ai1)
0
Writable 12 bit analog outputs. aoN
where N is a number from 1
to 4
. Its value is between 0 and 4095.
>>> print(io.ao4)
0
>>> io.ao4 = 2000
>>> print(io.ao4)
2000
Read-only temperature value in Celsius.
>>> print(io.temperature)
37.625
The dictionary object which contains the values of all digital and analog I/O and the temperature.
>>> print(io.status)
{'di': {'2': 0, '8': 0, '13': 0, '7': 0, '11': 0, '15': 0, '14': 0, '6': 0,
'10': 0, '16': 0, '1': 0, '4': 0, '9': 0, '3': 0, '12': 0, '5': 0},
'do': {'2': 0, '8': 0, '7': 0, '11': 0, '6': 0, '10': 0, '1': 0, '4': 0,
'9': 0, '3': 0, '12': 1, '5': 0}, 'temperature': 37.625, 'ro': {'15': 0,
'14': 1, '13': 0, '16': 0}, 'ai': {'2': 0, '1': 1, '4': 0, '3': 1},
'ao': {'2': 0, '1': 0, '4': 2000, '3': 0}}
>>>
>>> print(io.status.get('ao'))
{'2': 0, '1': 0, '4': 2000, '3': 0}
di_read(pin)
Return the value of the digital input. pin
is the digital input pin number and it's an integer between 1 and 16. The returning value is either 0
or 1
.
>>> print(io.di_read(2))
0
do_read(pin)
Return the value of the digital output. pin
is the digital output pin number and it's an integer between 1 and 12. The returning value is either 0
or 1
.
>>> print(io.do_read(8))
0
do_set(pin)
Set the digital output. pin
is the digital output pin number and it's an integer between 1 and 12.
>>> print(io.do8)
0
>>> io.do_set(8)
>>> print(io.do8)
1
do_reset(pin)
Reset the digital output. pin
is the digital output pin number and it's an integer between 1 and 12.
>>> print(io.do8)
1
>>> io.do_reset(8)
>>> print(io.do8)
0
do_write(pin, value)
Write to the digital output. pin
is the digital output pin number and it's an integer between 1 and 12. value
is either 0
/False
or 1
/True
.
>>> print(io.do3)
0
>>> io.do_write(3, True)
>>> print(io.do3)
1
ro_read(pin)
Return the value of the relay output. pin
is the relay output pin number and it's an integer between 13 and 16. The returning value is either 0
or 1
.
>>> print(io.ro_read(14))
0
ro_set(pin)
Set the relay output. pin
is the relay output pin number and it's an integer between 13 and 16.
>>> print(io.ro14)
0
>>> io.ro_set(14)
>>> print(io.ro14)
1
ro_reset(pin)
Reset the relay output. pin
is the relay output pin number and it's an integer between 13 and 16.
>>> print(io.ro14)
1
>>> io.ro_reset(14)
>>> print(io.ro14)
0
ro_write(pin, value)
Write to the relay output. pin
is the relay output pin number and it's an integer between 13 and 16. value
is either 0
/False
or 1
/True
.
>>> print(io.ro14)
0
>>> io.ro_write(14, True)
>>> print(io.ro14)
1
ai_read(pin)
Return the value of the analog input. pin
is the analog input pin number and it's an integer between 1 and 4. The returning value is an integer between 0 and 4095.
>>> print(io.ai_read(2))
8
ao_read(pin)
Return the value of the analog output. pin
is the analog output pin number and it's an integer between 1 and 4. The returning value is an integer between 0 and 4095.
>>> print(io.ao_read(2))
0
ao_write(pin, value)
Write to the analog output. pin
is the analog output pin number and it's an integer between 1 and 4. value
is an integer between 0 and 4095.
>>> print(io.ao2)
0
>>> io.ao_write(2, 500)
>>> print(io.ao2)
500
reset()
Reset all digital and analog outputs.
>>> io.do3 = True
>>> io.ao4 = 1350
>>> print(io.do3, io.ao4)
1 1350
>>> io.reset()
>>> print(io.do3, io.ao4)
0 0