Command Line Switch Colon and a Space Breaking Commands

I have a fan controller and I am working with the local API. Because the command has “Bond-Token: SecretToken” The configuration throws an error “Error loading /config/configuration.yaml: mapping values are not allowed here”. I can run the command from ssh on home assistant but when I try and add it to the switch it won’t because of the format. I have tried various use of quotation marks hoping that would do something but it didn’t work. Also it does like the colon and space here ‘{“light”: 0}’ Here is the example:

#Bond Fan Controller
- platform: command_line
  switches:
    living_room_fan_light:
      command_on: /usr/bin/curl -H "BOND-Token: SecretToken" -i http://localIP/v2/devices/00000041/actions/TurnLightOn -X PUT -d '{"light": 1}'
      command_off: /usr/bin/curl -H "BOND-Token: SecretToken" -i http://localIP/v2/devices/00000041/actions/TurnLightOff -X PUT -d '{"light": 0}'

Any way around this?

Try escaping the : ie

 \:

I tried but sadly the error stayed the same.

Try enclosing the entire command in single quotes. This works for me.

    livingroom_fan_high:
      command_on: 'curl -H "BOND-Token: xxxxxxxxxxxxxxx" -i http://192.168.x.x/v2/devices/029e4280/commands/66ea8517/tx -X PUT -d {}'
      command_off: 'curl -H "BOND-Token: xxxxxxxxxxxxx" -i http://192.168.x.x/v2/devices/029e4280/commands/0f8f3a9b/tx -X PUT -d {}'
1 Like

That was it! I had to omit the ““light”: 0” part from between the curly brackets but it is working so I am going with it. Thanks for your time and consideration!

Sadly omitting the light: 1 or 0 keeps it from letting the on button only turn it on and the off button only turning it off. It’s still better than not working at all but I can’t call on or off in automations as it will just toggle.

You should be able to send those actions without arguments. If you want to keep the state from toggling, check the “Trust tracked state” in the Device Settings screen in the Bond Home app!

1 Like

Thanks Marcio! I eventually got it sorted. I’m the same guy here https://forum.bondhome.io/t/home-assistant-two-fans-in-production/955.

1 Like