hassio_appliance-status-monitor icon indicating copy to clipboard operation
hassio_appliance-status-monitor copied to clipboard

Add an option to select the power attribute

Open Superpiffer opened this issue 1 year ago • 1 comments

I have unwanted and useless triggers with no power from appliances:

image

I analized some of this events and figured that the automation is triggered by "linkquality" attribute:

appliance_socket: switch.smart_plug_washing_machine
appliance_suspended_sensor: []
delayed_job_completion_duration: 0
delayed_job_completion_timer: timer.washing_machine_delayed_job_completion_timer
this:
  entity_id: automation.notifications_washing_machine
  state: 'on'
  attributes:
    last_triggered: '2023-03-27T07:04:53.630822+00:00'
    mode: restart
    current: 1
    id: '1679571899294'
    friendly_name: '[Notifications] Washing machine'
  last_changed: '2023-03-23T15:55:50.008512+00:00'
  last_updated: '2023-03-27T07:04:53.630931+00:00'
  context:
    id: 01GWGY4N3Y1E1JCVCHWAJZVWAA
    parent_id: 01GWGY4N3AJCKDQBD0HXMZ06EV
    user_id: null
trigger:
  id: power_event
  idx: '0'
  alias: null
  platform: state
  entity_id: sensor.smart_plug_washing_machine_power
  from_state:
    entity_id: sensor.smart_plug_washing_machine_power
    state: '0'
    attributes:
      state_class: measurement
      child_lock: UNLOCK
      current: 0
      energy: 4.37
      indicator_mode: off/on
      linkquality: 124
      power: 0
      power_outage_memory: restore
      update:
        installed_version: 192
        latest_version: 192
        state: idle
      update_available: false
      voltage: 233
      unit_of_measurement: W
      device_class: power
      friendly_name: Smart plug washing machine power
    last_changed: '2023-03-26T15:46:25.908200+00:00'
    last_updated: '2023-03-27T06:59:36.020225+00:00'
    context:
      id: 01GWGXTYYMQ5ZBZJ8Z53D6FRDJ
      parent_id: null
      user_id: null
  to_state:
    entity_id: sensor.smart_plug_washing_machine_power
    state: '0'
    attributes:
      state_class: measurement
      child_lock: UNLOCK
      current: 0
      energy: 4.37
      indicator_mode: off/on
      linkquality: 112
      power: 0
      power_outage_memory: restore
      update:
        installed_version: 192
        latest_version: 192
        state: idle
      update_available: false
      voltage: 233
      unit_of_measurement: W
      device_class: power
      friendly_name: Smart plug washing machine power
    last_changed: '2023-03-26T15:46:25.908200+00:00'
    last_updated: '2023-03-27T07:04:53.613919+00:00'
    context:
      id: 01GWGY4N3D2P3YZ9J24KJANGVK
      parent_id: null
      user_id: null
  for: null
  attribute: null
  description: state of sensor.smart_plug_washing_machine_power

Is it possible to add a selection for the power attribute? For now I solved manually adding this:

trigger:
- platform: state
  entity_id: !input appliance_power_sensor
  id: power_event
  attribute: power
- platform: state
  entity_id: !input appliance_socket
  id: socket_state_change_event
  attribute: power

Superpiffer avatar Mar 27 '23 08:03 Superpiffer

Hey @Superpiffer! Sorry for the late reply man. I see where the problem is, thank you for sharing it. However, I don't think that adding a select attribute would benefit everyone because most people (I'm one of them) don't have any attribute for such sensor.

The way you worked around this problem is correct, but I'm still wondering if we can have some kind of selection box to enable or disable this optional field.

I need to experiment but I don't know how to test it yet. Anyway, even if I added support to an attribute selection, it wouldn't be possible for the user to have some kind of dropdown choice selection, because it's facultative and so it would involve asking the user which attribute to follow and manually insert it in a text box. I think it's the maximum we can achieve for now.

leofabri avatar Apr 04 '23 06:04 leofabri