openhab / openhab1-addons

Add-ons for openHAB 1.x
Eclipse Public License 2.0
3.43k stars 1.7k forks source link

[MQTT] homeassistant binding ignores "payload_on"/"payload_off" directives #5782

Closed wildwiz closed 5 years ago

wildwiz commented 5 years ago

The MQTT binding successfully discovers the devices (via homeassistant discovery), properly reports them as online, but it then fails to control them.

Expected Behavior

Flipping an MQTT bound Item from PaperUI/Control should cause the appropriate MQTT message to be sent to the broker.

Current Behavior

Flipping an MQTT bound Item from PaperUI/Control causes the following WARNs in openhab.log. The MQTT message is actually sent, but with the wrong content.

Details

Configuration JSON of the discovered Thing attached to the Item (discovered with homeassistant discovery):

{"name":"sw1","platform":"mqtt","state_topic":"sw1/relay/0","command_topic":"sw1/relay/0/set","payload_on":"1","payload_off":"0","availability_topic":"sw1/status","payload_available":"1","payload_not_available":"0"}

note "payload_on":"1","payload_off":"0"

Warning registered in logs:

2019-02-05 21:22:14.710 [WARN ] [eneric.internal.generic.ChannelState] - Command '1' not supported by type 'OnOffValue': No enum constant org.eclipse.smarthome.core.library.types.OnOffType.1
2019-02-05 21:22:17.224 [WARN ] [eneric.internal.generic.ChannelState] - Command '0' not supported by type 'OnOffValue': No enum constant org.eclipse.smarthome.core.library.types.OnOffType.0

content in the MQTT message actually sent contains the text "true"/"false" rather than "1"/"0", which the device does not recognize.

Steps to Reproduce (for bugs)

Via Paper UI:

  1. Discover a Thing via homeassistant discovery from MQTT with discovered content as mentioned in JSON configuration.
  2. Link the Thing to an Item.
  3. Operate the Item flipping the switch on and off.
  4. Check the MQTT output carrying the wrong payload.

Additionally, I suspect that the capture of the actual state from MQTT is failing as well for similar reasons.

Environment

wildwiz commented 5 years ago

sorry, new to openhab, opened in the wrong project :)