Create own entity?

Hi

I’m trying to have the on/off status of my windows pc displayed in Home Assistant, but since I’m using the Steam integration, what I’m getting instead is “Online/Away/Offline” + the icon is my avatar…

So, I was thinking if it was possible for me to create a custom entity that I could automate to set to “On/Off” depending on the input from Steam. And I’m going about it wrong?

Also, I’m new to HA, but really liking it, though the learning curve is (in my case) steep.

thanks!

1 Like

You could create a Template Binary Sensor. I can provide a concrete example if you could tell me the entity_id of the Steam sensor, and exactly what the states are (as shown on the STATES tab of the Developer Tools page.) But it would be something like this:

binary_sensor:
- platform: template
  sensors:
    windows_pc:
      friendly_name: Windows PC
      value_template: "{{ states('sensor.steam1234') in ('online', 'away') }}"

EDIT: Since this post was marked as the solution, I’m editing the value_template to reflect what was discussed below.

how do I find the entity_id? Trying to look under developer tools->states, but is it the entity on the left that gives me the entity_id?

Yes, the left column labeled “Entity” shows the entity_id. The state is in the “State” column. You may have to cause the entity to change states to see all the values of state. (The state shown elsewhere in the UI, even in the “more info” window, is usually a translation, or is often just a different capitalization. This is very important because in automations, states are treated as case sensitive.)

the entity is just sensor.steam + a bunch of numbers. states are online, away and offline. all not capitalized.

so, if I understand it correctly, my binary sensor would be something along the lines of:

binary_sensor:

  • platform: template
    sensors:
    windows_pc: (this is what my binary sensor is called?)
    friendly_name: Windows PC (the above name, just nicer to look at?)
    value_template: “{{ states(‘sensor.steam1234’) in (‘online’, ‘away’) }}”

edit: think I managed to create the entity and find it in automation. However, won’t I need another entity to send the on/off automation to?

Apologise for the tons of questions!

When posting YAML code you need to format correctly:

```
YAML code
```

It would be like this:

binary_sensor:
- platform: template
  sensors:
    windows_pc:
      friendly_name: Windows PC
      value_template: "{{ states('sensor.steam1234') in ('online', 'away') }}"

And, yes, this will create binary_sensor.windows_pc, and “Windows PC” is the “friendly name” which you’ll see in most places in the UI.

Sorry, don’t understand what you’re asking.

I completely understand why you didn’t understand my question - I didn’t understand the background, thus leading to the (stupid) question :slight_smile:

My misunderstanding was that my binary sensor had to send an on/off to an entity, which in turn could display the received result. Just now realised that the binary sensor is an entity…

Trying to set the icon for the binary sensor, but HA won’t let me. Icon_template seems like the wrong way to go, but can’t see any other setting?

1 Like