rytilahti / python-songpal

Python library for interfacing with Sony's Songpal devices
GNU General Public License v3.0
64 stars 24 forks source link

Home Assistant warnings with SRS-ZR7 #17

Closed pschmitt closed 6 years ago

pschmitt commented 6 years ago

Everything is working fine with both my ZR7s, besides the following warnings:

Got unknowns for Sysinfo: {'bleID': '4ACC54EA'} - please create an issue!
Got unknowns for Sysinfo: {'bleID': '3EDA50EF'} - please create an issue!

... which seems to lead to:

homeassistant.exceptions.HomeAssistantError: Entity id already exists: media_player.office_speaker. Platform songpal does not generate unique IDs
rytilahti commented 6 years ago

At the moment the home assistant platform uses mac address from sysinfo as the unique id, could you please run songpal -dd sysinfo to see what information those speakers are offering so that we can adjust that?

Other than that the bleID being unknown has been fixed by https://github.com/rytilahti/python-songpal/commit/33efa2ea695a134f0495f83eb2b46fa3f5be078b which is also in the new release (available since yesterday).

edit: now reading the error more closely, could it be that those devices report a non-unique macAddr?

rytilahti commented 6 years ago

Any news on this? Maybe the platform should be adapted to use a combination of bleID and mac to avoid it?

pschmitt commented 6 years ago

Running the command you asked me to run leads to an error:


$ python -m songpal.main -dd sysinfo
Setting debug level to 2
Endpoint is required except when with 'discover'!
Traceback (most recent call last):
  File "/usr/lib64/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/pschmitt/dev/iot/sony_avr/python-songpal/songpal/main.py", line 584, in <module>
    cli()
  File "/home/pschmitt/.local/share/virtualenvs/python-songpal-ixVV-Ptk/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/pschmitt/.local/share/virtualenvs/python-songpal-ixVV-Ptk/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/pschmitt/.local/share/virtualenvs/python-songpal-ixVV-Ptk/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/pschmitt/.local/share/virtualenvs/python-songpal-ixVV-Ptk/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/pschmitt/.local/share/virtualenvs/python-songpal-ixVV-Ptk/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/pschmitt/.local/share/virtualenvs/python-songpal-ixVV-Ptk/lib/python3.6/site-packages/click/decorators.py", line 63, in new_func
    % object_type.__name__)
RuntimeError: Managed to invoke callback without a context object of type 'Device' existing```
rytilahti commented 6 years ago

Do you have to either set SONGPAL_ENDPOINT or use --endpoint, as indicated in the output (although that could be made clearer :-).

pschmitt commented 6 years ago

Oh - my bad. I have two of theses speakers so here are debug logs: https://gist.github.com/pschmitt/6c5a5899cf758ad4de673b840d7ca8a2

rytilahti commented 6 years ago

Hmm, that's weird. Both of those have different macAddr values which is being used by homeassistant:

    @property
    def unique_id(self):
        """Return a unique ID."""
        return self._sysinfo.macAddr

so I'm unsure where the error of non-uniqueness comes from :(

rytilahti commented 6 years ago

@pschmitt is this still a problem? If you don't mind, could you create a PR to add a dump_devinfo json (songpal dump_devinfo | json_pp > SRS-ZR7.json) for future reference?

rytilahti commented 6 years ago

Closing for inactivity. Please reopen if this is still an issue, and if you don't mind contributing a devinfo dump, please create a PR for it, thanks!