ok, i've been on this all day, and have read loads and looked at countless examples. I think I am now code blind. Fed up now...any help greatly appreciated.
I have this action in my plugin.py module
- Code: Select all
def mute(self, instruction, devId):
dev=indigo.devices[devId]
from pyviera import VieraFinder
if __name__ == '__main__':
vf = VieraFinder()
tv = vf.get_viera()
tv.mute()
and another module ...pyviera
- Code: Select all
import socket
import indigo
from urllib2 import urlopen
from parsing import parse_discovery_response, parse_description
IFACE = '0.0.0.0'
SSDP_MCAST_ADDR = '239.255.255.250'
SSDP_PORT = 1900
class VieraFinder(object):
def __init__(self):
desc_url = self.discover()
desc = urlopen(desc_url).read()
self.viera = parse_description(desc, desc_url)
def get_viera(self):
return self.viera
def discover(self):
header = 'M-SEARCH * HTTP/1.1'
fields = (
('ST', 'urn:panasonic-com:device:p00RemoteController:1'),
('MX', '1'),
('MAN', '"ssdp:discover"'),
('HOST', '239.255.255.250:1900'),
)
p = self._make_packet(header, fields)
dev=indigo.devices["MatsOfficeTVControl"]
location = "http://%s:55000/nrc/ddd.xml" % dev.pluginProps["address"]
return location
def _make_packet(self, header, fields):
return '\r\n'.join([header] + [': '.join(pair) for pair in fields]) + '\r\n'
The code works as is, but i need to change the dev=indigo.devices["MatsOfficeTVControl"] to dev=indigo.devices[devId] but this throws an error as the object has no attribute. I understand that, as I've not introduced it to the second module. And there I am stuck!
I didnt write the second module and whilst I can see generally whats going on and I have it working as above, it needs work with multiple devices.
What is frustrating me is how to get the dev.Id into the second module and where. Just getting frustrated....
Thanks for any help, or perhaps an answer at this time of night.