Exemplo n.º 1
0
def setup_platform(hass, config, add_devices, discovery_info=None):
    """Setup the Yamaha platform."""
    import rxv

    name = config.get(CONF_NAME)
    host = config.get(CONF_HOST)
    source_ignore = config.get(CONF_SOURCE_IGNORE)
    source_names = config.get(CONF_SOURCE_NAMES)
    zone_ignore = config.get(CONF_ZONE_IGNORE)

    if discovery_info is not None:
        name = discovery_info[0]
        model = discovery_info[1]
        ctrl_url = discovery_info[2]
        desc_url = discovery_info[3]
        receivers = rxv.RXV(ctrl_url,
                            model_name=model,
                            friendly_name=name,
                            unit_desc_url=desc_url).zone_controllers()
        _LOGGER.info("Receivers: %s", receivers)
    elif host is None:
        receivers = []
        for recv in rxv.find():
            receivers.extend(recv.zone_controllers())
    else:
        ctrl_url = "http://{}:80/YamahaRemoteControl/ctrl".format(host)
        receivers = rxv.RXV(ctrl_url, name).zone_controllers()

    for receiver in receivers:
        if receiver.zone not in zone_ignore:
            add_devices(
                [YamahaDevice(name, receiver, source_ignore, source_names)])
Exemplo n.º 2
0
def main():
    parser = argparse.ArgumentParser(description='wake up with music')
    parser.add_argument('--playlist',
                        type=str,
                        help='foo help',
                        default="Alarm Clock")
    parser.add_argument('--sleep', type=str, help='foo help', default="90 min")
    args = parser.parse_args()

    r = rxv.RXV("192.168.1.116")
    r.on = True
    time.sleep(0.5)
    r.sleep = args.sleep
    r.input = "HDMI4"
    r.volume = START_VOLUME

    cli = MPDClient()
    cli.connect("dom.wuub.net", 6600)
    cli.clear()
    cli.load(args.playlist)
    cli.play()

    for vol in range(START_VOLUME, MID_VOLUME, 1):
        r.volume = vol
        time.sleep(0.5)

    time.sleep(30)
    requests.get("http://dom.wuub.net/api/lights/small/on")

    for vol in range(MID_VOLUME, TARGET_VOLUME, 1):
        r.volume = vol
        time.sleep(2)

    time.sleep(60)
    requests.get("http://dom.wuub.net/api/lights/large/on")
Exemplo n.º 3
0
 def test_discover_zones(self, m):
     m.get(DESC_XML, text=sample_content('rx-v675-desc.xml'))
     rec = rxv.RXV(FAKE_IP)
     zones = rec.zone_controllers()
     self.assertEqual(len(zones), 2, zones)
     self.assertEqual(zones[0].zone, "Main_Zone")
     self.assertEqual(zones[1].zone, "Zone_2")
Exemplo n.º 4
0
    def Update(self):
        try:
            start = time.time()
            if (self.receiver == None):
                self.receiver = rxv.RXV(
                    "http://" + self.ip + ":80/YamahaRemoteControl/ctrl",
                    "Yamaha Receiver", "Zone_2")

            bReceiverPower = (self.powerMPD and self.volumeMPD > 0) or (
                self.powerShairport and self.volumeShairport > -140)
            if (self.receiver.on != bReceiverPower):
                self.receiver.on = bReceiverPower
                if (bReceiverPower and self.receiver.input != 'AV7'):
                    self.receiver.input = 'AV7'

            if (bReceiverPower):
                volume = 0
                if (self.powerShairport):
                    volume = self.volumeShairport
                else:
                    volume = convertVolToDB(self.volumeMPD, self.minVolume,
                                            self.maxVolume)
                if (bReceiverPower and self.receiver.volume != volume):
                    self.receiver.volume = volume
            end = time.time()
            print 'Update took {}'.format(end - start)
        except:
            print "Exception during Update"
            self.receiver = None
Exemplo n.º 5
0
    def monitor(self):
        soco.config.EVENT_LISTENER_PORT = self.cfg['sonos']['event_port']
        self.sonos = soco.SoCo(
            self.cfg['sonos']['ip'])
        self.yamaha = rxv.RXV(
            self.cfg['yamaha']['ctrl_url'], self.cfg['yamaha']['model_name'])

        self.log.info("{} ({}) Power={}, Input={}, Volume={}".format(
            self.cfg['yamaha']['friendly_name'],
            self.cfg['yamaha']['model_name'],
            self.yamaha.on, self.yamaha.input, self.yamaha.volume))

        signal(SIGTERM, self.handle_sigterm)

        while self.break_loop is False:
            self._subscription()
            try:
                self.event = self.subscription.events.get(timeout=10)
                self.status = self.event.variables.get('transport_state')
                self._status()
            except Queue.Empty:
                pass
            except KeyboardInterrupt:
                self.handle_sigterm()
                break

        if self.break_loop:
            self.subscription.unsubscribe()
            soco.events.event_listener.stop()
Exemplo n.º 6
0
def _receiver_endpoint(body):
    address = body['address']
    on = body.get('on')
    input = body.get('input')
    volume = body.get('volume')
    
    receiver = rxv.RXV(RECEIVER_URL.format(address))

    try:
        if not receiver.basic_status:
            return ""
    except Exception as e:
        return ""

    if on is not None:
        receiver.on = on

    if on and input:
        receiver.input = input

    if volume and volume[0] == '+':
        receiver.volume = receiver.volume + int(volume[1:])
    elif volume and volume[0] == '-':
        receiver.volume = receiver.volume - int(volume[1:])
    elif volume:
        receiver.volume = int(volume)

    return ""
Exemplo n.º 7
0
 def test_basic_object(self, m):
     m.get(DESC_XML, text=sample_content('rx-v675-desc.xml'))
     rec = rxv.RXV(FAKE_IP)
     self.assertEqual(rec.ctrl_url,
                      'http://%s/YamahaRemoteControl/ctrl' % FAKE_IP)
     self.assertEqual(rec.unit_desc_url,
                      'http://%s/YamahaRemoteControl/desc.xml' % FAKE_IP)
Exemplo n.º 8
0
	def __init__(self):
		self.macrolist = {} # {'name':['m','a','c','r','o'], 'name2':[...]}
		self.rcfile = "./.remctrl.rc"
		self._readMacros()
		# receivers = rxv.find()
		# print(receivers)
		# rx = receivers[0]
		self.rx = rxv.RXV('http://varshneyarxv675/YamahaRemoteControl/ctrl', 'RX-V675')
Exemplo n.º 9
0
def setup_platform(hass, config, add_devices, discovery_info=None):
    """Set up the Yamaha platform."""
    import rxv
    # keep track of configured receivers so that we don't end up
    # discovering a receiver dynamically that we have static config
    # for.
    if hass.data.get(KNOWN, None) is None:
        hass.data[KNOWN] = set()

    name = config.get(CONF_NAME)
    host = config.get(CONF_HOST)
    source_ignore = config.get(CONF_SOURCE_IGNORE)
    source_names = config.get(CONF_SOURCE_NAMES)
    zone_ignore = config.get(CONF_ZONE_IGNORE)
    zone_names = config.get(CONF_ZONE_NAMES)

    if discovery_info is not None:
        name = discovery_info.get('name')
        model = discovery_info.get('model_name')
        ctrl_url = discovery_info.get('control_url')
        desc_url = discovery_info.get('description_url')
        if ctrl_url in hass.data[KNOWN]:
            _LOGGER.info("%s already manually configured", ctrl_url)
            return
        receivers = rxv.RXV(
            ctrl_url, model_name=model, friendly_name=name,
            unit_desc_url=desc_url).zone_controllers()
        _LOGGER.info("Receivers: %s", receivers)
        # when we are dynamically discovered config is empty
        zone_ignore = []
    elif host is None:
        receivers = []
        for recv in rxv.find():
            receivers.extend(recv.zone_controllers())
    else:
        ctrl_url = "http://{}:80/YamahaRemoteControl/ctrl".format(host)
        receivers = rxv.RXV(ctrl_url, name).zone_controllers()

    for receiver in receivers:
        if receiver.zone not in zone_ignore:
            hass.data[KNOWN].add(receiver.ctrl_url)
            add_devices([
                YamahaDevice(name, receiver, source_ignore,
                             source_names, zone_names)
            ], True)
Exemplo n.º 10
0
    async def init(self):
        """Initialise the item"""
        self.play_status = None
        try:
            self.av_receiver = rxv.RXV(CTRL_URL.format(host=self.cfg["host"]))
        except (ConnectionError, ConnectionRefusedError):
            return False

        tick(2)(self.update)
Exemplo n.º 11
0
def _discovery(config_info):
    """Discover receivers from configuration in the network."""
    if config_info.from_discovery:
        receivers = rxv.RXV(
            config_info.ctrl_url,
            model_name=config_info.model,
            friendly_name=config_info.name,
            unit_desc_url=config_info.desc_url,
        ).zone_controllers()
        _LOGGER.debug("Receivers: %s", receivers)
    elif config_info.host is None:
        receivers = []
        for recv in rxv.find():
            receivers.extend(recv.zone_controllers())
    else:
        receivers = rxv.RXV(config_info.ctrl_url, config_info.name).zone_controllers()

    return receivers
Exemplo n.º 12
0
    async def init(self):
        """Initialise the item"""
        self.play_status = None
        try:
            self.av_receiver = rxv.RXV(CTRL_URL.format(host=self.cfg["host"]))
        except (ConnectionError, ConnectionRefusedError):
            return False

        self.update_task = self.core.loop.create_task(self.interval_update())
Exemplo n.º 13
0
	def __init__(self):
		self.ctrlist = {  'p': 'power',           'v': 'volume',        'd': 'DSP',           'i': 'input'}
		self.ctrprompt = {'p': self._powerprompt, 'v': self._volprompt, 'd': self._dspprompt, 'i': self._inpprompt}
		self.macrolist = {} # {'name':['m','a','c','r','o'], 'name2':[...]}
		self.rcfile = "./.remctrl.rc"

		self._readMacros()

		# receivers = rxv.find()
		# print(receivers)
		# rx = receivers[0]
		self.rx = rxv.RXV('http://varshneyarxv675/YamahaRemoteControl/ctrl', 'RX-V675')
Exemplo n.º 14
0
async def action(user: User = Depends(get_user), body=Body(None)):
    data = body
    response_data = {
        "request_id": uuid4(),
        "payload": {"user_id": user.id, "devices": []},
    }
    for device in data["payload"]["devices"]:
        rx_device = rxv.RXV(device["id"])
        response_device = {"id": device["id"], "capabilities": []}
        for capability in device["capabilities"]:
            capability_instance = get_capability_by_name(capability["type"])
            response_device["capabilities"].append(
                capability_instance.change_device_state(rx_device, capability)
            )
        response_data["payload"]["devices"].append(response_device)
    return response_data
Exemplo n.º 15
0
 def act(self, client_address, name, state):
     print "Name", name, "State", state, "from client @", client_address
     rx = rxv.RXV(
         "http://dentw04tc-c-107.dental.nyu.edu/YamahaRemoteControl/ctrl",
         "RX-A830")
     if (name == "projector"):
         if (state == True):
             command = convertHex(OnCommand)
             serialConnection.write(command)
             rx.input = "HDMI1"
             rx.volume = -10
         elif (state == False):
             command = convertHex(OffCommand)
             serialConnection.write(command)
             rx.input = "AirPlay"
             rx.volume = -30
     if (name == "git"):
         if (state == True):
             subprocess.call(['git pull'], shell=True)
             exit()
         elif (state == False):
             print "Figure out what to do with this"
     if (name == "speakers"):
         if (state == True):
             rx.on = True
         elif (state == False):
             rx.on = False
     if (name == "input"):
         Inputs = [i for i in rx.inputs()]
         i = Inputs.index(rx.input)
         if (state == True):
             if (Inputs[i] == Inputs[-1]):
                 rx.input = Inputs[0]
             else:
                 rx.input = Inputs[i + 1]
             i += 1
         elif (state == False):
             if (i == 0):
                 rx.input = Inputs[-1]
             else:
                 rx.input = Inputs[i - 1]
             i += 1
     return True
Exemplo n.º 16
0
def setup_platform(hass, config, add_devices, discovery_info=None):
    """Setup the Yamaha platform."""
    import rxv

    name = config.get(CONF_NAME)
    host = config.get(CONF_HOST)
    source_ignore = config.get(CONF_SOURCE_IGNORE)
    source_names = config.get(CONF_SOURCE_NAMES)

    if host is None:
        receivers = rxv.find()
    else:
        receivers = \
            [rxv.RXV("http://{}:80/YamahaRemoteControl/ctrl".format(host),
                     name)]

    add_devices(
        YamahaDevice(name, receiver, source_ignore, source_names)
        for receiver in receivers)
Exemplo n.º 17
0

def receiversVol(rx, vol=-51):
    rx.volume = vol
    return print('Receiver vol= {}'.format(vol))


def receiversInputFind(rx):
    return rx.inputs()


def receiversSetInput(rx, input='NET RADIO'):
    rx.input = input
    return print('Input = {}'.format(input))


def receiversPlay(rx):
    if (rx.get_playback_support() & PlaybackSupport.PLAY) != 0:
        rx.play()
    return print('Play OK! ')


rx = receiversFind()
rx = rxv.RXV("http://192.168.0.201:80/YamahaRemoteControl/ctrl", "RX-V473")

receiversOnOff(rx, True)
receiversVol(rx, -47)
receiversInputFind(rx)
receiversSetInput(rx)
receiversPlay(rx)
Exemplo n.º 18
0
 def __init__(self, url, name):
     RxvLogger.log("Yamaha connect ip: " + url)
     self.rv = rxv.RXV(url, name)
Exemplo n.º 19
0
 def do_change_state(self, transition):
     if transition == gst.STATE_CHANGE_NULL_TO_READY:
         logger.info("rxv")
         self._client = rxv.RXV(self.ip)
             #return gst.STATE_CHANGE_FAILURE
     return gst.STATE_CHANGE_SUCCESS
Exemplo n.º 20
0
 def setUp(self, m):
     super(TestFeaturesV675, self).setUp()
     m.get(DESC_XML, text=sample_content('rx-v675-desc.xml'))
     self.rec = rxv.RXV(FAKE_IP)
Exemplo n.º 21
0
def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the Yamaha platform."""
    import rxv

    # Keep track of configured receivers so that we don't end up
    # discovering a receiver dynamically that we have static config
    # for. Map each device from its zone_id to an instance since
    # YamahaDevice is not hashable (thus not possible to add to a set).
    if hass.data.get(DATA_YAMAHA) is None:
        hass.data[DATA_YAMAHA] = {}

    name = config.get(CONF_NAME)
    host = config.get(CONF_HOST)
    source_ignore = config.get(CONF_SOURCE_IGNORE)
    source_names = config.get(CONF_SOURCE_NAMES)
    zone_ignore = config.get(CONF_ZONE_IGNORE)
    zone_names = config.get(CONF_ZONE_NAMES)

    if discovery_info is not None:
        name = discovery_info.get("name")
        model = discovery_info.get("model_name")
        ctrl_url = discovery_info.get("control_url")
        desc_url = discovery_info.get("description_url")
        receivers = rxv.RXV(ctrl_url,
                            model_name=model,
                            friendly_name=name,
                            unit_desc_url=desc_url).zone_controllers()
        _LOGGER.debug("Receivers: %s", receivers)
        # when we are dynamically discovered config is empty
        zone_ignore = []
    elif host is None:
        receivers = []
        for recv in rxv.find():
            receivers.extend(recv.zone_controllers())
    else:
        ctrl_url = "http://{}:80/YamahaRemoteControl/ctrl".format(host)
        receivers = rxv.RXV(ctrl_url, name).zone_controllers()

    devices = []
    for receiver in receivers:
        if receiver.zone in zone_ignore:
            continue

        device = YamahaDevice(name, receiver, source_ignore, source_names,
                              zone_names)

        # Only add device if it's not already added
        if device.zone_id not in hass.data[DATA_YAMAHA]:
            hass.data[DATA_YAMAHA][device.zone_id] = device
            devices.append(device)
        else:
            _LOGGER.debug("Ignoring duplicate receiver: %s", name)

    def service_handler(service):
        """Handle for services."""
        entity_ids = service.data.get(ATTR_ENTITY_ID)

        devices = [
            device for device in hass.data[DATA_YAMAHA].values()
            if not entity_ids or device.entity_id in entity_ids
        ]

        for device in devices:
            port = service.data[ATTR_PORT]
            enabled = service.data[ATTR_ENABLED]

            device.enable_output(port, enabled)
            device.schedule_update_ha_state(True)

    hass.services.register(DOMAIN,
                           SERVICE_ENABLE_OUTPUT,
                           service_handler,
                           schema=ENABLE_OUTPUT_SCHEMA)

    add_entities(devices)
Exemplo n.º 22
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import yamaha
import rxv
import switchBoxD_API
import loctime
import time
'''Uruchamia i po 40min wyłącza wzmacniacz'''
rx = rxv.RXV("http://192.168.1.102:80/YamahaRemoteControl/ctrl", "RX-V671")

halospoty = 'http://192.168.1.201'
lampki = 'http://192.168.1.202'
kotlownia = 'http://192.168.1.203'

while True:

    if rx.on == False:
        yamaha.receiversInputFind(rx)
        yamaha.receiversOnOff(rx, True)
        time.sleep(1)
        yamaha.receiversVol(rx, -50)
        time.sleep(1)
        yamaha.receiversSetInput(rx, 'TUNER')
        time.sleep(2)

    if rx.on == True:
        time.sleep(3600)
        # print(yamaha.receiversInputFind(rx))
        yamaha.receiversOnOff(rx, False)
        switchBoxD_API.relay_set_get(lampki, 0, 0)
Exemplo n.º 23
0
#!/usr/bin/python
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
from os import curdir, sep, environ
import rxv
import json

PORT_NUMBER = 8080

receiver = rxv.RXV(
    "http://" + environ['AMP_IP'] + ":80/YamahaRemoteControl/ctrl", "AMP")
print(receiver)


#This class will handles any incoming request from
#the browser
class myHandler(BaseHTTPRequestHandler):

    #Handler for the GET requests
    def do_GET(self):
        if self.path == "/on":
            receiver.on = True
        if self.path == "/off":
            receiver.on = False
        self.send_response(200)
        self.send_header("Content-type", "application/json")
        self.end_headers()
        response = receiver.basic_status.__dict__
        playStatus = receiver.play_status()
        if playStatus is not None:
            response.update(playStatus.__dict__)
        self.wfile.write(json.dumps(response))
Exemplo n.º 24
0
#!/usr/bin/python

import rxv
import os
import time

rx = rxv.RXV(os.environ["RX600"])

def onWithBookmark (num):
  rx.on = True
  time.sleep(2)
  rx.input = "NET RADIO"
  time.sleep(1)
  rx.volume = -80
  rx.menu_jump_line(1)
  rx.menu_sel()
  time.sleep(2)
  rx.menu_jump_line(1)
  rx.menu_sel()
  time.sleep(2)
  rx.menu_jump_line(num)
  rx.menu_sel()
  time.sleep(2)
  rx.volume_fade(-65)

onWithBookmark(1)