Skip to content
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

RF433 json usermod #4234

Open
wants to merge 3 commits into
base: 0_15
Choose a base branch
from
Open

Conversation

kilrah
Copy link

@kilrah kilrah commented Oct 29, 2024

Inspired by https://github.com/athom-tech/Sound-Reactive-WLED/tree/master/usermods/RF433
Modified to handle similar cases as other remote methods through json

Usermod for controlling WLED using a generic 433 / 315MHz remote and simple 3-pin receiver
See https://github.com/sui77/rc-switch/ for details

Build:
- Enable by defining USERMOD_RF433 in my_config.h
- Uncomment "sui77/rc-switch @ 2.6.4" in platformio.ini default env lib_deps section

Usage:
- Connect receiver to an interrupt-capable pin
- Set pin in Config->Usermods
- Info pane will show the last received button code
- See https://kno.wled.ge/interfaces/json-ir/json_infrared/ as reference to create a "remote433.json" file
and upload it to the ESP in http://ip/edit, the key for the actions is the button number retrieved from above.

@blazoncek
Copy link
Collaborator

Thank you.
Please provide a minimal "readme.md" to accompany the usermod similar as found in other usermods.
Please also revert changes in platformio.ini and add the information into platformio_override.sample.ini (and readme.md)

@DedeHai
Copy link
Collaborator

DedeHai commented Oct 31, 2024

This looks like a great addition. Did you test it to work on all ESP variants?

A few suggestions:

  • provide a list of compatible pins for all ESPs in the readme
  • even better: restrict pin selection to compatible pins
  • provide an example json file

@kilrah
Copy link
Author

kilrah commented Oct 31, 2024

Did you test it to work on all ESP variants?

Tested on esp32, c3 and esp8266

even better: restrict pin selection to compatible pins

How can that be done? Believe it's all of them anyway

provide an example json file

No problem to just put one in the folder?

@DedeHai
Copy link
Collaborator

DedeHai commented Oct 31, 2024

not sure how to restrict pins but I think AR usermod does it, maybe look at others for examples but I have seen UMs where unusable pins are red. In the deep-sleep usermod I just create a list but there I do not use 'pin' because already used pins can be repurposed, so not going through pinmanager.

yea, I would just put the example json in the usermod folder, easier to find than going through KB and download an IR remote file.

@blazoncek
Copy link
Collaborator

FYI you cannot restrict GPIO in usermods. Not yet.
Existing restrictions come from used pins.

@kilrah
Copy link
Author

kilrah commented Oct 31, 2024

I looked around and at least for ESP32, S3 and 8266 all pins can be used as interrupts so there should not be any restriction.

Move doc to separate readme
Add sample config
Fix missing json handling
@kilrah
Copy link
Author

kilrah commented Nov 4, 2024

There, hopefully that's fine... I changed the default_env in platformio_override.sample.ini because the existing one doesn't exist anymore and so just copying the whole sample would break.

platformio_override.sample.ini Outdated Show resolved Hide resolved
sprintf_P(objKey, PSTR("\"%d\":"), button);

// attempt to read command from remote.json
readObjectFromFile(PSTR("/remote433.json"), objKey, pDoc);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it make more sense to read the JSON file during your setup function rather than for every button press?

Copy link
Author

@kilrah kilrah Nov 7, 2024

Choose a reason for hiding this comment

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

This is done the same as for wizmote, and for IR which wizmote was taken from. If it was loaded on setup only if you went to /edit and changed the file changes wouldn't be taken into account until a reboot? That wouldn't be user-friendly.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree, this (reading the file upon receive) is the way it is done in all other json remote code. Also there is no restriction on creating say 50 different commands: that would hog a lot of RAM permanently.

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.

4 participants