mirror of
https://github.com/esphome/esphome.git
synced 2026-10-20 04:56:48 +00:00
[seeed_mr60fda2] Use Apply buttons
This commit is contained in:
@@ -10,24 +10,22 @@ from esphome.const import (
|
||||
)
|
||||
from esphome.types import ConfigType
|
||||
|
||||
from .. import CONF_MR60FDA2_ID, MR60FDA2Component, mr60fda2_ns
|
||||
from .. import CONF_MR60FDA2_ID, MR60FDA2Component
|
||||
|
||||
DEPENDENCIES = ["seeed_mr60fda2"]
|
||||
|
||||
GetRadarParametersButton = mr60fda2_ns.class_("GetRadarParametersButton", button.Button)
|
||||
ResetRadarButton = mr60fda2_ns.class_("ResetRadarButton", button.Button)
|
||||
|
||||
CONF_GET_RADAR_PARAMETERS = "get_radar_parameters"
|
||||
|
||||
CONFIG_SCHEMA = {
|
||||
cv.GenerateID(CONF_MR60FDA2_ID): cv.use_id(MR60FDA2Component),
|
||||
cv.Optional(CONF_GET_RADAR_PARAMETERS): button.button_schema(
|
||||
GetRadarParametersButton,
|
||||
button.ApplyButton,
|
||||
device_class=DEVICE_CLASS_UPDATE,
|
||||
entity_category=ENTITY_CATEGORY_NONE,
|
||||
),
|
||||
cv.Optional(CONF_FACTORY_RESET): button.button_schema(
|
||||
ResetRadarButton,
|
||||
button.ApplyButton,
|
||||
device_class=DEVICE_CLASS_RESTART,
|
||||
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
||||
),
|
||||
@@ -37,5 +35,11 @@ CONFIG_SCHEMA = {
|
||||
async def to_code(config: ConfigType) -> None:
|
||||
hub = await cg.get_variable(config[CONF_MR60FDA2_ID])
|
||||
buttons = button.sub_buttons(config, parent=hub)
|
||||
await buttons(CONF_GET_RADAR_PARAMETERS, hub.set_get_radar_parameters_button)
|
||||
await buttons(CONF_FACTORY_RESET, hub.set_factory_reset_button)
|
||||
await buttons(
|
||||
CONF_GET_RADAR_PARAMETERS,
|
||||
hub.set_get_radar_parameters_button,
|
||||
apply="get_radar_parameters()",
|
||||
)
|
||||
await buttons(
|
||||
CONF_FACTORY_RESET, hub.set_factory_reset_button, apply="factory_reset()"
|
||||
)
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
#include "get_radar_parameters_button.h"
|
||||
|
||||
namespace esphome::seeed_mr60fda2 {
|
||||
|
||||
void GetRadarParametersButton::press_action() { this->parent_->get_radar_parameters(); }
|
||||
|
||||
} // namespace esphome::seeed_mr60fda2
|
||||
@@ -1,16 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/components/button/button.h"
|
||||
#include "../seeed_mr60fda2.h"
|
||||
|
||||
namespace esphome::seeed_mr60fda2 {
|
||||
|
||||
class GetRadarParametersButton final : public button::Button, public Parented<MR60FDA2Component> {
|
||||
public:
|
||||
GetRadarParametersButton() = default;
|
||||
|
||||
protected:
|
||||
void press_action() override;
|
||||
};
|
||||
|
||||
} // namespace esphome::seeed_mr60fda2
|
||||
@@ -1,7 +0,0 @@
|
||||
#include "reset_radar_button.h"
|
||||
|
||||
namespace esphome::seeed_mr60fda2 {
|
||||
|
||||
void ResetRadarButton::press_action() { this->parent_->factory_reset(); }
|
||||
|
||||
} // namespace esphome::seeed_mr60fda2
|
||||
@@ -1,16 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/components/button/button.h"
|
||||
#include "../seeed_mr60fda2.h"
|
||||
|
||||
namespace esphome::seeed_mr60fda2 {
|
||||
|
||||
class ResetRadarButton final : public button::Button, public Parented<MR60FDA2Component> {
|
||||
public:
|
||||
ResetRadarButton() = default;
|
||||
|
||||
protected:
|
||||
void press_action() override;
|
||||
};
|
||||
|
||||
} // namespace esphome::seeed_mr60fda2
|
||||
Reference in New Issue
Block a user