Create Virtual Device

Sorry if this has been asked in some form before, but I can’t find a final answer.
I would like to create a virtual device made up of several existing entities related to security to make it very simple for my wife to see if everything is in order, or to understand problems when they occur. For example, it would include current Frigate detection, locks status, movement detectors…
Is anything like that possible? Alternatively, what’s the best way to reach that objective?

If you want something that reports out status for a set of heterogeneous devices, template sensor is probably what you want.

but hard to tell without more specifics…

You could use conditional cards.

I use this for telling me what doors are open. I also use other similar cards in a grid with this.

Create a group of doors first.

Then use simple conditional card code.

type: conditional
conditions:
  - entity: binary_sensor.doors
    state: 'on'
card:
  type: custom:auto-entities
  card:
    type: entities
    state_color: true
    title: Doors Open
  filter:
    include:
      - group: binary_sensor.doors
        state: 'on'
    exclude: []
1 Like

Do you mean a sensor with various attributes?

There’s a HACS integration that does this:

…but wouldn’t a dashboard be easier?

3 Likes

it depends on what all you want to do with it. if all that you want is to display a ui showing the top issues, and there’s a small handful of possibilities, then doing a card that has a set of conditions like what @Arh said is a good option.

if you have, perhaps a long list of sensors, and you need to do something more complex to summarize (e.g. count them and enumerate) which ones are at issue… but then all you need is a summary, then you can use a sensor to do the complex composition and calculation, then set the final human readable result as it’s state.

if you need to trigger off individual states, then you may end up preferring to do something with multiple attributes.

but it’s hard to tell without a lot more specifics on what you want. can you describe quite specificaly what you want to show and do with this virtual device?

1 Like

Here is what I do with my system.

Basically templates to summarize when you have a problem. It is in the status_monitor.yaml file in my packages folder. The first binary_sensor flags if there is a problem with ad-guard. The second binary_sensor is the one you want. The third sensor is for devices offline. I like this approach because all the critical items are added, deleted from the one template

template:

  - binary_sensor:
      - name: adguard status
        unique_id: adguard_status
        state: >-
            {{ 
            is_state('switch.adguard_filtering', 'off') or
            is_state('switch.adguard_safe_browsing', 'off') or
            is_state('switch.adguard_safe_search', 'off') or
            is_state('switch.adguard_protection', 'off') or
            is_state('switch.adguard_home_filtering', 'off') or
            is_state('switch.adguard_home_safe_browsing', 'off') or
            is_state('switch.adguard_home_safe_search', 'off') or
            is_state('switch.adguard_home_protection', 'off')
            }}

  - binary_sensor:
      - name: Critical status
        unique_id: critical_status
        icon: mdi:bell-alert
        state: >-
            {{ 
            is_state('input_boolean.hot_water_lockout_offon', 'on') or
            is_state('binary_sensor.lumi_lumi_sensor_wleak_aq1_cf44e607_ias_zone', 'on') or
            is_state('valve.hot_water_valve','unavailable') or
            is_state('valve.wfwsv_socket','unavailable') or
            is_state('valve.zigbee_water_switch','unavailable') or
            (is_state('valve.hot_water_valve','closed') and is_state('input_boolean.vacation_mode','off')) or
            (is_state('valve.wfwsv_socket','closed') and is_state('input_boolean.vacation_mode','off')) or
            (is_state('valve.zigbee_water_switch','closed') and is_state('input_boolean.vacation_mode','off'))
            }}

  - sensor:
      - name: "Unavailable Devices"
        unique_id: unavailable_devices
        state: >
          {% set domains = ['light', 'binary_sensor', 'lock','zha'] %}
          {% set filter = [''] %} 
          {{ states | selectattr('domain', 'in',domains) | rejectattr('entity_id', 'in', filter) |
          selectattr('state','eq','unavailable') | map(attribute='name') | list | join(', ') }}

This is the main card I use, that only shows when there is an urgent issue and flashes red. tapping it take you to the location where I have cards that show all the details. It does require installing custom:button-card

type: conditional
conditions:
  - condition: state
    entity: binary_sensor.critical_status
    state: 'on'
card:
  entity: binary_sensor.critical_status
  tap_action:
    action: navigate
    navigation_path: /lovelace-maint/status
  state:
    - color: red
      icon: mdi:bell-alert
      styles:
        card:
          - animation: blink 2s ease infinite
      value: 'on'
      name: ''
      show_name: false
    - color: green
      icon: mdi:null
  type: custom:button-card

2 Likes

Does this display which door is open?

Thanks, I’ll try this out very soon!

My solution with the conditional card shows only the doors that are open, the card does not show if the doors are all closed.

This card is really cool! I think it solves the problem, many thanks!

This solved my problem in the exact way I needed, thank you for sharing!

I have some RF controlled ceiling fans in my house, which I use Tasmota to control. However the Tasmota integration doesn’t individualize the fans as devices. And to control the fans, I created some Scripts and Helpers to track the states and values such as fan speed, light state, etc. All because it’s a “dumb” device that cannot sync its values to HASS.

Using this virtual device creator integration, I created a Device for each fan, and then added the Scripts and Helpers of each respective fan to the new virtual devices. This now allows me to have these helpers be managed as if they’re devices, and gain all the benefits of a device, such as seeing which Automations are related, assigning the device to a room, adding entities in bulk to the dashboard, etc. These things are much less nebulous now. Very nifty!