DavidMStraub / homeassistant-homeconnect

Custom component for Home Assistant to connect appliances supporting the Home Connect standard
MIT License
117 stars 29 forks source link

A few suggestions #120

Open SantaFox opened 3 years ago

SantaFox commented 3 years ago

Dear David, first of all let me show my gratitude for your great work.

I have three HomeConnect-enabled appliances, a Neff Hob, and Siemens Washer and Dryer (separate appliances). With all respect to the current versions, I'd like to specify a few things that may be easily improved.

1) Programs list. You have lists pre-configured as constants. I can say that with my Washer and Dryer, some programs are match, and some are not. If they doesn't match, than no Program switches are turned on.

An API request gives the following results for me, which totally match the listed programs on the machine control pane. May you amend your function DeviceWithPrograms.get_programs_available() to make a request to https://api.home-connect.com/api/homeappliances//programs and return the actual list?

{
  "data": {
    "programs": [
      {
        "key": "LaundryCare.Dryer.Program.Cotton",
        "name": "Cotton",
        "constraints": {
          "execution": "selectandstart",
          "available": true
        }
      },
      {
        "key": "LaundryCare.Dryer.Program.Synthetic",
        "name": "Synthetics",
        "constraints": {
          "execution": "selectandstart",
          "available": true
        }
      },
      {
        "key": "LaundryCare.Dryer.Program.Mix",
        "name": "Mixed Fabrics",
        "constraints": {
          "execution": "selectandstart",
          "available": true
        }
      },
      {
        "key": "LaundryCare.Dryer.Program.Dessous",
        "name": "Lingerie",
        "constraints": {
          "execution": "selectandstart",
          "available": true
        }
      },
      {
        "key": "LaundryCare.Dryer.Program.TimeCold",
        "name": "Timed programme cold",
        "constraints": {
          "execution": "selectandstart",
          "available": true
        }
      },
      {
        "key": "LaundryCare.Dryer.Program.TimeWarm",
        "name": "Timed programme warm",
        "constraints": {
          "execution": "selectandstart",
          "available": true
        }
      },
      {
        "key": "LaundryCare.Dryer.Program.Hygiene",
        "name": "Hygiene",
        "constraints": {
          "execution": "selectandstart",
          "available": true
        }
      },
      {
        "key": "LaundryCare.Dryer.Program.Super40",
        "name": "Rapid 40`",
        "constraints": {
          "execution": "selectandstart",
          "available": true
        }
      },
      {
        "key": "LaundryCare.Dryer.Program.Outdoor",
        "name": "Outdoor",
        "constraints": {
          "execution": "selectandstart",
          "available": true
        }
      },
      {
        "key": "LaundryCare.Dryer.Program.DownFeathers",
        "name": "Pillow",
        "constraints": {
          "execution": "selectandstart",
          "available": true
        }
      },
      {
        "key": "LaundryCare.Dryer.Program.Blankets",
        "name": "Duvet",
        "constraints": {
          "execution": "selectandstart",
          "available": true
        }
      },
      {
        "key": "LaundryCare.Dryer.Program.BusinessShirts",
        "name": "Shirts/Blouses",
        "constraints": {
          "execution": "selectandstart",
          "available": true
        }
      }
    ]
  }
}
  1. A new sensor entity that will hold results from https://api.home-connect.com/api/homeappliances/. You already analyze this, however I suggest to make a sensor with value of "connected" data key pair (it is important thing because remote start needs to be activated), while all other key pairs, except for haId, may be held in the same sensor as attributes. My result example:
{
  "data": {
    "name": "Dryer",
    "brand": "Siemens",
    "vib": "WT47W5H0BY",
    "connected": false,
    "type": "Dryer",
    "enumber": "WT47W5H0BY/07",
    "haId": "<haid>"
  }
}

3. In debug logging, I can see an event when the Dryer finished its program. It differs from similar event because of specific section in the end (LaundryCare.Dryer.Event.DryingProcessFinished: [Object]), and may be we can raise a fully functional event in HA on this?

`{'BSH.Common.Status.DoorState': {'timestamp': 1606928437, 'handling': 'none', 'uri': '/api/homeappliances/SIEMENS-WT47W5H0BY-68A40E1C5862/status/BSH.Common.Status.DoorState', 'value': 'BSH.Common.EnumType.DoorState.Closed', 'level': 'hint'}, 'BSH.Common.Status.LocalControlActive': {'timestamp': 1606928445, 'handling': 'none', 'uri': '/api/homeappliances/SIEMENS-WT47W5H0BY-68A40E1C5862/status/BSH.Common.Status.LocalControlActive', 'value': False, 'level': 'hint'}, 'BSH.Common.Status.OperationState': {'timestamp': 1606928440, 'handling': 'none', 'uri': '/api/homeappliances/SIEMENS-WT47W5H0BY-68A40E1C5862/status/BSH.Common.Status.OperationState', 'value': 'BSH.Common.EnumType.OperationState.Run', 'level': 'hint'}, 'BSH.Common.Status.RemoteControlActive': {'timestamp': 1606928445, 'handling': 'none', 'uri': '/api/homeappliances/SIEMENS-WT47W5H0BY-68A40E1C5862/status/BSH.Common.Status.RemoteControlActive', 'value': True, 'level': 'hint'}, 'BSH.Common.Status.RemoteControlStartAllowed': {'value': False}, 'BSH.Common.Setting.PowerState': {'value': 'BSH.Common.EnumType.PowerState.On'}, 'BSH.Common.Root.ActiveProgram': {'timestamp': 1606928440, 'handling': 'none', 'uri': '/api/homeappliances/SIEMENS-WT47W5H0BY-68A40E1C5862/programs/active', 'value': 'LaundryCare.Dryer.Program.Mix', 'level': 'hint'}, 'BSH.Common.Root.SelectedProgram': {'timestamp': 1606928440, 'handling': 'none', 'uri': '/api/homeappliances/SIEMENS-WT47W5H0BY-68A40E1C5862/programs/selected', 'value': 'LaundryCare.Dryer.Program.Mix', 'level': 'hint'}, 'BSH.Common.Option.Duration': {'timestamp': 1606928438, 'handling': 'none', 'uri': '/api/homeappliances/SIEMENS-WT47W5H0BY-68A40E1C5862/programs/selected/options/BSH.Common.Option.Duration', 'unit': 'seconds', 'value': 2400, 'level': 'hint'}, 'BSH.Common.Option.ProgramProgress': {'timestamp': 1606928440, 'handling': 'none', 'uri': '/api/homeappliances/SIEMENS-WT47W5H0BY-68A40E1C5862/programs/active/options/BSH.Common.Option.ProgramProgress', 'unit': '%', 'value': 0, 'level': 'hint'}, 'BSH.Common.Option.RemainingProgramTime': {'timestamp': 1606930109, 'handling': 'none', 'uri': '/api/homeappliances/SIEMENS-WT47W5H0BY-68A40E1C5862/programs/active/options/BSH.Common.Option.RemainingProgramTime', 'unit': 'seconds', 'value': 120, 'level': 'hint'}, 'LaundryCare.Dryer.Event.DryingProcessFinished': {'timestamp': 1606928377, 'handling': 'acknowledge', 'value': 'BSH.Common.EnumType.EventPresentState.Off', 'level': 'hint'}}`

Thank you one more time, Dmitry

DavidMStraub commented 3 years ago

Hi,

  1. This has been discussed before, see e.g. #53.
  2. Yes, this would be useful, see also #99. It contains some hints on how to imlement this.
  3. See #42.
SantaFox commented 3 years ago

Thank you very much for your prompt answer.

Regarding programs - my bad, I didn't checked the situation with the switched off appliance. However a configuration option may be suggested for the integration, and based on its value new appliances will be added with "standard" list (by the way, can we extend it with positions from my list?) or wait for the appliance to be online to add it with proper options and programs.

Regarding status, am I correctly understand that I should fork your project, test it and then send you a pull request? I never used Python before, but it may be interesting.

Regarding the meaningful events (like program finished, empty condensation container etc), with all my respect, I don't understand what you have suggested. I can see that you code receive the event, however I don't understand what exactly do you recommend. If I correctly understand an architecture of HA, such events should be implemented as integration-specific triggers. However it may be a more simple way, to make a sensor with last event status, and use a standard trigger for sensor value change.

SantaFox commented 3 years ago

Hi David,

it took me a few hours to learn basics of Python and HA architecture, and I think I've found a solution for 2) and 3) requests from my post. I've added a fourth sensor that translates BSH.Common.Status.OperationState into its value, and show all other pairs from appliance.status as its attributes. With such sensor, it is possible to create any automation that triggers from change of the sensor itself or its attributes, and act accordingly to program finish, for example. It looks like this (some enums are not translated):

Screenshot 2020-12-04 205816

There is a lot of things to be improved, and I am afraid it will also require some changes in homeconnect module. However I hope to find a way not to touch the base api module and work only on component level.

I also definitely need to learn Python better, last time I've programmed about 10 years ago and it was C-Sharp...

SantaFox commented 3 years ago

David hi,

are you ok if I fork your project in order to resolve your initial problem with program switches? I have both washer and dryer, and a lot of entities as a result :) Moreover, your initial suggestion that follow the programs list from API will be enough is not correct, my dryer has at least two programs that were not included in your list:

    LaundryCare.Dryer.Program.TimeCold
    LaundryCare.Dryer.Program.TimeWarm
rudizl commented 3 years ago

David hi,

are you ok if I fork your project in order to resolve your initial problem with program switches? I have both washer and dryer, and a lot of entities as a result :) Moreover, your initial suggestion that follow the programs list from API will be enough is not correct, my dryer has at least two programs that were not included in your list:

    LaundryCare.Dryer.Program.TimeCold
    LaundryCare.Dryer.Program.TimeWarm

Hi, Santa! I have Bosch dishwasher and tried to find its speciffic programs from api, but without any luck...

SantaFox commented 3 years ago

Hi, Santa! I have Bosch dishwasher and tried to find its speciffic programs from api, but without any luck...

Hi Radoslav, what exactly you have tried?

  1. First of all, your appliance should be turned on in standby (official Home Connect application show state as "Off", but not "Disconnected". It also may be running, but in this case API output may be limited to the list of programs that can be used for "switching" of your current program.
  2. API should be a production API (https://apiclient.home-connect.com/hcsdk-production.yaml), with full authorization (green "Authorize" button shows locked icon)
  3. You obtain a correct haId via /homeappliances request
  4. For programs list, you use a simple /homeappliance/{haId}/programs request, without subcategories
  5. If you still think that list is not full, please share your output from step 4 and a photo of your program selection wheel on control panel of your appliance.
DavidMStraub commented 3 years ago

Hi,

I never replied to this question

are you ok if I fork your project in order to resolve your initial problem with program switches?

but of course I'm totally happy if you fork - this integration is even part of HA Core, so you can also submit your improvements directly there. I currently don't have a lot of time to work on this (as you noticed I guess).