maddox / harmony-api

🗼 A simple server allowing you to query/control multiple local Harmony Home Hubs over HTTP or MQTT
MIT License
393 stars 115 forks source link

Sending multiple POST commands #77

Closed librien closed 6 years ago

librien commented 6 years ago

I understand this isn't the forum for technical support, but I am having trouble with sending multiple sequenced commands to my hub, and am not sure where the problem is.

I wrote a script to turn on an activity and then change the channel on my STB. If the activity is already on, the script works and it will change the channel successfully. If the harmony hub is off, or is set to a different activity, and the script needs to turn on, or change activities, and then send the commands to change channel, it will not work.

The first part works, it turns on / changes activity. I added a delay to the commands to change the channel in case that was the problem, this didn't change anything. When I send the commands, I do receive Response [200], so I know harmony-api is receiving the commands. It just looks like it is not relaying them properly? If I then run the script again after the hub / activity is on, it changes the channel correctly. Is there something I need to do to break the connection and resend the commands?

maddox commented 6 years ago

harmony-api doesn't have any kind of queue. So when you send those commands back to back, they're being relayed immediately (asynchronously) to the harmony hub. That's probably where the problem lies.

I know it's not great, but try adding some time between requests.

librien commented 6 years ago

Thank you so much for the prompt response. I'm fine with adding a delay, I'm using python so I've added time.sleep(10) in between when the activity turns on and when I send the commands. I'll try to mess around with the time, maybe even a check for when the activity status changes. If that doesn't work I'll look at mosquito. Thanks again for the response!