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

Option to not advertise upon startup #27

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Conversation

Rudd-O
Copy link

@Rudd-O Rudd-O commented Mar 12, 2023

With some devices, it is preferable simply not to advertise at all the return of the ESP keyboard once it restarts.

This option enables users to choose that.

They can create a switch to turn advertisements off in this way:

globals:
  - id: keyboard_enabled
    type: bool
    restore_value: no
    initial_value: "false"

switch:
  - platform: template
    name: Enabled
    icon: mdi:power
    lambda: |-
      if (id(keyboard_enabled)) {
        return true;
      } else {
        return false;
      }
    turn_on_action:
      - ble_keyboard.start: le_keyboard
      - lambda: |-
          id(keyboard_enabled) = true;
      - logger.log:
          format: "The keyboard has been enabled."
          level: INFO
    turn_off_action:
      - ble_keyboard.stop: le_keyboard
      - lambda: |-
          id(keyboard_enabled) = false;
      - logger.log:
          format: "The keyboard has been disabled."
          level: INFO

@sourcery-ai
Copy link

sourcery-ai bot commented Mar 12, 2023

Sourcery Code Quality Report

❌  Merging this PR will decrease code quality in the affected files by 0.38%.

Quality metrics Before After Change
Complexity 1.38 ⭐ 1.37 ⭐ -0.01 👍
Method Length 177.62 😞 179.08 😞 1.46 👎
Working memory 12.84 😞 13.03 😞 0.19 👎
Quality 63.71% 🙂 63.33% 🙂 -0.38% 👎
Other metrics Before After Change
Lines 1044 1048 4
Changed files Quality Before Quality After Quality Change
components/ble_keyboard/__init__.py 74.47% 🙂 74.34% 🙂 -0.13% 👎
components/ble_keyboard/const.py 35.25% 😞 35.25% 😞 0.00%

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
components/ble_keyboard/__init__.py ble_keyboard_press_to_code 2 ⭐ 125 😞 8 🙂 68.04% 🙂 Try splitting into smaller methods
components/ble_keyboard/__init__.py ble_keyboard_combination_to_code 0 ⭐ 132 😞 8 🙂 69.20% 🙂 Try splitting into smaller methods

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

@Rudd-O
Copy link
Author

Rudd-O commented Aug 13, 2023

hello?

Copy link

@jd1 jd1 left a comment

Choose a reason for hiding this comment

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

I switched to your branch and it works fine. I justed added some suggestion to the YAML example. I can't say much about the code, but I would be happy if @dmamontov could have a look.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@Rudd-O
Copy link
Author

Rudd-O commented Feb 23, 2024

Thanks for the review! Your changes have been committed.

Rudd-O and others added 3 commits February 23, 2024 03:22
Co-authored-by: Johannes Dilli <[email protected]>
Co-authored-by: Johannes Dilli <[email protected]>
Co-authored-by: Johannes Dilli <[email protected]>
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