mtgeekman / Home_Assistant_NeoSmartBlinds

Adds NeoSmart Blinds support to Home-Assistant.
46 stars 14 forks source link

DRYer configurations possible? #44

Closed slamotte closed 1 year ago

slamotte commented 1 year ago

First off, thanks for this project. I recently started with Home Assistant and I'm not sure what I would have done if your project didn't exist.

We have 14 blinds in our house with a single controller. Rather than repeat the same settings for every blind, is there any way to optimize the configuration so you can specify the controller config separately from the blinds? Or even reference the controller for each blind?

I tried using YAML anchors like this:

common: &common
  platform: neosmartblinds
  host: 10.0.0.127
  hub_id: xxx
  protocol: http
  port: 8838
  rail: 1
  percent_support: 1
  close_time: 30
  motor_code: no

cover:
  - <<: *common
    name: Office
    blind_code: 064-112-15
  - <<: *common
    name: Great Room
    blind_code: 064-117-15
  - # etc

but the config is invalid because top-level names (like common in my example) are reserved for integrations. So maybe that's the key, to change the schema to allow anchors to be declared someplace, but then you would almost certainly lose the tight schema checking which could cause non-technical folk big pain 🤔

In the end it's not a big deal to copy/pasta the settings 14 times, it's just not too elegant, so if there's a way to avoid it I'd love to hear about it.

slamotte commented 1 year ago

Never mind, figured it out:

# NeoSmartBlinds
cover:
  - name: Office
    blind_code: 064.138-15
    <<: &basement
      platform: neosmartblinds
      host: 10.0.0.127
      hub_id: xxx
      protocol: http
      port: 8838
      rail: 1
      percent_support: 1
      close_time: 10
      motor_code: no
  - name: Rec Room
    blind_code: 240.061-15
    <<: *basement

Maybe this will help someone else.