Skip to content

Commit

Permalink
fixed wrong state for lock transitioning phase
Browse files Browse the repository at this point in the history
  • Loading branch information
hatl committed May 17, 2024
1 parent a22bf3b commit 3b60c8d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 10 additions & 0 deletions widget/source/hass/Entity.mc
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,15 @@ module Hass {
hidden var _mExt; // Is this entity loaded from settings?
hidden var _mSensorValue; // Custom state info text
hidden var _mSensorClass; // Device class for sensor
hidden var _mTransitioning; // For devices which have longer transitioning times from one stat to another (like some smart locks turning the key)

function initialize(entity) {
_mId = entity[:id];
_mName = entity[:name];
_mState = Entity.stringToState(entity[:state]);
_mExt = entity[:ext] == true;
_mSensorClass = entity[:sensorClass];
_mTransitioning = false;

if (_mId.find("scene.") != null) {
_mType = TYPE_SCENE;
Expand Down Expand Up @@ -174,6 +176,14 @@ module Hass {
_mSensorClass = newSensorClass;
}

function getTransitioning() {
return _mTransitioning;
}

function setTransitioning(newState) {
_mTransitioning = newState;
}

function isExternal() {
return _mExt;
}
Expand Down
10 changes: 8 additions & 2 deletions widget/source/hass/Hass.mc
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,14 @@ module Hass {
if (_entitiesToRefresh.size() > 0) {
var entity = _entitiesToRefresh[0];

_entitiesToRefresh.remove(entity);
if(entity.getTransitioning()) {
entity.setTransitioning(false);
}
else {
_entitiesToRefresh.remove(entity);

refreshEntity(entity, Utils.method(Hass, :_refreshPendingEntities));
refreshEntity(entity, Utils.method(Hass, :_refreshPendingEntities));
}
} else {
// We need to finalize with reading the scenes from settings again,
// so that the name config takes precedence
Expand Down Expand Up @@ -348,6 +353,7 @@ module Hass {
action = Client.ENTITY_ACTION_TURN_ON;
loadingText = "Running";
} else if (entity.getType() == Entity.TYPE_LOCK) {
entity.setTransitioning(true);
if (currentState == Entity.STATE_UNLOCKED) {
action = Client.ENTITY_ACTION_LOCK;
loadingText = "Locking";
Expand Down

0 comments on commit 3b60c8d

Please sign in to comment.