Skip to content

Commit 72aea03

Browse files
committed
fix(switch): drive RPiEasy outputs pin-free via taskvaluesetandrun
RPiEasy's /json does not expose a GPIO pin (unlike ESPEasy), so without a manually configured pin the only command tried was '<taskname>,<state>', which RPiEasy rejects with body 'False' — leaving RPiEasy switches dead unless the user hand-set a pin in options. Add 'taskvaluesetandrun,<taskname>,<valuename>,<state>' as a candidate. It is a RPiEasy built-in that sets the task value (driving the physical GPIO for output plugins) and runs the task, publishing the new state back over C013. Matched by exact task/value name via getTaskValueIndex and returns 'True' on success, which our existing success heuristic accepts. Tried after an explicit pin/template so ESPEasy (which learns its pin from /json) is unaffected.
1 parent 051557f commit 72aea03

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

custom_components/espeasy_p2p/switch.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,13 @@ async def _send_command(self, state: int) -> None:
211211
return
212212
task = self._coordinator.tasks.get((self._src_unit, self._task_index))
213213
task_name = (task.task_name if task else "") or f"task{self._task_index}"
214+
# Real (firmware-reported) task/value names, used for RPiEasy's
215+
# task-name-addressed command. Kept separate from the synthetic
216+
# "task<idx>" fallback above so we don't send a bogus name.
217+
real_task_name = task.task_name if task else ""
218+
value_name = ""
219+
if task and 0 <= self._value_index < len(task.value_names):
220+
value_name = task.value_names[self._value_index]
214221
gpio_pin = self._coordinator.get_gpio_pin(self._src_unit, task_name)
215222
template = self._coordinator.get_command_template(
216223
self._src_unit, task_name
@@ -223,6 +230,12 @@ async def _send_command(self, state: int) -> None:
223230
# - "gpio,<pin>,<state>" works for "Switch input"/"Output Helper"
224231
# tasks (the most common setup with relays/pumps). RPiEasy needs
225232
# this form: it answers <taskname>,<state> with body 'False'.
233+
# - "taskvaluesetandrun,<taskname>,<valuename>,<state>" is RPiEasy's
234+
# pin-free path: it sets the task value (driving the physical GPIO
235+
# for output plugins) and runs the task, which also publishes the
236+
# new state back over C013. This is what lets RPiEasy switches work
237+
# without the user having to hand-configure a GPIO pin, since
238+
# RPiEasy's /json does not expose the pin like ESPEasy does.
226239
# - "<taskname>,<state>" works for plugins like "Generic Dummy"
227240
# or "Output - PWM Motor" that respond to their task name.
228241
candidates: list[str] = []
@@ -231,6 +244,10 @@ async def _send_command(self, state: int) -> None:
231244
else:
232245
if gpio_pin is not None:
233246
candidates.append(f"gpio,{gpio_pin},{state}")
247+
if real_task_name and value_name:
248+
candidates.append(
249+
f"taskvaluesetandrun,{real_task_name},{value_name},{state}"
250+
)
234251
candidates.append(f"{task_name},{state}")
235252

236253
# Fire-and-forget P2P (RPiEasy accepts type-0; stock ESPEasy ignores).

0 commit comments

Comments
 (0)