Playing around like this. I am going to try and make a card that “looks” like a card. YOu can get alot of the verbage if you can to some of those links. Fun project.
I implemented a “pokeball” button in this, clicking it will grab a new one. Although the images sometimes lag or do not exist, I will need to examine that.
This uses stack-in and mushroom cards though, so be sure if you copy this that you have these installed. Otherwise you can just use built-in Button and Markdown and Vertical stacking or Grid.
Actually changing the picture card to picture-entity card seems much better as it auto updates the card when the entity updates:
If not, you would get an error.
I would also note that I found a few times I did not get an image, possibly that second URL does not have SVG images for all Pokemon (or the ones 1 through 1000 which is what I have in the random sensor),
Yeah, I have all those installed and I can get everything except the photo. My husband says that it may have something to do with /dream-world/ being part of the url since not all Pokémon are in there, but there’s got to be a list of photos somewhere?
Beware that the grabbing of super-nice, large SVG sprites (versus the small images in through pokeapi) I would only find 1 - 649. You can also shorten the update by downloading the whole collection local from here:
If someone knows a source for all 1008 in HQ SVG format, that would be great to know.
I can confirm the best thing is to download the images locally and remove the call. It now is super fast. However, you only have id’s #1 - #649 in the set I found so anything above #650 displays no image.
OK. Based on some “poking” around the data. It looks like all the images could be just grabbed from the actual data. The sensor attribute is “sprites” and the path below is other.official-artwork.front_default as in:
My husband was super excited about this card! He asked if I would be able to include the game/generation where the pokemon was first introduced as well so that is what I am working on now.
Looking really fun! Not sure about that border. I do not have that “keep” section in stack-in looks to be the only difference.
By the way, I changed the stats part to report them like units …
subtitle: >
National No: {{state_attr('sensor.random_pokemon','id') }}, Height:
{{state_attr('sensor.random_pokemon','height')/10}} m, Weight:
{{state_attr('sensor.random_pokemon','weight')/10 }} kg
As for gave/generation … I am not a Pokemon person, I just thought the project sounded fun and thought I could help everyone get to the data. I am sure it is either there or in alternate links that are in the main one.
Love it! That seems easier than having them as chips. I was just trying to think of what a pokemon card looked like from memory (apparently I forgot I could just google it!)
By the way, I downloaded all those PNGs and I store them locally. I do this for many things but to be honest I have a super-slow internet as I live in the middle of nowhere. So I do this:
And since the entire collection of PNGs is on my HA server, it is super fast for the image. If I run my “Grab a Pokemon”, I have everything in about 0.5 seconds
I would also like to do this for the types, abilities and maybe moves, but I am struggling to get the example you provided working in the attributes of the sensor, are you able to elaborate a little?
Well, you do not use that in the attributes of a sensor (unless you actually want to create a new sensor). Since that information is already in the master sensor, you can get it into “something”.
Now that “something” depends on how you want it to display in the GUI. Let’s say you wanted that information in a simple Markdown Card. You could do this:
type: markdown
content: |-
## Types
{% for tp in state_attr("sensor.random_pokemon","types") -%}
{{ tp.type.name }}
{% endfor %}
## Abilities
{% for ab in state_attr("sensor.random_pokemon","abilities") -%}
{{ ab.ability.name }}
{% endfor %}
## Moves
{% for mv in state_attr("sensor.random_pokemon","moves") -%}
{{ mv.move.name }}
{% endfor %}
To everyone following this, I noticed an error in the original sensor. I had typed “states” as one of the attributes. It is “stats” and should be like this:
json_attributes:
- abilities
- base_experience
- forms
- game_indicies
- height
- held_items
- id
- is_default
- location_area_encounters
- moves
- name
- order
- past_types
- species
- sprites
- stats
- types
- weight
I noticed this in trying to get the Stats like HP, Attack, etc. Change that sensor to use “stats” and now I get the info:
Right now, that card is this (note that it is st.stat.name but it is only st.base_stat ):
type: markdown
content: |-
## Types
{% for tp in state_attr("sensor.random_pokemon","types") -%}
{{ tp.type.name }}
{% endfor %}
## Abilities
{% for ab in state_attr("sensor.random_pokemon","abilities") -%}
{{ ab.ability.name }}
{% endfor %}
## Stats
{% for st in state_attr("sensor.random_pokemon","stats") -%}
{{ st.stat.name }} {{ st.base_stat }}
{% endfor %}
## Moves
{% for mv in state_attr("sensor.random_pokemon","moves") -%}
{{ mv.move.name }}
{% endfor %}
BUT. I just posted to the Apex chart gurus because I want to move the stats into a small chart, like is done on Pokedex. Ideally I would like something like this: