Skip to content

MQTT thermostat: unquote payloads#11347

Closed
tinloaf wants to merge 1 commit into
home-assistant:devfrom
tinloaf:unquote_mqtt_thermostat
Closed

MQTT thermostat: unquote payloads#11347
tinloaf wants to merge 1 commit into
home-assistant:devfrom
tinloaf:unquote_mqtt_thermostat

Conversation

@tinloaf
Copy link
Copy Markdown
Contributor

@tinloaf tinloaf commented Dec 28, 2017

Description:

For payloads incoming via the *_STATE MQTT channels, we should unquote them if they are quoted.

This targets a (probably pretty common) use case of using the MQTT thermostat with another HA instance on the other side, and using mqtt_statestream for the *_STATE channels. Since #9872 , the values set from the "master" HA instance will be echoed in a quoted form on the state channels by the "slave" HA instance, causing errors. There is currently no easy way of circumventing this.

I thought about making unquoting optional, but I don't think we do any harm just always trying this. We always try setting both quoted and unquoted form, so nothing that works now should break. There are two scenarios where I could imagine trouble:

  • If someone has FOO as well as "FOO" in their operations_list (or any other list), this will break. But this seems like an insane configuration.
  • If some device wants "FOO" as their hold_mode, unquoting would turn this into FOO, since we don't have a list of values for the hold_mode, and thus always apply unquoting here.

Related issue (if applicable): fixes parts of #10209

If the code does not interact with devices:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • Tests have been added to verify that the new code works.

Copy link
Copy Markdown
Member

@balloob balloob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a hack and confusing to our users. Will probably bite us in the future.

It's also not "Unquoting". The values are JSON encoded and should be decoded.

So we should either add a config option to treat incoming data as JSON instead of text or add value_template config option for each topic and allow the user to do this themselves.

@tinloaf
Copy link
Copy Markdown
Contributor Author

tinloaf commented Jan 12, 2018

I agree this was a hacky approach. So, then I'd vote for adding a json_decode switch. Adding an option for each topic makes the config option monster that the mqtt climate platform is worse, I think.

I'll get to it today, hopefully.

@tinloaf tinloaf mentioned this pull request Jan 13, 2018
4 tasks
@tinloaf
Copy link
Copy Markdown
Contributor Author

tinloaf commented Jan 13, 2018

I not only re-decided to go with templating, I also opened a new PR in #11623 to have a clean history.

@tinloaf tinloaf closed this Jan 13, 2018
@home-assistant home-assistant locked and limited conversation to collaborators May 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants