Maker API and Virtual Devices - Possible bug

Steps to reproduce the issue:

  1. Make sure the Maker API is not configured for debug logging
  2. Add a Virtual Device, in my case a Virtual Shade, but it happens with Virtual Switch as well. I haven't tested others.
  3. Make the device available for the Maker API
  4. On the device page send a command, e.g. Close (the shade)
  5. BUG: The Maker API will not send events related to that device until you...
  6. WORKAROUND: Enable debug logging on the Maker API
  7. The device commands are sent via Maker API
  8. Disable the debug logging
  9. The device continues to work normally through Maker API

I'm not sure if that would be a precondition for the issue but I have 2 instances of Maker API, one for my dashboard and the other one for Node-RED. The issue occurs in the Node-RED one.

I have created 5 virtual devices so far and had the same problem with all of them.

What if you reverse steps 3 and 4? Do the commands come through then? Have you seen any errors in the logs?

I still think you may be right about it being a bug, just questioning the debug log link... I'm thinking Maker API may need an initial state captured for the device attributes.... Just a theory....

Did you select Done in the Maker API app after doing this? If not, but if you did after enabling/disabling debug logging (as you must do for the setting to take effect), that would explain the problem (you also have to do this for the device changes to take effect).

1 Like

I didn't click in "Done", because that was never necessary with regular devices, just adding them to the list and clicking "Update" is enough.
Maybe it is not enabling the logs the "fixes" the issue, but clicking the "Done" button, I always do that after enabling the logs.
I'll try and let you know.

That's probably more likely than my idea, otherwise new attributes would never get picked up.....

It is not enough; it will not create the event subscriptions for the devices unless you select Done. This is why you see the behavior you do.

3 Likes

In the Maker-API dedicated to my dashboard I just need to click "Update", I have about 60 devices and never clicked "Done".
Just tried now to be sure with a new Virtual Shade.
The device appeared automatically in the dashboard and sending a command from there did work.

2023-04-15 14:43:55.673 info Bedroom Window Shades was turned off
2023-04-15 14:43:55.670 info Bedroom Window Shades is closed
2023-04-15 14:43:55.668 info Bedroom Window Shades was set to 0%
2023-04-15 14:43:55.663 info Bedroom Window Shades is closing

Maybe what is executed by the "Done" button could be executed automatically when "Update" is clicked.

Sending a command from an external system will work; an event subscription is not necessary for that. It is necessary to do the POST functionality, where the Maker API app needs to subscribe to the event (so it knows it happens) and then send it off. That is why you see the behavior you described above (and why it is different depending on what behavior you're looking at).

It would be possible for Maker API to work as you propose, but I assume the choice was made not to due to the fact that creating event subscriptions for all selected devices is a relatively "expensive" process that you might only want to do when you're really ready to save your changes. Saving changes is what the Done button does in nearly any app, and it's also what is documented in the steps for making changes in Maker API, though it is not unusual in this regard: https://docs2.hubitat.com/en/apps/maker-api

A while ago, I remember someone saying "if you see a Done button, click it," and it's generally good advice. :slight_smile:

2 Likes

It might be generally good advice, but might not be what is desired in some cases. For example, because Done cancels all Waits, scheduled jobs, etc., and returns to the Apps page, if a Rule is partially executed and is awaiting an elapsed time or a device event, that wait will be cancelled and you will be back at the Apps page. If a Private Boolean or some such has been set as a semaphore to prevent retriggering (for a Required Expression, etc.) while the rule is in progress, the Rule might never trigger again unless the semaphore Private Boolean is manually cleared. Just an example. As long as people understand that Done has multiple side effects, fine.

Yes, that is a good point and is why I didn't say "always" and why I put it the Rule Machine documentation. :slight_smile:

(But along the same lines, if you changed triggers in Rule Machine and need the new event subscriptions, you will have to "Done" or "Update Rule" at some point.)

2 Likes

Iā€™m so terrified of Broken Rules and having to re-create such damaged rules, that I always hit Done after editing a rule, which changing a trigger would cause. But, when just viewing a Rule, I think twice about the effect before hitting Done.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.