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