From 45c45ab4e35f62ab341068dded5e025ca6a6d66d Mon Sep 17 00:00:00 2001 From: Michel van de Wetering Date: Tue, 4 Apr 2017 21:15:55 +0200 Subject: [PATCH] Examples in the readme --- README.rst | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/README.rst b/README.rst index 0e01c92..6e3ba03 100644 --- a/README.rst +++ b/README.rst @@ -17,6 +17,32 @@ This package contains: * YncaReceiver: a class that represents YNCA capable receiver and allows you to control it * ynca_console: a function that provides a console to directly give YNCA commands and see the responses (debugging) +Example +======= +# Create a receiver object. This call takes a while (multiple seconds) since +# it communicates quite a lot with the actual device. +# Note that later calls that control the receiver are are fast (they get async responses) +receiver = ynca.YncaReceiver("/dev/tty1") # Port could also be e.g. COM3 on Windows or 192.168.1.12 for IP connection + +# Attributes that are still None after initialization are not supported by the receiver/zone +#``receiver.zones`` is a dictionary with all available zone object for the receiver +main = receiver.zones["MAIN"] # other possible zones are ZONE2, ZONE3 and ZONE4 +print(main.name) # Print the name of the main zone + +#``receiver.inputs`` is a dictionary of available inputs with the key being the unique ID and the value the friendly name +if available +print(main.inputs) + +# To get notifications when something changes register callbacks +def on_update_callback(): + pass +main.on_update_callback = on_update_callback + +# Examples to control the zone +main.on = True +main.input = "HDMI3" +main.volume_up() +