Error running example.py
Closed this issue · 1 comments
I'm just starting to play around with the library, and am running into an error simply trying to run example.py. I have Intiface Central running (macOS), I can see the device (Lovense Ambi) and control it inside Intiface Central, and Intiface Central is running with WebSockets -and- shows that example.py does connect (as Test Client).
But it throws this error:
INFO:Test Client.websocket_connector:Connected to ws://127.0.0.1:12345
ERROR:root:Could not connect to server, exiting: 'DeviceMessageAttributes' object has no attribute 'get'
Any idea what might be up with that? Thanks!
client.py
seems to find the device find when calling v3.RequestDeviceList()
:
[Device(device_name='Lovense Ambi', device_index=0, device_messages={'ScalarCmd': [DeviceMessageAttributes(feature_descriptor='N/A', step_count=20, actuator_type='Vibrate', sensor_type=None, sensor_range=None, endpoint=None)], 'SensorReadCmd': [DeviceMessageAttributes(feature_descriptor='Battery Level', step_count=None, actuator_type=None, sensor_type='Battery', sensor_range=[(0, 100)], endpoint=None)], 'StopDeviceCmd': []}, device_message_gap=None, device_display_name=None)]
It appears the error is in this code:
# Actuators
for i, attributes in enumerate(messages.pop(v3.ScalarCmd.__name__, [])):
self._actuators.append(
ScalarActuator(
self,
i,
attributes.get('FeatureDescriptor'),
attributes.get('ActuatorType'),
attributes.get('StepCount'),
)
)
And there are two issues -- one is that the attribute is step_count
(and not StepCount
) and the other is that you have to use getattr(attributes, 'step_count')
or just attributes.step_count
:
DeviceMessageAttributes(feature_descriptor='N/A', step_count=20, actuator_type='Vibrate', sensor_type=None, sensor_range=None, endpoint=None)
As defined:
class DeviceMessageAttributes(Field):
feature_descriptor: str = None
step_count: int = None
actuator_type: str = None
sensor_type: str = None
sensor_range: list[tuple[int, int]] = None
endpoint: list[str] = None