Cannot delete a sensor

In line 111 where is

        playlist_type = "user"
        locale = "en"
        limit = 10
        account = None

Can i change also the locale?

I believe what you have screenshotted there is the github README, not the release notes. And it appears you are correct that this sensor is not documented there. An oversight Iā€™m sure. A perfect opportunity to do a quick PR and help him out! :wink:

I promise you this sensor is being created by Spotcast. This is the file that does this.

Snippet from sensor.py
class ChromecastPlaylistSensor(SensorEntity):
    def __init__(self, hass: ha_core, country=None):
        self.hass = hass
        self._state = STATE_UNKNOWN
        self.country = country
        self._attributes = {"playlists": [], "last_update": None}
        _LOGGER.debug("initiating playlist sensor")

    @property
    def name(self):
        return "Playlists sensor"

    @property
    def state(self):
        return self._state

    @property
    def extra_state_attributes(self):
        """Return the state attributes."""
        return self._attributes

    def update(self):
        _LOGGER.debug("Getting playlists")

        if self.country is not None:
            country_code = self.country
        else:
            # kept the country code to SE if not provided by the user for retrocompatibility
            country_code = "SE"

        playlist_type = "user"
        locale = "en"
        limit = 10
        account = None

        resp = self.hass.data[DOMAIN]["controller"].get_playlists(
            account, playlist_type, country_code, locale, limit
        )
        self._attributes["playlists"] = [{ "uri": x['uri'], "name": x['name']} for x in resp['items'] ]

        self._attributes["last_update"] = dt.now().isoformat("T")
        self._state = STATE_OK

In that file you can change limit = 10 to a reasonable number and you will get more playlists in the sensor.

Ah I see you already found it.

I havenā€™t looked to see where that comes from or how itā€™s used.
Give it a shot. Worst that can happen is it wonā€™t workā€¦

Ok, thanksā€¦ butā€¦ which is the real use of that sensor? How do you use it?

I load the playlist names into an input_select (which Iā€™ll probably eventually update to use the new template select ). Then when spotcast.start is called it grabs the URI to use by matching it to the playlist that is selected in the input_select.

Hereā€™s the automations where I populate the input_select. (It also stores the selection and recalls it after the list has been reloaded).

Hereā€™s the script where I call spotcast.

PS Donā€™t judge the playlists. Those are mostly my wifeā€™s showing :crazy_face:

Thanks a lot, iā€™ll study it and make usable on my environmentā€¦

1 Like

Riiiiiiiiiiiight :rofl::joy::rofl:

Hmm. Iā€™m feeling a little judged! :yum:

Oh no, i am not so expertā€¦ i like to study to improveā€¦

I think you misunderstood. petro was laughing at me for denying the playlists in my screenshot were my personal preferences. My wife is a fan of country music, I shall we say - am not.

If you need help figuring out those automations ask away, happy to help you out.

1 Like

Yes, I was laughing at the playlist

Thanks, just a question:
How you set the input_select?

same way you set any other input_select, with the select_option service or through the dropdown.

Ok, but as options i must put all the playlists or not?

He posted the automation that updates the input_select

Yes, itā€™s in the automation I posted. Keep in mind in that automation Iā€™m also populating a bunch of additional input_selects in my automation (I have several playlist "presets " for different things).

Your service call to populate the input_select will look something like this which loops through all the playlist names and puts them in the input select.

- service: input_select.set_options
  target:
    entity_id: input_select.spotify_playlist
  data:
    options: >
      {% set options = namespace(value=[]) %}
      {% for item in playlists -%}
        {% set options.value = options.value + [item.name] %}
      {% endfor %}
      {{ options.value }}

Not sure if this was resolved or figured out, but under Developer Tools/STATISTICS is where I deleted mine from, and now I no longer have the unwanted sensors I created. If this was resolved, please ignore.

I have the same issue, last night my DB crashed so Ive started all from scratch as i had some very outdated full backup that was unusefull.

Today ive created sensor for enerty monthy discount in templates.yaml, after that i renamed its unique_ID, but its appearing in Developer> states, so i deleted that sensor from templates.yaml the only place ive coded it, after deletion its still here, nor restart nor hard restart helped. Ive created second sensor with same unique_id and now newly created sesoor has the suffix _2 ,ā€¦

I can see that ā€œoldā€ changed/ deleted sensors have key:value restored: true, note that this ā€œphantomā€ sensors are not used anywhere else still as everything is from scratch as i said. No appearance in any config/template/automation YAMLsā€¦ So it stores is somewhere even its not used in UI, or anywhere else