Music Streamer Interface

Posted on
Wed Jan 13, 2021 12:09 am
pgershon offline
Posts: 399
Joined: Jul 10, 2004

Re: Music Streamer Interface

I am moving along on my plugin and have a very basic version that I am trying to interface with my Nuvo Concerto plugin. But I got stuck this evening and must be having a brain cramp and cannot get this figured out.

I created a device type LinkPlay and the devices.xml starts as follows:

It displays fine and I am able to input both an 'address' and a 'concertozone'. But I cannot figure out how to reference the concertozone in my code.

Code: Select all
   <Device type="custom" id="LinkPlay">
      <Name> LinkPlay Player </Name>
         <Field id="address" type="textfield">
            <Label>IP Address:</Label>
         <Field id="concertozone" type="menu" defaultValue="1">
            <Label>Concerto Input</Label>
               <Option value="1">Input:1</Option>
               <Option value="2">Input:2</Option>
               <Option value="3">Input:3</Option>
               <Option value="4">Input:4</Option>
               <Option value="5">Input:5</Option>
               <Option value="6">Input:6</Option>
         <Field type="separator" id="sepL" />
         <Field type="textfield" id="Button1" defaultValue="">
            <Label>Preset #1:</Label>
         <State id="playerid">
            <TriggerLabel>Player Id</TriggerLabel>
            <ControlPageLabel> Player Id </ControlPageLabel>

My code is (in the startup):
Code: Select all
      for musicProperties in indigo.devices.iter("com.perrygershon.indigoplugin.LinkPlay"):
musicProperties.address works fine. But neither musicProperties. concertozone nor musicProperties.pluginProps["concertozone"] is acceptable. The former generates an error "AttributeError: 'Device' object has no attribute 'concertozone'" while the latter generates "KeyError: key concertozone not found in dict".

Any ideas?

It feels like I should be doing something else to define concertozone but I am stumped

Posted on
Sun Jan 17, 2021 8:01 pm
matt (support) offline
Site Admin
User avatar
Posts: 20380
Joined: Jan 27, 2003
Location: Texas

Re: Music Streamer Interface

The defaultValue you have specified in the XML is only used when the device is first created, so if this is an existing device then it may not have that property defined yet. One approach is to use the get() method to access the value because you can pass in a default value to be used if the element doesn't exist in the pluginProps (in this case I used 1 as the default):

Code: Select all
b = musicProperties.pluginProps.get("concertozone", 1)


Who is online

Users browsing this forum: No registered users and 2 guests