Creating a "virtual" sensor to use with Tasker

Hey everbody, i’ve recently switched to HA, coming from Domoticz.
I’m running a wall tablet with Tasker which was using the Domoticz API to update a so called virtual sensor with the current battery percent.
Now I’m trying to realise this case with HA and have found out about the REST API which is working quite well, but an existing device is needed which van be updated.
How do I create such a device?

I know, I should use MQTT, but I’m struggling with the configuration.

Best regards

if you can use MQTT, then it’s “fairly” easy:

  1. Add MQTT Broker to your config (Doc)
  2. Create a sensor to read some status from the MQTT topic (Doc)
  3. Add the sensor to one of your views/groups to be displayed on your dashboard (Doc)

Let me know if you need help.

Not necessarily. If it doesn’t exist when you do the post, the documentation seems to suggest that it will create an entity for you. I haven’t tried it with the restful api, but it does work with appdaemon.

The return code is 200 if the entity existed, 201 if the state of a new entity was set. A location header will be returned with the URL of the new resource. The response body will contain a JSON encoded State object.

Correct, though through my experience, the downside in not creating a sensor is that you can’t customise it (like its friendly name or its icon) as it won’t exist when HA is loading and applying customisations.
This is why I’d personally create a sensor that reads the data off the MQTT topic. You don’t have to display it if you don’t want to and you can still use it in your automations

I recently experimented with using Zanzito to send light sensor data back to HA. You’ll have to get MQTT working on HA (get your broker set up) then point Zanzito at it. Zanzito can use any sensor on your Android device (so you could use it as a motion sensor in addition to getting battery status).

I have been trying to get my heart rate into HA for awhile now with zanzito. I can pass messages between ha and my phone no problem. I get my battery in ok. I am new to tasker though from what I read is %HEART is the variable but all I get in HA is “%HEART” its not converting it to the actual heart rate. Any idea what I can look at?

Make sure you can see %HEART in a task (for example, toast it) first to make sure it’s even being valued. Your device has to have a built-in heart sensor for that to work.

thanks, im missing something in tasker. im going to have to play with it some more i guess. Cause i know nothin about toast lol:)

its a s9+ and i have a gear watch so it takes my heart rate every hour i think. I wanted to track it, it would be very beneficial for me.

I dont know if I even have the state/event setup right. I had it on state and just put if my heart was inside a certain parameter, but im really looking for a way to tell tasker to take my heart rate on the hour every hour. I would have a very consistant chart. Ill check up on toast, if you have any ideas i would appreciate any direction
!

A toast is a standard Android notification. When you see a message at the bottom of your screen in a grey box.

When you’re debugging Tasker, it’s handy to display stuff in a Toast to see if you’ve got the data you expect.