Update some logging

This commit is contained in:
Marius Muja 2024-01-18 14:45:50 -08:00
parent 79490cb6b0
commit 2d9e862f23
1 changed files with 14 additions and 14 deletions

View File

@ -95,13 +95,10 @@ namespace ratgdo {
void RATGDOComponent::received(const DoorState door_state)
{
ESP_LOGD(TAG, "Door state=%s", DoorState_to_string(door_state));
auto prev_door_state = *this->door_state;
ESP_LOGD(TAG, "Door state=%s", DoorState_to_string(door_state));
if (prev_door_state == door_state) {
return;
}
@ -192,48 +189,50 @@ namespace ratgdo {
void RATGDOComponent::received(const LearnState learn_state)
{
this->learn_state = learn_state;
ESP_LOGD(TAG, "Learn state=%s", LearnState_to_string(learn_state));
this->learn_state = learn_state;
}
void RATGDOComponent::received(const LightState light_state)
{
this->light_state = light_state;
ESP_LOGD(TAG, "Light state=%s", LightState_to_string(light_state));
this->light_state = light_state;
}
void RATGDOComponent::received(const LockState lock_state)
{
this->lock_state = lock_state;
ESP_LOGD(TAG, "Lock state=%s", LockState_to_string(lock_state));
this->lock_state = lock_state;
}
void RATGDOComponent::received(const ObstructionState obstruction_state)
{
if (this->obstruction_from_status_) {
ESP_LOGD(TAG, "Obstruction: state=%s", ObstructionState_to_string(*this->obstruction_state));
this->obstruction_state = obstruction_state;
// This isn't very fast to update, but its still better
// than nothing in the case the obstruction sensor is not
// wired up.
ESP_LOGD(TAG, "Obstruction: state=%s", ObstructionState_to_string(*this->obstruction_state));
}
}
void RATGDOComponent::received(const MotorState motor_state)
{
this->motor_state = motor_state;
ESP_LOGD(TAG, "Motor: state=%s", MotorState_to_string(*this->motor_state));
this->motor_state = motor_state;
}
void RATGDOComponent::received(const ButtonState button_state)
{
this->button_state = button_state;
ESP_LOGD(TAG, "Button state=%s", ButtonState_to_string(*this->button_state));
this->button_state = button_state;
}
void RATGDOComponent::received(const MotionState motion_state)
{
ESP_LOGD(TAG, "Motion: %s", MotionState_to_string(*this->motion_state));
this->motion_state = motion_state;
if (motion_state == MotionState::DETECTED) {
this->set_timeout("clear_motion", 3000, [=] {
@ -243,11 +242,14 @@ namespace ratgdo {
this->query_status();
}
}
ESP_LOGD(TAG, "Motion: %s", MotionState_to_string(*this->motion_state));
}
void RATGDOComponent::received(const LightAction light_action)
{
ESP_LOGD(TAG, "Light cmd=%s state=%s",
LightAction_to_string(light_action),
LightState_to_string(*this->light_state)
);
if (light_action == LightAction::OFF) {
this->light_state = LightState::OFF;
} else if (light_action == LightAction::ON) {
@ -255,10 +257,6 @@ namespace ratgdo {
} else if (light_action == LightAction::TOGGLE) {
this->light_state = light_state_toggle(*this->light_state);
}
ESP_LOGD(TAG, "Light cmd=%s state=%s",
LightAction_to_string(light_action),
LightState_to_string(*this->light_state)
);
}
void RATGDOComponent::received(const Openings openings)
@ -273,6 +271,8 @@ namespace ratgdo {
void RATGDOComponent::received(const PairedDeviceCount pdc)
{
ESP_LOGD(TAG, "Paired device count, kind=%s count=%d", PairedDevice_to_string(pdc.kind), pdc.count);
if (pdc.kind == PairedDevice::ALL) {
this->paired_total = pdc.count;
} else if (pdc.kind == PairedDevice::REMOTE) {