mhrivnak / radiotherm

python client library for Radio Thermostat wifi-enabled home thermostats
BSD 3-Clause "New" or "Revised" License
49 stars 40 forks source link

Multiple thermostats #5

Open toddeye opened 9 years ago

toddeye commented 9 years ago

Hi, Was wondering in discovery why you check for the case where you get > 1 thermostats but only return the first? Why not just return the thermostats as a list?

if len(thermostats) > 1:
            raise IOError("Found %d thermostats and I don't know which to pick." % len(thermostats))
        return thermostats[0]

Thanks for the library.

Todd

mhrivnak commented 9 years ago

I think this was only because there wasn't a good way (or maybe any way) to help the user determine which thermostat is which. The expectation is that the user will have a known hostname or IP address for each thermostat. Otherwise, how do you know which one you're interacting with?

Perhaps if each is a different model, that would give you a way to tell them apart. Seems like an edge case though.

Ideas are welcome. If you want to implement multiple-thermostat discovery, that's fine with me as long as we have a clear user story.

toddeye commented 9 years ago

discovery could query the name of the thermostat(s) and return the name, model etc, but personally I think the calling application should be responsible for associating the IP(s) with the location of an individual thermostat.

for index, tstat_host in enumerate(radiotherm.discover.discover_address()):
    tstats.append(radiotherm.get_thermostat(tstat_host))
    print(tstats[index].name)     
{'raw': 'upstairs'}
{'raw': 'downstairs'}

What do you think?