Skip to content

MQTT relay_state is published inverted (HTTP /device/relay reports correctly) #78

Description

@chochb

Device / version

  • Model: Shelly Wall Display XL (modelName: BLAKE, SAWD-3A1XE10EU2)
  • App version: 3.26157.2133
  • MQTT: enabled, HA auto-discovery on (device-based discovery)

Summary
The relay state published over MQTT (shellyelevatev2//relay_state) is inverted relative to the actual command and the physical relay. The HTTP API reports the state correctly, so the bug is isolated to the MQTT state-publishing path, not the relay logic itself.

Effect in Home Assistant
The auto-discovered switch is non-optimistic, so after a command it immediately receives the inverted state back and snaps back to the previous position. A single toggle never sticks; only a second toggle accidentally lines up.

Observed MQTT (command → reported state)

relay_command ON   → relay_state OFF
relay_command OFF  → relay_state ON

Consistent inversion across all toggles.

HTTP cross-check (correct)

> POST /device/relay {"num":0,"state":true}    → relay physically ON
> GET  /device/relay?num=0                      → {"success":true,"state":true}   # correct
> 
> POST /device/relay {"num":0,"state":false}   → relay physically OFF
> GET  /device/relay?num=0                      → {"success":true,"state":false}  # correct

HTTP command and readback both match the physical relay. Only the MQTT relay_state topic is wrong.

Expected
relay_state should publish the same logical value as the command / HTTP readback (ON→ON, OFF→OFF).

Workaround
Drive the relay via HTTP (rest_command → /device/relay) and treat the MQTT relay entity as a state source with inverted interpretation.

Likely location
Wherever the relay state is read/serialized for MQTT publishing — the value appears negated compared to the (correct) HTTP /device/relay handler.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions