Core: Person cannot be merged (Packages)

Created on 22 Feb 2019  路  16Comments  路  Source: home-assistant/core

Home Assistant release with the issue:

0.88.0

Last working Home Assistant release (if known):
new component

Operating environment (Hass.io/Docker/Windows/etc.):

homeassistant in docker on unRAID system

Component/platform:

https://www.home-assistant.io/components/person

Description of problem:
the person component cannot be configured in a package.
if the same code is present in the configuration.yaml it all works.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

person:
  - name: Roland
    id: person_roland
    device_trackers:
      - device_tracker.nmap_rolands_nokia

this works!

But:

  packages:
    !include_dir_named packages

with this as an include file does not work. (filename person.yaml)

person:
  - name: Roland
    id: person_roland
    device_trackers:
      - device_tracker.nmap_rolands_nokia

Traceback (if applicable):

2019-02-22 21:14:33 ERROR (MainThread) [homeassistant.config] Package person setup failed. Component person cannot be merged. Expected a dict. (See /config/packages/person.yaml:4). 

Additional information:
https://community.home-assistant.io/t/component-person-cannot-be-merged/100963

person

Most helpful comment

Lol, so true. Will look into it tomorrow. Laptop ran out of stormlight.

It鈥檚 most likely the validation schema for person

All 16 comments

Can you simply nest this under homeassistant: in your package.yaml file?

E.g.

```
homeassistant:
person:
- name: User
id: user
user_id: User
device_trackers:
- device_tracker.user_iphone
- device_tracker.user_iphone_bluetooth

No, that results in this error:
[homeassistant.config] Package person contains invalid customize
and I don鈥檛 think it should be there, only customize is at that level.

CC @kellerza

perosn.yaml should only contain

  - name: Roland
    id: person_roland
    device_trackers:
      - device_tracker.nmap_rolands_nokia

It should not have a person: in it, as your include_dir_named of person.yaml already creates the person: key

This is not how the package key works: https://www.home-assistant.io/docs/configuration/packages/. File names become the package's key, not the platform's. Each package may contain a person key. The content of person would then be merged into a single person by home-assistant before being consumed.

I am too facing the same issue (person cannot be merged). The following config doesn't work for person, but does for everything else (light, cast, ... you name it). I am not using person.yaml as a file name to help visualize things.

configuration.yaml

homeassistant:
  packages: !include_dir_named packages/

packages/somebody.yaml

homeassistant:
  customize:
    person.somebody:
      entity_picture: !secret somebody_picture_url

person:
  - id: "somebody"
    name: "Somebody"
    device_trackers:
      - device_tracker.somebody_phone

packages/someone.yaml

person:
  - id: "someone"
    name: "Someone"
    device_trackers:
      - device_tracker.someone_phone

Lol, so true. Will look into it tomorrow. Laptop ran out of stormlight.

It鈥檚 most likely the validation schema for person

Person can be a list or an empty dict: vol.Any(vol.All(cv.ensure_list, [PERSON_SCHEMA]), {})

Merging only accepts one type... possible solutions:

  1. Make Person a list or empty list
  2. Add the concept of either dict/list to merge_package (@balloob probably wont like a big change to merging)

The reason we allow an empty dict, is because that's the default value if a person just has person: in their config. If filled in, it should be a list.

if my GitHub search skills are right, then PERSON is the only component that has this feature.
So do we need to change PERSON to make it fit with the rest, or do we change the merge_package to handle this special case?
I am questioning if PERSON is truly different from any other component we have in HA.

https://github.com/home-assistant/home-assistant/search?q=%22vol.Any%28vol.All%22&unscoped_q=%22vol.Any%28vol.All%22

Since {} and [] is equally Falsey, it seem like changing the schema could do the trick. Let me try a PR

As part of loading we create empty ordered dict for empty branches, which seems to be the reason for {}

@Data-Monkey the inspect_schemas.py script confirms your finding

since there was some change to person in 0.88.2 I tested it again, but still the same error.

I can confirm that in 0.88.2 there is an issue with placing the person config in a package directory.
If I put the same configuration in the main configurations.yaml, I do not get the dictionary issue
Here is an example of the error and my configuration.
https://hastebin.com/nijebahacu.coffeescript

I have not tested the actual person component, just that if passes the config check.

+1.

using HA 90.2, the error still exists:

Package package_person setup failed. Component person cannot be merged. Expected a dict.

using the exact code as provided on the person documentation https://www.home-assistant.io/components/person/. Can confirm this code works when used in configuration.yaml:

person:
  - name: Name
    id: name12345
    user_id: redactedac12345
    device_trackers:
      - device_tracker.life360_name
      - device_tracker.name #regular phone device
      - device_tracker.name_presence #mqtt_json device_tracker
      - device_tracker.ping_iphone_name
      - device_tracker.telefoon_name_bt

not sure if the component follows zoning to the underlying device_trackers, but so far customizing the entity_picture does work, proof of the component person being alright when used in configuration.yaml (and the customization in my package_person)

homeassistant:
  customize:
    person.name:
      templates:
        entity_picture: >
          if (state === 'home' || state === 'not_home') return '/local/tiles/family/name_' + state + '.png';
          return '/local/tiles/family/name_' + entities['sensor.name_location_picture'].state + '.png';

Just came back here to confirm it is all working now. Thanks a lot!

With 0.94.2, I'm still seeing this. If I have person: in the root configuration, everything works, if I have it in a package, the person and the UI for adding new persons disappear. In both cases I get [homeassistant.loader] Loaded person from homeassistant.components.person in the logs, but only in the former do I also get [homeassistant.setup] Setting up person and [homeassistant.setup] Setup of domain person took 0.8 seconds.

Should I open a new issue for this?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kirichkov picture kirichkov  路  3Comments

aweb-01 picture aweb-01  路  3Comments

arangates picture arangates  路  3Comments

coolriku picture coolriku  路  3Comments

MartinHjelmare picture MartinHjelmare  路  3Comments