How to create a family group for devices charging?

I want to create a group that is either in state charging or not_charging. I want to detect when all of the listed devices are in state charging.

I tried as follows, but the group state is unknown. why?

groups.yml:

charging:
  name: Family Charging
  all: true
  entities:
    - sensor.my_mobile_battery_state
    - sensor.wife_mobile_battery_state

Group status can only be binary. The way to do this would either be to create template binary sensors for each phone, and then put those in a group or (less code) make a single template binary sensor covering all the phones and use that in place of the group.

Could you give an example on the entities above setting a binary_sensor into status on only when both charging, and off otherwise?

value_template: "{{ is_state('sensor.my_mobile_battery_state', 'charging') and is_state('sensor.wife_mobile_battery_state', 'charging') }}"
1 Like