Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible problem with spaces in friendly_name #9

Open
dersimn opened this issue Aug 19, 2017 · 3 comments
Open

Possible problem with spaces in friendly_name #9

dersimn opened this issue Aug 19, 2017 · 3 comments
Assignees
Labels

Comments

@dersimn
Copy link

dersimn commented Aug 19, 2017

Only one of my devices is available via MQTT.
This might be due to a space in one of the Chromecast's friendly name Simon's Zimmer:

INFO:event:added device Simon's Zimmer
ERROR:mqtt:value conversion error
Traceback (most recent call last):
  File "/Users/simon/Applications/Chromecast-MQTT-Connector/handler/properties.py", line 114, in _write
    self.mqtt.send_message(formatted_topic, value)
AttributeError: 'NoneType' object has no attribute 'send_message'

I've no idea what's wrong with line 114, but Python isn't my best language, either.

Full debug output (I deleted the ID values Chromecast-Audio-AAA._googlecast._tcp.local., because I don't know if my devices can be globally accessed knowing this value or something):

Seim:Chromecast-MQTT-Connector simon$ python3 connector.py 
DEBUG:__main__:~ reading config
INFO:config:config file path: /Users/simon/Applications/Chromecast-MQTT-Connector/config.ini
INFO:config:config file has been found
DEBUG:__main__:~ connecting to mqtt
DEBUG:__main__:~ starting chromecast discovery
DEBUG:discovery:starting discovery
DEBUG:__main__:~ initialization finished
INFO:discovery:adding chromecast with name "Chromecast-Audio-AAA._googlecast._tcp.local."
INFO:discovery:chromecast device name "Simon's Zimmer"
INFO:discovery:adding chromecast with name "Chromecast-Audio-BBB._googlecast._tcp.local."
INFO:discovery:chromecast device name "Wohnzimmer"
INFO:discovery:adding chromecast with name "Google-Cast-Group-CCC._googlecast._tcp.local."
INFO:discovery:chromecast device name "(All Speakers)"
INFO:event:added device Simon's Zimmer
ERROR:mqtt:value conversion error
Traceback (most recent call last):
  File "/Users/simon/Applications/Chromecast-MQTT-Connector/handler/properties.py", line 114, in _write
    self.mqtt.send_message(formatted_topic, value)
AttributeError: 'NoneType' object has no attribute 'send_message'
INFO:event:added device Wohnzimmer
ERROR:mqtt:value conversion error
Traceback (most recent call last):
  File "/Users/simon/Applications/Chromecast-MQTT-Connector/handler/properties.py", line 114, in _write
    self.mqtt.send_message(formatted_topic, value)
AttributeError: 'NoneType' object has no attribute 'send_message'
DEBUG:mqtt:connected to mqtt with result code 0
DEBUG:event:mqtt connected callback has been invoked
DEBUG:mqtt:subscribing to topic chromecast/+/command/volume_level
DEBUG:mqtt:subscribing to topic chromecast/+/command/volume_muted
DEBUG:mqtt:subscribing to topic chromecast/+/command/player_position
DEBUG:mqtt:subscribing to topic chromecast/+/command/player_state
DEBUG:event:mqtt topics have been subscribed
INFO:event:added device (All Speakers)
ERROR:mqtt:value conversion error
Traceback (most recent call last):
  File "/Users/simon/Applications/Chromecast-MQTT-Connector/handler/properties.py", line 114, in _write
    self.mqtt.send_message(formatted_topic, value)
AttributeError: 'NoneType' object has no attribute 'send_message'
INFO:discovery:adding chromecast with name "Chromecast-Audio-DDD._googlecast._tcp.local."
INFO:discovery:chromecast device name "Badezimmer"
INFO:event:added device Badezimmer
DEBUG:mqtt:sending topic chromecast/Badezimmer/connection_status with value "WAITING"
INFO:pychromecast:Querying device status
INFO:pychromecast:Querying device status
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 10.1.1.133
DEBUG:urllib3.connectionpool:Starting new HTTP connection (2): 10.1.1.133
INFO:pychromecast:Querying device status
DEBUG:urllib3.connectionpool:Starting new HTTP connection (3): 10.1.1.133
DEBUG:urllib3.connectionpool:http://10.1.1.133:8008 "GET /ssdp/device-desc.xml HTTP/1.1" 200 1086
DEBUG:urllib3.connectionpool:http://10.1.1.133:8008 "GET /ssdp/device-desc.xml HTTP/1.1" 200 1086
DEBUG:urllib3.connectionpool:http://10.1.1.133:8008 "GET /ssdp/device-desc.xml HTTP/1.1" 200 1086
DEBUG:pychromecast.controllers:Receiver:Updating status
DEBUG:root:Thread started...
INFO:pychromecast:Querying device status
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 10.1.1.30
DEBUG:urllib3.connectionpool:http://10.1.1.30:8008 "GET /ssdp/device-desc.xml HTTP/1.1" 200 1077
DEBUG:pychromecast.controllers:Receiver:Updating status
DEBUG:root:Thread started...
INFO:pychromecast:Querying device status
DEBUG:urllib3.connectionpool:http://10.1.1.30:8008 "GET /ssdp/device-desc.xml HTTP/1.1" 200 1077
DEBUG:pychromecast.controllers:Receiver:Updating status
DEBUG:root:Thread started...
INFO:pychromecast:Querying device status
DEBUG:urllib3.connectionpool:http://10.1.1.30:8008 "GET /ssdp/device-desc.xml HTTP/1.1" 200 1077
INFO:pychromecast:Querying device status
@nohum nohum added the bug label Aug 20, 2017
@nohum nohum self-assigned this Aug 20, 2017
@nohum
Copy link
Owner

nohum commented Aug 20, 2017

Hi!

Interesting error. As all of my chromecast devices have spaces in their names (e.g. Living Room Audio) I do not believe that this is the issue.

According to the log the mqtt property seems not to be a valid MQTT object. On second view of the logfile, this is also visible (compare the order of the messages connecting to mqtt, the errors and the final mqtt connected callback has been invoked message).

Seems to be a race-condition of some kind when the MQTT connection is not established fast enough yet devices already have been found.

Edit:
You can verify this by starting a "dummy mqtt server" with netcat, e.g nc -k -l 1883. This will never successfully connect, so this error will even happen with your device called Badezimmer.

@nohum
Copy link
Owner

nohum commented Aug 20, 2017

You can try the version available in PR #11.

@dersimn
Copy link
Author

dersimn commented Aug 23, 2017

Before you made any changes only the Badezimmer (≙ Bathroom) topics showed up in MQTT - nothing else.

With the #9 branch however:

Here everything starts to work in the end, the 'workflow' to get everything working is as bit struggling:

  1. Connection status is WAITING for all devices (but they appear right after starting the script)
  2. Connection status changes to CONNECTED for Badezimmer and at the same time every topic (like volume_level) gets populated. All other devices remain on WAITING
  3. Using Spotify on my iPhone, I make a change to the current player state (from Playing to Pause, or vice versa)
  4. All /media/ topics get populated for e.g. the Simon's Zimmer speakers, leaving the connection_status still on WAITING.
  5. If you now change the volume on the iPhone, the connection_status will be set to CONNECTED and all other topics (like the volume_level) appear in MQTT right after that.

So basically once every device was in use and somebody changed the volume, they'll appear in MQTT.

What I haven't thought about until now: The Bathroom speakers are the only one's connected via WiFi. For the other two, I'm using the Ethernet Adapter. I'll try to connect one of them with WiFi as well, tomorrow.

rickynils pushed a commit to rickynils/chromecast-mqtt-smarthome-connector that referenced this issue Feb 3, 2019
rickynils pushed a commit to rickynils/chromecast-mqtt-smarthome-connector that referenced this issue Aug 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants