Skip to content

Conversation

@Lash-L
Copy link
Collaborator

@Lash-L Lash-L commented Apr 29, 2023

based this off of your single device work.

This is still very much WIP. but it is a basis and I thought I would publish it to see if you had any feedback

@Lash-L Lash-L marked this pull request as draft April 29, 2023 03:29
@Lash-L
Copy link
Collaborator Author

Lash-L commented Apr 29, 2023

I'm also adding a vacuummodelspecification which states which of the enum to use.

I'll push that when I get home

Copy link
Collaborator

@humbertogontijo humbertogontijo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks much better

},
)
class RoborockStateCode(RoborockEnum):
starting = 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't enum names be upper case? We could create a function to return it lower

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would that function be? We would just call it on top of each time we need it lowercase?

I was thinking about translations of the entities, it my head it made more sense to be lower case but it could be upper case

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me test this when I have the chance. My first impression was that this is non standard. But if it helps with some scenarios I can work with it

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish I pushed my changes so that you could see it/ use it. But basically I have a function that builds a vacuum mode specification based on the model str that determines which e has to use

@Lash-L
Copy link
Collaborator Author

Lash-L commented May 1, 2023

@humbertogontijo This still has more work - but let me know what you think conceptually whenever you have a chance - no rush

capability: Optional[Any] = None
category: Optional[Any] = None
schema: Optional[Any] = None
model_specification: ModelSpecification | None = None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ops. I'm pretty sure this class is wrong. Might have been an issue on my end when coping and pasting all these entities

@humbertogontijo
Copy link
Collaborator

Overall it is looking fine

@Lash-L Lash-L changed the base branch from feat/single-device-api to main May 1, 2023 16:50
@Lash-L Lash-L marked this pull request as ready for review May 2, 2023 00:55
@Lash-L
Copy link
Collaborator Author

Lash-L commented May 2, 2023

Code is tested and working - you can see how I tested implementing it here: https://github.com/Lash-L/core/tree/roborock_device_specific/homeassistant/components/roborock

prefix=b"\x00\x00\x00\xa7", params={"data": [], "need_retry": 1}
),
RoborockCommand.SET_CUSTOM_MODE: CommandInfo(prefix=b"\x00\x00\x00\x87", params=[108]),
RoborockCommand.SET_CUSTOM_MODE: CommandInfo(prefix=b"\x00\x00\x00w", params=[108]),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to change this to get it to work - was this change made on purpose?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I sniffed commands and merged them into CommandInfoMap. It is strange that the app sends invalid prefixes haha

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idk maybe there's some magic resting to prefixes we don't know yet haha.

Does the prefix appear to be wrong for you as well?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably. I still don't know much about these 4 heading bytes
Yes, I had to apply your change for it to work.

@humbertogontijo
Copy link
Collaborator

After this gets merged, should we use dicts to parse the enum value?
We need the translation key for state within extra_attributes (for lovelace xiaomi vacuum card) and for error sensor

@Lash-L
Copy link
Collaborator Author

Lash-L commented May 2, 2023

What do you mean by that?

Like a dict from enum value to translation key? Why not use enum name as translation key

@humbertogontijo
Copy link
Collaborator

Oh, I tried it just by logging the return of a command. But didn't verified that it was actually returning the enum for state and error_code

@Lash-L
Copy link
Collaborator Author

Lash-L commented May 2, 2023

I think this in its current form would work for that - this https://github.com/Lash-L/core/blob/34f175e59a722ce9a1c12bf0f64c2d079e446f4b/homeassistant/components/roborock/vacuum.py#L27 correctly maps, so I assume the errors would work as well. And whenever we need the string, we just call .name like I do here https://github.com/Lash-L/core/blob/34f175e59a722ce9a1c12bf0f64c2d079e446f4b/homeassistant/components/roborock/select.py#L44

This should be ready for a merge whenever you see fit.

@Lash-L Lash-L changed the title Specific device functionality feat: add specific device functionality May 2, 2023
@humbertogontijo
Copy link
Collaborator

Had to make a small change for translations to work
c559d40

@Lash-L
Copy link
Collaborator Author

Lash-L commented May 3, 2023

You were able to get fan speed translations to work? How do? It wasn't translating for me when I tried

@humbertogontijo
Copy link
Collaborator

humbertogontijo commented May 3, 2023

I'm not there yet. Still making necessary changes
I'm stuck with mop_mode schema for service vacuum_set_mop_mode
I'll probably drop that service

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants