Unable change status name anyway

My code from configuration.yaml is above :slight_smile:

I do that:

  • lovelace - 3 small dots and choose and choose user interface configuration
  • a big plus in the bottom right corner choose entities and then binary_sensor.0x00158d00044b72dd_contact
  • and it shows me what I see in the picture.
    Screenshot_2020-02-14 Home Assistant(1)

I really want the picture to show the closed door when the magnet does not touch the sensor and vice versa, and the point is that the picture with the door closed is a description closed.

It seems to me that what I paste into configuration.yam is either invalid or this edited entity is somewhere other than in sensors…

I’m really sorry. Maybe it’s a translation issue but I’m still confused about what you want to do.

From the code in your first post it seemed that you were trying to modify the state there to show open/closed instead of on/off. You can’t make those changes there and have them stay permanently. They will revert back to the state in the state machine (on/off) on the next update.

You will never be able to see open/closed in that location. it will only ever say on/off for a binary_sensor.

the device_class customization only changes how the binary sensor is displayed in the UI. That is done entirely in the customization section of the configuration.yaml or thru the customization sectio in the UI.

However, from the picture right above here it looks like you’ve already done the customization because the state in that picture is saying “open”.

And I still don’t have any idea why think you need to create a template binary_sensor out of another existing binary sensor?

Does the icon not show a closed door when the state shows “closed”? are you saying that the state of the door (open/closed) is the opposite of what it is in reality (if the door is actually open it shows as closed in the UI?

What is the code that you are pasting into configuration.yaml that you think isn’t valid and what makes you think that?

Oh I’m so sorry for misunderstanding, it’s my fault. Once again, what is my idea - look at the pictures below - I have a sensor at home that is not installed on the door but on the lock and there are only two possibilities for this sensor and lock state:

I’m sure there is a possibility of styling some information of sensors in UI HA. I do not care about what binary information is, I prefer to be able to change any information to for example - “I’m in home” or “please close the door” or anything else depending on the situation. And of course assign selected icon depending on the invented description. I thought is the way of that is customize.yaml but I don’t see any effects of its use anywhere, probably because I don’t look where it is needed? my code below:

binary_sensor:
  - platform: template
    sensors:
      door_sensor:
        friendly_name: "Quite_New_Sensor"
        device_class: door
        value_template: "{{ is_state('binary_sensor.0x00158d00044b72dd_contact', 'off') }}"
        attribute_templates:
          battery: "{{ state_attr('sensor.0x00158d00044b72dd_battery', 'battery') }}"
          linkquality: "{{ state_attr('sensor.0x00158d00044b72dd_linkquality', 'linkquality') }}"

I apologize in advance, I hope it’s temporarily misunderstand. I am writing amateur software in few languages, but HA is an idea which I do not quite understand yet, but it will change - I promise it :slight_smile:

Oh, OK!

I think it’s all coming together now.

You already have a binary_sensor that was automatically created by the door sensor device. And the door sensor was already a “door” device class so it showed up correctly as such in the UI.

BUT…you want it to show as the opposite of what the door sensor usually shows. normally when the sensor is ‘on’ the icon and state are ‘open’. but you want the indication to be reversed from that so if the sensor is ‘on’ you want the state and icon to be ‘closed’.

that part i fairly easy but is kind of more advanced because it uses templates.

I think the problem is that you are trying to create the new template binary sensor under the customize section in your configuration files because:

It looks like you have a file that is split away from your main configuration.yaml file called “customize.yaml”, which is OK but you can’t create the new binary_sensor in that file.

the binary_sensor has to be created in your configuration.yaml file either directly by adding it in there or by using a separate file that uses the !include function.

I’m going to assume that you have no idea how this works to be able to explain it to you so don’t be offended if you already know this.

pretty much everything you manually add to HA goes into the configuration.yaml file.

like this:

/config_directory/
->configuration.yaml

in your configuration.yaml file:

homeassistant:
  - stuff here

automation:
  - automations here

script:
  - scripts here

binary_sensor:
  - your manually created binary sensors here

etc......

But you can also split up your configuration by using !include files in the configuration.yaml file

/config_directory/
 ->configuration.yaml
 |
 ->automations.yaml
 |
  ->scripts.yaml
 |
 ->binary_sensors.yaml
 |
 ->  etc

in your configuration.yaml file:

homeassistant:
  - stuff here

automation: !include automations.yaml

script:!include scripts.yaml

binary_sensor: !include binary_sensors.yaml

etc......

then in your binary_sensors.yaml file:

 - your manually created binary sensors here

Notices there is no “binary_sensor:” line in this file as it’s already in the configuration.yaml file

So, to make this work to reverse the indicated state of the door lock from the opposite of what a standard door would show (and using @jocnnor’s suggestion as an example) and depending on if you split your config you would do the following.

If using it directly in configuration.yaml:

homeassistant:
  - stuff here

automation:
  - automations here

script:
  - scripts here

binary_sensor:
  - platform: template
    sensors:
      your_door_lock_sensor:
        friendly_name: "Your New Sensor"
        device_class: door
        # Want this to be inverse of the real sensor. So, if it reports off, this will return true (on).
        value_template: "{{ is_state('binary_sensor.0x00158d00044b72dd_contact', 'off') }}"

etc...

if you are splitting up the config you would put the following in binary_sensors.yaml:

  - platform: template
    sensors:
      your_door_lock_sensor:
        friendly_name: "Your New Sensor"
        device_class: door
        # Want this to be inverse of the real sensor. So, if it reports off, this will return true (on).
        value_template: "{{ is_state('binary_sensor.0x00158d00044b72dd_contact', 'off') }}"

You don’t need to add all of those attributes of the other sensor unless you really want to> but I recommend you don’t just to keep things more simple.

Now when you do that, do a config check an restart HA you should see a new binary sensor in your states page called “binary_sensor.your_door_lock_sensor” and it should always show the opposite state of your original “binary_sensor.0x00158d00044b72dd_contact”. And when you add it to lovelace it should show the opposite state as your original sensor too - if the original state showed “open” then the new one will show “closed”.

I hope I didn’t confuse things too much for you.

1 Like

Yes Yes Yes!!! it works my Master :slight_smile:
And that was the problem - I only created binary_sensors.yaml, included it into configuration.yaml, moved all the code into binary_sensors.yaml and BUM there - everything works !!! :slight_smile:
I am very happy, soon I will start what is most pleasant or styling. Thank you very much for your patience, I’m closing the thread, for now I know as much as I need at the moment.
THANK YOU, THANK YOU!
Screenshot_2020-02-16 Home Assistant

Top door is templated sensor, bottom is native sensor.

1 Like