Then this needs to go in as a Feature Request. Pretty sure I saw another one requesting this already somewhere on the forum, so search around before creating a new one please.
Difference between what I inquired about on this post was the s/n was part of the entity_id. Now I need to add attribute to something that does not have entity_id or entity. I am basically looking to create something from a data value. I been looking in forums and google and not seeing any good pointers. Can you reference me something to go by?
Nevermind, It was your own post I read, on a different topic, and where you were already told to raise a Feature request.
If it helps, there’s already a generic feature request to show the Serial Id for devices. I suggest you vote there since you’ll have greater odds of this being voted for due to its generic nature.
so no way of creating a manual entity. I guess I was lucky with the other one and it could be manipulated with the template since the s/n was part of entity_id. oh well, win some and lose some.
That’s one of the functions of using a template sensor. It allows you to manual create an entity from somewhere else. There are other entities that can be manually created depending on what you’re trying to do.
Easiest way to create any attributes/notes/whatever for your devices is to use the customize.yaml file. You can then use it in a card just like petro showed you how in the linked post.
Here is an entire FR thread asking for generic notes. The second post shows you exactly what you need to add in customize.yaml.
Just set it up once & forget it.
I been reading about the customize.yaml over last day or two, but when Google is giving me mixed bag of results with some posts several years old I hesitated, but thanks for the link
Don’t be afraid, it’s quite easy to use. Ping me here if you get stuck & I’ll do my best to help you with it.
How does this look? Getting the impression I may also need to use configuration.yaml unless I am not understanding correctly.
sensor:
- platform: template
sensors:
sensor.sony_kd_55x750f_modelname:
friendly_name: "Model Name"
value_template: "KD-55X750F"
sensor.sony_kd_55x750f_serialnumber:
friendly_name: "Serial Number"
value_template: "123456"
You need to add the serial in customize.yaml and reference the file in configuration.yaml first if you’re splitting up your config.
Otherwise just add everything in configuration.yaml under your existing homeassistant
lineand forget about customize.yaml, like this.
homeassistant:
customize:
sensor.whatever:
serial: "12345"
Remember to reload location & customisations from the dev tools page in order for the change to apply.
I want to use customize.yaml alone. No errors, but nothing created. Can you tell me what I am doing wrong?
I am referencing the customize.yaml file in the configuration.yaml
sensor.sony_kd_55x750f_serialno:
friendly_name: "Serial No"
value_template: "123456"
Ok, let’s take it step by step.
Paste your customize.yaml here, and paste the section in the configuration.yaml (including the homeassistant
line) where you’re referencing it
ok so what I pasted from last post is in the customize.yaml. The file did not exist so I created it. So nothing else in that file except what you see from my last post.
configuration.yaml
homeassistant:
packages: !include_dir_named packages
customize: !include customize.yaml
name: Home
latitude: 42.230830
longitude: -70.933590
# Loads default set of integrations. Do not remove.
default_config:
# Load frontend themes from the themes folder
frontend:
themes: !include_dir_merge_named themes
# Text to speech
tts:
- platform: google_translate
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
sensor: !include sensors.yaml
shell_command:
backup_script: "/bin/sh -c 'ha core stop && ha backups new --name \"Automated backup $(date +%Y-%m-%d)\" && ha core start'"
Ok, but sensor.sony_kd_55x750f_serialno
doesn’t actually exist as an entity, right?
You need to use an entity which already exists in order to add an attribute to it, so your customize should look something like this:
sensor.sony_kd_55x750f:
serial: "123456"
You’re also indented too far to the right for friendly_name
and value_template
. While it may not break anything, those lines should be only 2 spaces in instead of 4
correct. they don’t exist as an entity. was hoping to create a “fake one”. this does exist media_player.sony_kdl_40w600b. Can I add an attribute to this to accomplish what I want x 2 so I can display the model and s/n on dashboard
Looks like a different device from your first one based on the model number, but sure, give that a try.
Remember to reload customisations after your change
so the attribute was created with value I define. sorry if this is obvious, but how would I then reference the attribute on any card?
I’m not really great with templates, but I believe petro already showed you how to display attributes in the dashboard on the other thread.
Something like:
{{ device_attr('sensor.cyberpower_status', 'manufacturer') }}
{{ device_attr('sensor.cyberpower_status', 'model') }}
You can use the entities card. Just make sure the entity and attribute values are correct. The attribute name should be all lowercase.
- type: entities
entities:
- type: attribute
entity: media_player.sony_kdl_40w600b
attribute: serial_number
name: SN
That I did. And those are the templates.