Skip to content

Option to not advertise upon startup - #27

Open
Rudd-O wants to merge 15 commits into
dmamontov:mainfrom
Rudd-O:main
Open

Option to not advertise upon startup#27
Rudd-O wants to merge 15 commits into
dmamontov:mainfrom
Rudd-O:main

Conversation

@Rudd-O

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

Copy link
Copy Markdown

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

sourcery-ai Bot commented Mar 12, 2023

Copy link
Copy Markdown

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

Rudd-O commented Aug 13, 2023

Copy link
Copy Markdown
Author

hello?

@jd1 jd1 left a comment

Copy link
Copy Markdown

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.

Comment thread README.md Outdated
Comment thread README.md Outdated
Comment thread README.md Outdated
@Rudd-O

Rudd-O commented Feb 23, 2024

Copy link
Copy Markdown
Author

Thanks for the review! Your changes have been committed.

Rudd-O and others added 8 commits February 23, 2024 03:22
Co-authored-by: Johannes Dilli <jd1@users.noreply.github.com>
Co-authored-by: Johannes Dilli <jd1@users.noreply.github.com>
Co-authored-by: Johannes Dilli <jd1@users.noreply.github.com>
Probably won't work seeing as 2.x re-wrote a lot, but lets try it first
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.

5 participants