Create a device tracker - gravatar

Hi,
I am trying to improve my presence detection and thought I would play around with the Bayesian binary sensor. I am doing something similar to this post

but instead of node-red i am using app-daemon. I have the baysien working fine but it creates a binary sensor, I am using appdaemon to convert that to a device tracker. From a state perspective it works great but I want the gravatar to appear on the new device tracker i create from the binary switch the Bayesian sensor creates

I have the following in appdaemon

class PresenceTracker(hass.Hass):

    def initialize(self):
        # Subscribe to sensors
        self.listen_state(self.state_change_detected, self.args["binary_sensor"])

    def state_change_detected(self, entity, attribute, old, new, kwargs):
        if new == "on":
            # Person is home so set device tracker to home
            self.set_state(self.args["device_tracker"], state = "home", attributes = {"friendly_name": self.args["friendly_name"],"gravatar": self.args["gravatar"],"picture": self.args["gravatar"],"entity_picture":self.args["gravatar"] })

        elif new == "off":
            # Person is not home so set device tracker to away
            self.set_state(self.args["device_tracker"], state = "not_home", attributes = {"friendly_name": self.args["friendly_name"],"gravatar": self.args["gravatar"],"picture": self.args["gravatar"],"entity_picture":self.args["gravatar"] })

the app.yaml is

presencetracker:
  module: set_presence_tracker
  class: PresenceTracker
  binary_sensor: input_boolean.automation_test_sensor #<for testing will using binary sensor once working>
  device_tracker: device_tracker.binary
  friendly_name: "Scott"
  gravatar: "https://www.gravatar.com/avatar/XXXXXXXX.jpg?s=80&d=wavatar"

the gravatar arg is a valid gravatar url that displays when i use the owntracks gravatar sensor by enering the email in the knowndevices.yaml. I have also tried the email address associated with this and it doesn’t work. It works in knowndevices.yaml

the trouble is that set_state is working but not really dependable when it comes to other devices then sensors.
thats not a problem that can be tackled in AD, its a HA problem.

so allthough the devicetracker is created, it still works as a sensor.

i did learn something a short while ago.
some entities have a bitfield
to get another entity to work better we need to set supported_features as attribute.
but i cant find that for devicetracker, so i guess that isnt there (yet)

did you check in the attributes from the devicetracker (when its set in the knowndevices) if they did really name it gravatar? because in the code i only see picture

maybe you also could find out more when you add a device to knowndevices and then use listen event to see if you get more info about how it normally works.

Did what you said and looked at the response from the get_state function. was able to get the item to add the Gravatar using the Entity_picture attribute and the full gravatar url and it worked

1 Like