ioBroker / ioBroker.lovelace

Visualization with Lovelace-UI
Apache License 2.0
58 stars 27 forks source link

HmIP-BBL shutter/cover configuration #106

Closed agross closed 3 years ago

agross commented 4 years ago

I have HomeMatic HmIP-BBL devices which are not natively supported by ioBroker.lovelace. I wonder what the alias configuration needs to look like in order to:

  1. Have the type detector detect the alias channel as a blind
  2. How to debug if the type detector does not detect an alias channel as a blind (I tried adding console.log but it does not show up in the ioBroker log)
  3. What the required states are for blinds which not only have a position (up/down), but also have the possibility to tilt

I'm not really interested in how to do it via the "devices" adapter because it doesn't support blinds with tilt positions, and I also want to script the alias creation.

Versions:

agross commented 4 years ago

Seems like the type detector does not support tilt levels, right?

This statement in the lovelace code:

if(this._addTiltLevel(entity, control, objects, 'TILT_SET'))

can never become true, because control.states will never have an object with property name = 'TILT_SET' which must be provided by the type detector.

Why did I come to this conclusion? After adding some debug statements, this is what the type detector determined from my aliases:

{
    "states": [
        {
            "indicator": false,
            "type": "number",
            "write": true,
            "name": "SET",
            "required": true,
            "defaultRole": "level.blind",
            "id": "alias.0.hm-rpc.1.00135BE992528C.level"
        },
        {
            "indicator": false,
            "type": "number",
            "name": "ACTUAL",
            "required": false,
            "defaultRole": "value.blind",
            "id": "alias.0.hm-rpc.1.00135BE992528C.tilt_level"
        },
        {
            "indicator": false,
            "type": "boolean",
            "write": true,
            "name": "STOP",
            "required": false,
            "noSubscribe": true,
            "defaultRole": "button.stop",
            "id": "alias.0.hm-rpc.1.00135BE992528C.stop"
        },
        {
            "indicator": true,
            "name": "DIRECTION",
            "required": false,
            "defaultRole": "indicator.direction"
        },
        {
            "indicator": true,
            "name": "WORKING",
            "required": false,
            "defaultRole": "indicator.working"
        },
        {
            "indicator": true,
            "type": "boolean",
            "name": "UNREACH",
            "required": false,
            "defaultRole": "indicator.maintenance.unreach"
        },
        {
            "indicator": true,
            "type": "boolean",
            "name": "LOWBAT",
            "required": false,
            "defaultRole": "indicator.maintenance.lowbat"
        },
        {
            "indicator": true,
            "type": "boolean",
            "name": "MAINTAIN",
            "required": false,
            "defaultRole": "indicator.maintenance"
        },
        {
            "indicator": true,
            "name": "ERROR",
            "required": false,
            "defaultRole": "indicator.error"
        }
    ],
    "type": "blind"
}

The object's names all can be traced back here where, from my understanding,

  1. All channel states are inspected
  2. If a state matches the definition given (i.e. role matches, type matches, the state is writable etc.), it'll be added to the object above

Essentially, the only names that can be returned are depicted by the object above. But these do not contain tilt levels. Not even entries for stuff like "completely open the shutters" or "completely close the shutters". This also reflects what my lovelace is able to do:

  1. Set blinds level using the slider
  2. Stop movement using the stop button
  3. The arrow buttons are dysfunctional

image

I'm still trying to wrap my head around how this all works.

Garfonso commented 4 years ago

Yes, that is true, that tilt level currently is not really supported.

I planned on adding it and also improving the level-roles so that the role defines if 100% is open or closed. I did not yet manage to make a PR to the type detector, there is a fork here that contains those changes: https://github.com/Garfonso/ioBroker.type-detector/tree/all_changes_combined

It is a bit behind official type-detector, I need to update it. If you want, you can install it from github and try it. (I do not have blinds that support tilt, so this is not yet tested, so I'd really like to get feedback on that part of the code). Roles for those type of blinds are defined here https://github.com/Garfonso/ioBroker.type-detector/blob/all_changes_combined/index.js#L344 (but as said, is not yet official, so might change in future).

agross commented 4 years ago

I guess you are kind of familiar with the detector. I was wondering how you debug this piece of code. It just tells you results, but you don't know how you arrived there. I find it especially interesting why I don't get what I expect.

For example, and unrelated to this issue, I was later trying to add a media player (channel with two state with roles media.state and media.cover required). In a unit testing scenario, this works. But after I later added aliases according to this test to my ioBroker instance no media player could be detected. You cannot even add media players using the devices adapter that fit the schema.

it("Must detect media player channel", (done) => {
  const detector = new ChannelDetector();

  const objects = {
    "alias.0.player": {
      common: {
        name: "Media Player",
      },
      type: "channel",
    },
    "alias.0.player.state": {
      common: {
        name: "state",
        type: "boolean",
        role: "media.state",
      },
      type: "state",
    },
    "alias.0.player.cover": {
      common: {
        name: "cover",
        type: "string",
        role: "media.cover",
      },
      type: "state",
    },
  };

  Object.keys(objects).forEach((id) => (objects[id]._id = id));

  const options = {
    objects: objects,
    id: "alias.0.player",
    _keysOptional: Object.keys(objects),
    _usedIdsOptional: [],
  };

  const controls = detector.detect(options);

  console.log(JSON.stringify(controls));
  expect(controls[0].type).to.be.equal(Types.media);

  done();
});
agross commented 4 years ago

I've cherry-picked the blinds-related commits of your branch to my fork off based on upstream's master: https://github.com/agross/ioBroker.type-detector/tree/blinds

All conflicts are resolved (there as only one, a merge would have shown more, but these are unrelated to blinds). You might want to review, I could then create the PR for you or you transfer my branch to your repo and create it yourself.

agross commented 4 years ago

I haven't tested yet, just for alignment with what iobroker.lovelace appears to support.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs within the next 7 days. Please check if the issue is still relevant in the most current version of the adapter and tell us. Also check that all relevant details, logs and reproduction steps are included and update them if needed. Thank you for your contributions. Dieses Problem wurde automatisch als veraltet markiert, da es in letzter Zeit keine Aktivitäten gab. Es wird geschlossen, wenn nicht innerhalb der nächsten 7 Tage weitere Aktivitäten stattfinden. Bitte überprüft, ob das Problem auch in der aktuellsten Version des Adapters noch relevant ist, und teilt uns dies mit. Überprüft auch, ob alle relevanten Details, Logs und Reproduktionsschritte enthalten sind bzw. aktualisiert diese. Vielen Dank für Eure Unterstützung.

agross commented 3 years ago

Just in case somebody else is interested in this. I currently manage my HmIP-BBL blinds using a custom Lovelace widget and some aliases that I create off of hm-rpc devices.

image

Lovelace card markup (requires vertical-stack-in-card):

type: 'custom:vertical-stack-in-card'
cards:
  - type: horizontal-stack
    cards:
      - type: entity-button
        entity: switch.Living_Room_Shutter_Open
        icon: 'mdi:arrow-up'
        name: Open
        show_name: false
        show_icon: true
        icon_height: 40px
      - type: entity-button
        entity: switch.Living_Room_Shutter_Stop
        icon: 'mdi:stop'
        name: Stop
        show_name: false
        icon_height: 40px
      - type: entity-button
        entity: switch.Living_Room_Shutter_Close
        icon: 'mdi:arrow-down'
        name: Close
        show_name: false
        icon_height: 40px
  - type: entities
    entities:
      - entity: input_number.Living_Room_Shutter_Level
        name: Level
        icon: 'mdi:window-shutter'
  - type: horizontal-stack
    cards:
      - type: entity-button
        entity: switch.Living_Room_Shutter_Tilt_Open
        icon: 'mdi:arrow-up'
        name: Open
        show_name: false
        show_icon: true
        icon_height: 40px
      - type: entity-button
        entity: switch.Living_Room_Shutter_Tilt_Close
        icon: 'mdi:arrow-down'
        name: Close
        show_name: false
        icon_height: 40px
  - type: entities
    entities:
      - entity: input_number.Living_Room_Shutter_Tilt_Level
        name: Slats
        icon: 'mdi:angle-acute'

The Lovelace entities (e.g. input_number.Living_Room_Shutter_Level) are defined for ioBroker aliases that are generated from hm-rpc devices.

The generator script linked above

image

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs within the next 7 days. Please check if the issue is still relevant in the most current version of the adapter and tell us. Also check that all relevant details, logs and reproduction steps are included and update them if needed. Thank you for your contributions. Dieses Problem wurde automatisch als veraltet markiert, da es in letzter Zeit keine Aktivitäten gab. Es wird geschlossen, wenn nicht innerhalb der nächsten 7 Tage weitere Aktivitäten stattfinden. Bitte überprüft, ob das Problem auch in der aktuellsten Version des Adapters noch relevant ist, und teilt uns dies mit. Überprüft auch, ob alle relevanten Details, Logs und Reproduktionsschritte enthalten sind bzw. aktualisiert diese. Vielen Dank für Eure Unterstützung.

stale[bot] commented 3 years ago

This issue has been automatically closed because of inactivity. Please open a new issue if still relevant and make sure to include all relevant details, logs and reproduction steps. Thank you for your contributions. Dieses Problem wurde aufgrund von Inaktivität automatisch geschlossen. Bitte öffnet ein neues Issue, falls dies noch relevant ist und stellt sicher das alle relevanten Details, Logs und Reproduktionsschritte enthalten sind. Vielen Dank für Eure Unterstützung.