Service Call to Enable/Disable Entities and Devices

Would love to be able to automate enabling/disabling or hiding/unhiding entities and devices with a service call. Tried writing an automation to disable a camera when we have guests but was surprised the functionality didn’t currently exist. Would also come in handy for disabling seasonal devices like holiday lights/fans/fireplaces etc.

In summary, the feature would be to add service calls to:

  • Enable Device
  • Disable Device
  • Enable Entity
  • Disable Entity
  • Hide Entity
  • Unhide Entity

I know this is an older post(I guess not that old), but does something like this exists now ? I need to change the status of the entity to disabled during the day to not flood logs or trigger anything, but I cant find a way to automate that. Only found scripts to change the state and thats not what I need. Any help is appreciated. I do see how to do it in GUI btw.

3 Likes

I have exactly the same need.

2 Likes

Anyone ever figure this out? Have a similar need but not seen anything. Might just see about scripting the camera to PTZ off into lala land but a true disable/enable would be the ideal solution.

1 Like

Hello,
I am also interested in such a service.
Reason:
My integration of “Homematic” (GitHub - danielperna84/hahomematic: Python 3 Interface for Home Assistant to interact with HomeMatic devices) forgets a number of entities every time I update Homematic. They all have to be reactivated manually.
Many greetings, Eckart

2 Likes

Would be interested in that as well. I simply remove some smart home devices from time to time from the power (via a smart plug) and bring them back later. Instead of errors in the logs this could be handled via an automation.

5 Likes

+1 for this feature. I would love to be able to temporarily or conditionally disable devices via an automation or Boolean switch. Currently setting up Christmas lights with a bunch of Wifi outlets and need to disable my exterior garden lights while the Christmas lights are in use… yet they all use the same automation to turn on an hour before sunset!

For now I’m building seperate automations with identical time triggers but would be great to just disable a device on the front end or even better via an automation…

4 Likes

i would also like to be able to disable/enable a camera entity, this would be very helpful…

+1, I would like to disable a polling sensor that creates a lot of traffic based on time - I only need the information in the morning and would disable the entity after a set time.

+1 from me also. I need to enable a device in the day and disable at night.

My use case for this is in detecting new entities (NMAP device_trackers) on my network

I believe that the addition of a new device tracker can be detected in an automation with the following trigger


  trigger:
    platform: event
    event_type: entity_registry_updated
    event_data:
      action: create

Home assistant appears to create the device_tracker entity, but creates it as “disabled by integration” in spite of me having explicitly stated that I want to “Enable newly added entities.” (perhaps this is just because the UI needs a language update)

image

Because the entity is not enabled upon discovery, it seems to not have its attributes in the state machine when one attempts to use a template to report on the attributes of the new entity

{{state_attr(trigger.event.data.entity_id,'friendly_name')}}

Having the ability to enable the entity via a service would allow me to

  1. enable the entity
  2. Wait the prerequisite of 30 seconds for the entity to become available in the state machine
  3. Query the state machine for the device tracker attributes of interest (Source, MAC, IP etc.)
  4. Allow me to construct a human digestible report of what just got added

Related:

8 Likes

This is a nice feature if implemented, as I have my tuya integration has tried 700 times in the last hours for a christmas lights that wont be plugged until December, and logs are flooded stupidly.

Did anyone actually test this?

I would also like to be able to disable/enable a camera entity

It’s been some time, did anyone figure this out? I can confirm this works for a notification:

alias: Device Tracker new device notification
description: ""
trigger:
  - platform: event
    event_type: device_tracker_new_device
    event_data:
      action: create
  - platform: event
    event_type: entity_registry_updated
    event_data:
      action: create
condition:
  - condition: and
    conditions:
      - condition: template
        value_template: "{{ trigger.event.data.entity_id.split('.')[0] == 'device_tracker' }}"
      - condition: template
        value_template: >-
          {{ not
          (trigger.event.data.entity_id.split('.')[1].startswith('unifi_') and
          trigger.event.data.entity_id.split('.')[1].endswith('default')) }}
action:
  - service: notify....
    data:
      message: >-
        New device connected: {{
        trigger.event.data.entity_id }}
1 Like

I happen to be doing this notification as well.

My case triggered from unifi integration where new devices are detected then HA create new entity and device.

How can we simulate a new device to test this script?

My Use Case

Outdoor smart lights on a circuit that is on a dusk to dawn light sensor switrch. When the sun is up and therefor the switch is off, I want the smart devices behind said switch disabled so they don’t throw constant errors while unavailable. At sunset the devices would be re-enabled.

Edit: Spook works fantastically for my use case!

1 Like

Yes. It works.

I have a problem with re-enabling an entity (media_player), after disabling it with spookie. The entity is only afer a full restart of HA visible again.
Any ideas?