Robert Schütz 2019-02-27 14:32:37 +01:00
parent 27fb4f46d2
commit 971187eada

View File

@ -29,14 +29,24 @@ let
# platform = "luftdaten"; # platform = "luftdaten";
# ... # ...
# } ]; # } ];
#
# Beginning with 0.87 Home Assistant is migrating their components to the
# scheme "platform.subComponent", e.g. "hue.light" instead of "light.hue".
# See https://developers.home-assistant.io/blog/2019/02/19/the-great-migration.html.
# Hence, we also check whether we find an entry in the config when interpreting
# the first part of the path as the component.
useComponentPlatform = component: useComponentPlatform = component:
let let
path = splitString "." component; path = splitString "." component;
# old: platform is the last part of path
parentConfig = attrByPath (init path) null cfg.config; parentConfig = attrByPath (init path) null cfg.config;
platform = last path; platform = last path;
in isList parentConfig && any # new: platform is the first part of the path
(item: item.platform or null == platform) parentConfig' = attrByPath (tail path) null cfg.config;
parentConfig; platform' = head path;
in
(isList parentConfig && any (item: item.platform or null == platform) parentConfig)
|| (isList parentConfig' && any (item: item.platform or null == platform') parentConfig');
# Returns whether component is used in config # Returns whether component is used in config
useComponent = component: useComponent = component: