mirror of
https://github.com/esphome/esphome.git
synced 2024-11-21 22:48:10 +01:00
Added vol +/- control to dfplayer (#1856)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
parent
3b18f1b87f
commit
2b9350ce76
3 changed files with 42 additions and 0 deletions
|
@ -43,6 +43,8 @@ PreviousAction = dfplayer_ns.class_("PreviousAction", automation.Action)
|
|||
PlayFileAction = dfplayer_ns.class_("PlayFileAction", automation.Action)
|
||||
PlayFolderAction = dfplayer_ns.class_("PlayFolderAction", automation.Action)
|
||||
SetVolumeAction = dfplayer_ns.class_("SetVolumeAction", automation.Action)
|
||||
VolumeUpAction = dfplayer_ns.class_("VolumeUpAction", automation.Action)
|
||||
VolumeDownAction = dfplayer_ns.class_("VolumeDownAction", automation.Action)
|
||||
SetEqAction = dfplayer_ns.class_("SetEqAction", automation.Action)
|
||||
SleepAction = dfplayer_ns.class_("SleepAction", automation.Action)
|
||||
ResetAction = dfplayer_ns.class_("ResetAction", automation.Action)
|
||||
|
@ -201,6 +203,36 @@ async def dfplayer_set_volume_to_code(config, action_id, template_arg, args):
|
|||
return var
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
"dfplayer.volume_up",
|
||||
VolumeUpAction,
|
||||
cv.Schema(
|
||||
{
|
||||
cv.GenerateID(): cv.use_id(DFPlayer),
|
||||
}
|
||||
),
|
||||
)
|
||||
async def dfplayer_volume_up_to_code(config, action_id, template_arg, args):
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
"dfplayer.volume_down",
|
||||
VolumeDownAction,
|
||||
cv.Schema(
|
||||
{
|
||||
cv.GenerateID(): cv.use_id(DFPlayer),
|
||||
}
|
||||
),
|
||||
)
|
||||
async def dfplayer_volume_down_to_code(config, action_id, template_arg, args):
|
||||
var = cg.new_Pvariable(action_id, template_arg)
|
||||
await cg.register_parented(var, config[CONF_ID])
|
||||
return var
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
"dfplayer.set_eq",
|
||||
SetEqAction,
|
||||
|
|
|
@ -180,6 +180,8 @@ DFPLAYER_SIMPLE_ACTION(StartAction, start)
|
|||
DFPLAYER_SIMPLE_ACTION(PauseAction, pause)
|
||||
DFPLAYER_SIMPLE_ACTION(StopAction, stop)
|
||||
DFPLAYER_SIMPLE_ACTION(RandomAction, random)
|
||||
DFPLAYER_SIMPLE_ACTION(VolumeUpAction, volume_up)
|
||||
DFPLAYER_SIMPLE_ACTION(VolumeDownAction, volume_down)
|
||||
|
||||
template<typename... Ts> class DFPlayerIsPlayingCondition : public Condition<Ts...>, public Parented<DFPlayer> {
|
||||
public:
|
||||
|
|
|
@ -141,6 +141,14 @@ api:
|
|||
then:
|
||||
- dfplayer.random
|
||||
|
||||
- service: dfplayer_volume_up
|
||||
then:
|
||||
- dfplayer.volume_up
|
||||
|
||||
- service: dfplayer_volume_down
|
||||
then:
|
||||
- dfplayer.volume_down
|
||||
|
||||
- service: battery_level_percent
|
||||
variables:
|
||||
level_percent: int
|
||||
|
|
Loading…
Reference in a new issue