joshjcarrier / homeassistant-litter-robot

The litter-robot component offers integration with the Litter-Robot WiFi enabled devices to Home Assistant.
82 stars 15 forks source link

Error when calling service for multiple litter robots #32

Closed houseofbugs closed 3 years ago

houseofbugs commented 4 years ago

Whenever I call a service call for a specific robot I get this error:

Failed to call service litter_robot/nightlight_turn_on. can only concatenate str (not "mappingproxy") to str

"can only concatenate str (not "mappingproxy") to str" shows for all calls - cycle, reset, nightlight

houseofbugs commented 4 years ago

Log output:

2020-08-01 05:08:11 ERROR (MainThread) [custom_components.litter_robot.litter_robot] [command <N1] Unexpected exception: can only concatenate str (not "mappingproxy") to str
2020-08-01 05:08:12 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.140305688863744] can only concatenate str (not "mappingproxy") to str
Traceback (most recent call last):
  File "/config/custom_components/litter_robot/litter_robot.py", line 79, in async_send_command
    await async_run()
  File "/config/custom_components/litter_robot/litter_robot.py", line 72, in async_run
    await session.post('https://v2.api.whisker.iothings.site/users/' + self._user_id + '/robots/' + robot_id + '/dispatch-commands',
TypeError: can only concatenate str (not "mappingproxy") to str

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 125, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1281, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1316, in _execute_service
    await handler.func(service_call)
  File "/config/custom_components/litter_robot/__init__.py", line 89, in async_nightlight_on_handler
    await litter_robot.async_nightlight_on(call.data or list(litter_robot.robots.keys())[0])
  File "/config/custom_components/litter_robot/litter_robot.py", line 37, in async_nightlight_on
    await self.async_send_command(robot_id, '<N1')
  File "/config/custom_components/litter_robot/litter_robot.py", line 83, in async_send_command
    await async_run()
  File "/config/custom_components/litter_robot/litter_robot.py", line 72, in async_run
    await session.post('https://v2.api.whisker.iothings.site/users/' + self._user_id + '/robots/' + robot_id + '/dispatch-commands',
TypeError: can only concatenate str (not "mappingproxy") to str
joshjcarrier commented 4 years ago

Wow you have more than one robot, nice!

Sorry I'm pretty noob at python, so I'm not good at troubleshooting:

When sending your service call, are you providing the litter robot id? This would be yaml like

litter_robot_id: a00bb111cccca
flyize commented 4 years ago

I'm getting the same error with multiple robots. This is how I've setup the YAML. BTW, I'm super new at this, so there's a good chance I've screwed up here.

litter_robot_office_litter_box_nightlight: friendly_name: "Office Litter Box Night Light" value_template: "{{ is_state('sensor.litter_robot_office_litter_box_nightlight', 'On') }}" icon_template: "mdi:lightbulb" turn_on: service: litter_robot.nightlight_turn_on data: litter_robot_id: f5d27f*****

joshjcarrier commented 4 years ago

I might have fixed reading the litter robot id from the data section, please try updating init.py from this branch and let me know how that works https://github.com/joshjcarrier/homeassistant-litter-robot/tree/fix/services_data

flyize commented 4 years ago

That seems to have fixed it for me!

drkp commented 3 years ago

Can confirm this patch works for me too -- thanks!