-
-
Notifications
You must be signed in to change notification settings - Fork 563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chuangmi IR: Add ability to send any Pronto Hex encoded IR command. #183
Conversation
repeats += 1 | ||
|
||
times = set() | ||
for pair in pronto_data.intro + pronto_data.repeat * (1 if repeats else 0): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (83 > 79 characters)
2 similar comments
Any way that we could make this part of the .play command and detect whether the command is base64 (captured) or Proton format? |
@cnrd I don't think that's a good idea. It adds much more complexity. Also you don't need to put spaces in the Pronto (not Proton :)) and it would make hard to recognise if this is Pronto or base64 (Pronto doesn't use any characters which can't be used in base64). In case of Pronto, the frequency is already in the signal data and my method also gives you an ability to define how many repeats you want (Pronto has separate sections for intro sequence and repeat sequence). Do you see any use case of play method directly accepting a Pronto code? |
Pronto noted. The use case that I would have is in the home assistant platform I'm currently writing, this would avoid requiring extra parameters to be set for each command. Imagine a list of commands, if we could detect the signal type then we could make a list like this:
If we cannot detect the type we would need this to be:
I do however agree that if we cannot detect it reliably then the second option is better even if it's a bit more verbose. Also about the repeat section (I know close to nothing about IR signals): Is this a parameter that repeats the signal to make sure is is received correctly, or is it something that is required by some devices, as in something that would usually be a part of a pronto command found in a manual or on the internet? Sorry for the formatting I'm currently on mobile. |
If you write commands as a simple list, then how do you plan to provide a frequency when base64 is used? You'd still need to make a dict with with code and frequency. And for Pronto you'd want to be able to provide number of repeats. I wonder if the autodetection should be on the library side or on the HA component side. You can have much more control if you do this in the component and then just call the right method in the library. The Pronto code in the example I've provided in the comment:
is the one I've used to generate the base64 version you've tested successfully in #175. You can either use it in a format like above for readability or you can remove the spaces. If you remove the spaces then the character set used in the code is the subset of charset used in base64. Of course there's really low chance that this would be an actual base64 string, especially because the binary form of the signal starts with the magic sequence 0x67, 0xa5, which should always produce a base64 string starting with "Z6". Instead of autodetection you could also go with something like this: |
Just a small remark about autodetecting, maybe it makes sense to have one as a default (accompanied with debug logging for those tinkerers among us), and let one to cast with a syntax as stated in @yawor's last comment ( I would not necessarily find using a simple heuristics to try to detect the type (e.g. a base64-encoded value may |
@rytilahti maybe it could be done with another method in addition the the play and play_pronto. Or maybe the play could be renamed to play_raw and new play could be introduced with the semantics I've mentioned in my comment which would in turn use the play_* methods as backends. That way the software could either use the built-in routing or use the methods explicitly. |
@yawor I think that would be the best way to handle this indeed, I would really not prefer to have something like in users' code: https://github.com/home-assistant/home-assistant/pull/11891/files#diff-c3a98a9bc5ffb47c62c48b7f7b114de3R231 . So to summarize what we'd need to change:
What do you think? |
@rytilahti Do you prefer the "Z6" vs. "0000" type check? |
@rytilahti so it could work like this:
Is that correct? |
@syssi I think both of them are fine, shouldn't really matter (except for detecting an unknown formats). @yawor that sounds good. I think the first part should be to check if there's a colon. If yes, read the type and pass the rest of it to the appropriate handler (that is, the type part is not delivered forwards). |
Pronto Hex is probably the most popular format for storing IR signals.
A usage example:
It only supports a raw variant of Pronto, which begins with value "0000".