Maker API and Virtual Omni Sensor

I'm trying to send my phone's battery percentage to Hubitat. The main reason is that I want to alert myself when I wake up if the battery is below a threshold, indicating my phone didn't charge overnight so that I can charge it while I get ready and/or on my way to work.

I set up a virtual device using the Virtual Omni Sensor Plus. I plan to send HTTP requests from Tasker with my current battery level, but I can't seem to get the command right. For troubleshooting I'm just sending the command from my browser.

I thought one of these would work, but they don't.{hidden}{hidden}{hidden}{hidden}

I can get it to acknowledge charging/not charging using the commands below, so I know the connection is working, I just can't figure out the specific command to set my battery level.{hidden}{hidden}

If anyone knows what I'm doing wrong I'd love to hear it.

Thanks in advance,

Only the above format should work, IF you have a command setBattery in your device. Always good to pull the commands before you send a value to make sure the command exists:

Get commands:

To send a command with secondary value:


Thanks @bobbyD.

I tried this:

and received this response:


So the command is there, still this did not work.{hidden}

When I try the above, I get this response. The "battery" "currentValue" isn't updated in the response.

{"id":"606","name":"Mobile Battery","label":"Mobile Battery","type":"Virtual Omni Sensor Plus - Phone","attributes":[{"name":"battery","currentValue":50,"dataType":"NUMBER"},{"name":"variable","currentValue":null,"dataType":"STRING"},{"name":"batteryStatus","currentValue":"charging","dataType":"STRING"},{"name":"batteryLastUpdated","currentValue":"2022/07/19 11:15:07","dataType":"DATE"}],"capabilities":["Battery",{"attributes":[{"name":"battery","dataType":null}]}],"commands":["batteryStatusCharging","batteryStatusDischarging","batteryStatusIdle","setBattery"]}

Any other thoughts?

Have you tested the driver from Device Details that setBattery is actually functional?

I think this is what you are asking. I have put in a value in setBattery and clicked the button and the battery value updates there.

1 Like

I am not aware of any restrictions for custom commands, the ones I run all work. With that being said, not all commands are honored. Will set a driver with a setBattery command to see what I get:™_Maker_API

Quick follow-up. I have no problem using setBattery command. Likely your issue is with the driver. Use this virtual battery driver I created to see if this works.

1 Like

Thanks @bobbyD! That works for me.

I have a little coding experience, so I'm excited to have a very simple app to work with and try to expand on with other features. I appreciate your help!

1 Like

Here's another variant of that virtual driver... useful if you're looking to grow your groovy knowledge:

A lot of virtual drivers have been coded over the years that interlock two dissimilar virtual devices. I remember one of the first I wrote was for a Presence + Switch. The driver above takes that concept up 10x.

For real Sensors (Door/Window, Leak, Presence, etc.) you cannot set them. The device itself does the setting.. for example, you have a door sensor and the door is open, You can't click on a button and have that door change to closed. You have to physically walk over and close the door, But for virtual devices, there's no physical to move. Thus a switch is interlocked to the sensor. You change the virtual switch and it changes the virtual Sensor too.


This is great, thanks. I'm excited to dive in!

1 Like