1
0
mirror of https://github.com/esphome/esphome.git synced 2025-04-07 19:30:29 +01:00
Jesse Hills 8849443bf6
[update] Implement `update.perform action and update.is_available` condition (#7165)
* [update] Fix unimplemented yaml action/condition

* Add/update tests

---------

Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
2024-07-31 04:08:11 +00:00

24 lines
613 B
C++

#pragma once
#include "update_entity.h"
#include "esphome/core/automation.h"
namespace esphome {
namespace update {
template<typename... Ts> class PerformAction : public Action<Ts...>, public Parented<UpdateEntity> {
TEMPLATABLE_VALUE(bool, force)
public:
void play(Ts... x) override { this->parent_->perform(this->force_.value(x...)); }
};
template<typename... Ts> class IsAvailableCondition : public Condition<Ts...>, public Parented<UpdateEntity> {
public:
bool check(Ts... x) override { return this->parent_->state == UPDATE_STATE_AVAILABLE; }
};
} // namespace update
} // namespace esphome