Condition for showing generic camera

Is it possible to use a condition for showing a generic camera image?
I want to use it for my camera at home. I only want to show it on HA when nobody is home (device tracker). I do not want to spy on my Family :slight_smile:

So i think lovelace (which is kinda beta at the mo) can dynamically enabled and disable cards based on thing.

I remember someone else wanting to have dynamic cards on the front end, as was told lovelace.

Okay thanks, but at the moment I would rather want a solution for the “old” UI… if possible.

Not possible in the HASS frontend, HADashboard might work tho.

okay. Too bad. No way to maybe Group it and hide that Group with a condition or something like that?

u can hide icons, like devices when tracking them.
but not entries/group of entries.

okay. Guess I have to wait for this to be possible before integrating my cameras then

I haven’t tried using it for this, but there is a group.set service that you can use to set the entities in the group. You might be able to use that to dynamically include/exclude the generic camera from a view group. Go to the Services page in the frontend, then select group.set in the Service drop-down. It will show you the service parameters.

Having said that, wouldn’t it be better to somehow disable the camera feed when you don’t want to see it? Unfortunately the generic camera platform doesn’t seem to implement the new camera services turn_off and turn_on. If you’re comfortable with programming, maybe you can add them. :wink:

i have tried to include the Group.set service in an automation but it returns an error.

action:
  - service: group.set
    data:
      entity_id: 
        - group.cameras
      visible: false

“Invalid service data for group.set: extra keys not allowed @ data[‘entity_id’]. Got [‘group.cameras’]
required key not provided @ data[‘object_id’]. Got None”
What am I doing wrong?

I would very much like to disable the feed instead but my programming skills are on a novice level :wink:

According to:

The parameter is object_id, not entity_id. object_id is the part after the dot. This is for the entity_id of the group, so I believe you want it to be cameras.

You also need to specify entities, which is the list of entity_id’s you want to be in the group. I.e., the cameras you want visible.

You do want to see this group, right? So visible should probably be true.

So:

action:
  - service: group.set
    data:
      object_id: cameras
      visible: true
      entities: camera.my_camera_1, camera.my_camera_2

This might need some tweaking. E.g., not sure if you need to specify all the parameters, of if the ones you leave out will just remain what they were.

I did not notice the difference :slight_smile:
Now it Works. Anyway I maybe think the other possibility “Group.set_visibilty” could also be an option. Normally I create a Group in the Groups.yaml and have also tried that for cameras (Group.cameras) and then used the Group.set_visibilty in an automation and no errors but nothing happens.

  cameras:
    name: Cameras
    view: view
    entities:
      - camera.test

action:
  - service: group.set_visibility
    data:
      entity_id: group.cameras
      visible: false

Are you trying to hide a view group, a regular group (which is part of a view group), or an entity in a regular group?

In your above example the group is a view group. I’m not sure if those can be hidden. (Don’t really know.)

I would like to hide the view Group so it will not appear in the top of the UI.
You think it is posible to create a always visible view Group and then hide the camera group in it?

Well, as I said, I haven’t played with groups in this way, but I think there are a few possible options. (At least there’s a few things I’d try.)

So let me understand. You only have one camera, and you’re trying to hide it from the UI when people are home. Is that right? I.e., you’re not trying to hide one camera out of a few. And is it the only thing in a view group (aka tab)?

Assuming you have just the one camera, and it’s the only thing in a group view, then you could use the group.set service to change the entities of the view group - just the camera when nobody is home, or nothing when somebody is home. What I’m not sure about is if it’s valid to have an empty view group. But it’s worth a try. (BTW, you can do this via the Services page to test out the concept before writing automations/scripts.)

If that doesn’t work then maybe you need a group to put it in (view or regular) that has something else in it. That way you could change its entities to the camera and something else, or just something else. Of course you’d have to find some entity to include that is useful in some way.

Hi @jeppper, maybe this automation helps:

######################################################################
#Show KitchenCam picture only when cam is actually on
######################################################################
- alias: Visibility KitchenCam On
  trigger:
    platform: state
    entity_id: switch.etekcity_0320_2
    to: 'on'
  action:
    service: group.set_visibility
    entity_id: group.cameras3
    data:
      visible: True
######################################################################
- alias: Visibility KitchenCam Off
  trigger:
    platform: state
    entity_id: switch.etekcity_0320_2
    to: 'off'
  action:
    service: group.set_visibility
    entity_id: group.cameras3
    data:
      visible: False

It actually shows the card (group) with the camera if its power switch is turned on and hides it when the power switch is turned off.
I though about triggering it by the camera state, i.e. home vs. not_home but decided to go with the power on/off option because it reacts faster.

This is the cameras3 group in my groups file:

cameras3:
  name: Security Cameras 3
  entities:
    - camera.kitchencam

Hi
Did you also need to include this Group into a view Group to make it visible/invisibe?

That’s all the code I use.

  1. put the camera into a group
  2. turn visibility of the group on and off

This is the configuration of the camera itself:

- platform: generic
  still_image_url: http://192.168.7.82/image/jpeg.cgi
  username: !secret cam_user
  password: !secret cam_pass
  name: KitchenCam

I now tried to make an emty view Group in which I included the camera Group and now it Works :slight_smile: I guess it is not possible to hide a view Group with this service.

So you needed nested groups for that?
Strange that my setups work without.

But is the Group you created included in a “view” Group?