NameError: name 'media_player' is not defined

I am running Appdaemon in Docker and cant figure out what I am doing wrong for playing media via my Google home :frowning:

This is what I am trying to run:

import appdaemon.plugins.hass.hassapi as hass

class TestToSpeach(hass.Hass):
    
    def initialize(self):
        self.handle = None
        self.warned = None
        self.log("Initializing Text To Speech")
        self.log("Movement Sensor is {}".format(self.args["binary_sensor"]))
        self.listen_state(self.say_somthing, self.args["binary_sensor"], new="on")

    def say_somthing(self, entity, attribute, old, new, kwargs):
        self.log("Callback triggered")  #{}".format(self.args["TTSVolume"]))
        self.log(self.get_state(self.args["player"]))
        self.log(self.get_state(self.args["player"], attribute="media_content_id"))
        self.log(self.get_state(self.args["player"], attribute="media_position"))
        self.call_service("media_player/turn_on", entity_id = self.args["player"])
        self.call_service("media_player/media_play", entity_id = media_player.googlehome, media_content_id = "https://archive.org/download/testmp3testfile/mpthreetest.mp3")

Ok, so looks like I had the wrong entity_id :joy:

1 Like