chromecast-mqtt-connector
chromecast-mqtt-connector copied to clipboard
Possible problem with spaces in friendly_name
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
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
.
You can try the version available in PR #11.
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:
- Connection status is
WAITING
for all devices (but they appear right after starting the script) - Connection status changes to
CONNECTED
for Badezimmer and at the same time every topic (likevolume_level
) gets populated. All other devices remain onWAITING
- Using Spotify on my iPhone, I make a change to the current player state (from Playing to Pause, or vice versa)
- All
/media/
topics get populated for e.g. theSimon's Zimmer
speakers, leaving theconnection_status
still onWAITING
. - If you now change the volume on the iPhone, the
connection_status
will be set toCONNECTED
and all other topics (like thevolume_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.