Remove attributes entity

I have the minecraft sensor to check my minecraft server

Now is the problem that whenever I put an automation on the entity it changes based on state AND attributes. And the attributes changes all the time (ping, player names reordering). I have created a sensor based on player names. That works ok. But I tried creating a sensor based on the state only. Without all the attributes. But I cannot get that to work

As you can see in the picture. I want a sensor with only the 0/20 state and not all attributes. But I do want to have the attributes in the original entity for usage.

You can do that with template sensor I believe but why?
What is the usecase and why the original sensor with the state fails to do the job?

Rather paste your automation here which sounds the falty one.

1 Like

You could add a condition in order to check if the state has changed.

- condition: template     
  value_template: '{{ trigger.from_state.state != trigger.to_state.state }}'
1 Like
- id: '1578653971070'
  alias: Minecraft
  description: ''
  trigger:
  - entity_id: sensor.minecraft_server
    platform: state
  condition: []
  action:
  - data:
      message: 'Er zijn {{ states(''sensor.minecraft_server'')|replace(''/20'', '''')
        }} spelers verbonden met de server. Momenteel online: {{ state_attr(''sensor.minecraft_server'',
        ''players'') }}'
      title: Iemand verbonden met Minecraft
    service: notify.mobile_app_vog_l29

I did this through GUI (I know that’s a bad thing :blush:)
I don’t know how it’s suppose to look ONLY to the state 0/20 when it changes to 1/20 etc. But now it looks to ALL attributes aswell.

Usecase: I want to get a notification when someone connects/disconnects from the server.

But now it just gives me a notification every 30 seconds because something always changes. The ping changes all the time and the players attribute aswell because of reordering. Sometimes it’s Players: [1 , 2 , 3] and 30 seconds later it’s Players: [2, 1, 3]

I will try this.

Do i need to specify which entity state to look at? or does it look at the entity from the trigger?

I’m sorry my coding skills are not that great :slight_smile:

Basically Dennis’s suggestion is what you asked for (but that’s not always what people need I grant you)
Each entity has a state, and also can have many attributes, as you have found entities trigger (without a specified state trigger) on all the attributes as well (I know you know this but I’m explaining for anyone else comming across this thread)
Dennis’s suggestion puts a condition in so that it just makes sure that the state has changed (attributes may have changed also but…) ie ‘from’ does not equal ‘to’ .

I think that’s elegant :+1:

Me too! Wouldn’t have thought that myself!

No, just use the automation editor to drop that as condition.

Not at all. Especially now when you can use the yaml mode and put templates and basically whatever in.

- id: '1578653971070'
  alias: Minecraft
  description: ''
  trigger:
  - entity_id: sensor.minecraft_server
    platform: state
  condition:
  - condition: template
    value_template: 'value_template: ''{{ trigger.from_state.state != trigger.to_state.state
      }}'''
  action:
  - data:
      message: 'Er zijn {{ states(''sensor.minecraft_server'')|replace(''/20'', '''')
        }} spelers verbonden met de server. Momenteel online: {{ state_attr(''sensor.minecraft_server'',
        ''players'') }}'
      title: Iemand verbonden met Minecraft
    service: notify.mobile_app_vog_l29

Well I added it but now I get no notifications at all.

Your line has value_template twice and all in all too many ’ marks :slight_smile:

  condition:
  - condition: template
    value_template: '{{ trigger.from_state.state != trigger.to_state.state}}'

Ahh yes because pasting the whole part into the gui value_template part doesn’t work. I’m such an idiot :smile:. Thanks everybody for your help. I’ve learned a lot :slight_smile:

Follow up: it works like a charm. Now to let my lights flash green and then back to normal state. But that’s a different “project”

Hi - can you tell me where you got the sensor and if it is working with 0.10x releases of HA? Thanks. I had mine working but since recent updates it has caused the HA UI to fail.