Discovery problems
This commit is contained in:
@@ -790,16 +790,13 @@ def publish_discovery(client):
|
||||
|
||||
|
||||
def publish_state(client):
|
||||
states = {}
|
||||
for i, g in enumerate(gauge_objects):
|
||||
gt = gauge_topics[i]
|
||||
val = g.get()
|
||||
val_rounded = int(val * 10) / 10
|
||||
states[str(i)] = val_rounded
|
||||
info(f"pub G{i} state={val_rounded:.1f} step={g._current_step}")
|
||||
client.publish(gt["state"], f"{val_rounded:.1f}", retain=True)
|
||||
client.publish(gt["status"], "online", retain=True)
|
||||
client.publish(T_STATE, ujson.dumps(states), retain=True)
|
||||
info(f"pub G{i} get()={val} step={g._current_step}")
|
||||
s = str(val)
|
||||
client.publish(gt["state"], s)
|
||||
info(f"published {s}")
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -901,6 +898,7 @@ def main():
|
||||
direction = 1 if current_target > g._current_step else -1
|
||||
steps_to_move = current_target - g._current_step
|
||||
steps_to_move = max(-5, min(5, steps_to_move))
|
||||
info(f"G{i} tgt={gauge_targets[i]:.1f} cur_step={g._current_step} target_step={current_target} dir={direction} moving={steps_to_move}")
|
||||
for _ in range(abs(steps_to_move)):
|
||||
g.step(direction)
|
||||
moved_any = True
|
||||
|
||||
Reference in New Issue
Block a user