File: send.py

package info (click to toggle)
python-pilight 0.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 148 kB
  • sloc: python: 398; makefile: 4
file content (25 lines) | stat: -rw-r--r-- 993 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
"""Example how to to simply send RF commands.

A running pilight-daemon is needed.
"""

from pilight import pilight

# pylint: disable=C0103
if __name__ == '__main__':
    # Create new pilight connection that runs on localhost with port 5000
    pilight_client = pilight.Client(host='127.0.0.1', port=5000)

    # Send a good code. It is checked to be acknoledged by the piligt-daemon.
    # Data from https://manual.pilight.org/en/api
    pilight_client.send_code(data={"protocol": ["kaku_switch"],
                                   "id": 1,
                                   "unit": 0,
                                   "off": 1})

    # Send a wrong code that lead to an IO error since the pilight-daemon
    # rejects it. Data from https://manual.pilight.org/en/api
    pilight_client.send_code(data={"protocol": ["kaku_switch"],
                                   "id": 0,  # ID has to be > 0
                                   "unit": 0,
                                   "off": 1})