feat(ups-hid): Beeper control

Signed-off-by: bullshit <coding@ow-software.pl>
This commit is contained in:
bullshit committed 2025-08-18 12:04:20 +02:00
1 parent 64f29e49c8
commit bbacfcb5c8
13 files changed
+702 -41

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import button
from esphome.const import CONF_ID
from . import ups_hid_ns, CONF_UPS_HID_ID, UpsHidComponent
DEPENDENCIES = ["ups_hid"]
UpsHidButton = ups_hid_ns.class_("UpsHidButton", button.Button, cg.Component)
CONF_BEEPER_ACTION = "beeper_action"
BEEPER_ACTIONS = {
"enable": "enable",
"disable": "disable",
"mute": "mute",
"test": "test"
}
CONFIG_SCHEMA = button.button_schema(UpsHidButton).extend({
cv.GenerateID(CONF_UPS_HID_ID): cv.use_id(UpsHidComponent),
cv.Required(CONF_BEEPER_ACTION): cv.enum(BEEPER_ACTIONS, lower=True),
}).extend(cv.COMPONENT_SCHEMA)
async def to_code(config):
var = await button.new_button(config)
await cg.register_component(var, config)
parent = await cg.get_variable(config[CONF_UPS_HID_ID])
cg.add(var.set_ups_hid_parent(parent))
cg.add(var.set_beeper_action(config[CONF_BEEPER_ACTION]))