Skip to content
This repository has been archived by the owner on Aug 22, 2021. It is now read-only.

"mqtt_json" platform no longer supported by Home Assistant #51

Closed
donkawechico opened this issue Jan 25, 2019 · 19 comments
Closed

"mqtt_json" platform no longer supported by Home Assistant #51

donkawechico opened this issue Jan 25, 2019 · 19 comments
Assignees
Milestone

Comments

@donkawechico
Copy link
Contributor

AI-Light version: 0.4.1-dev
HA version: 0.86.2

As of HA 0.84, "mqtt_json" is no longer a valid platform:
home-assistant/core#18227

Since upgrading, I've been unable to use AILight via Home Assistant, and see tons of spam in my logs saying:
image

Since the error doesn't explicitly suggest AILight is the source of the error, I did a recursive grep for "mqtt_json" in my HA directory and found nothing. Looking through AILight code, however, I see this line, which suggests the platfprm is being set to mqtt_json for discovery purposes:
https://github.com/stelgenhof/AiLight/blob/80666ddca444b8eb529b02ea17770ff10ff5b5b3/src/light.ino

It's certainly possible that I'm misinterpreting things here, but it feels to me like AILight firmware isn't accommodating the new APi for mqtt lights.

Let me know if I can provide additional details.

@stelgenhof
Copy link
Owner

@donkawechico Thanks for letting me know about this. I haven't upgraded HA myself so, haven't seen it yet. Let me have a look.

@brahmafear
Copy link

brahmafear commented Jan 25, 2019 via email

@stelgenhof
Copy link
Owner

From what I can tell from reading the HA PR in question, indeed the mqtt_json is still accepted. So the change should be straightforward.

It will only mean that the AiLight firmware with this change will not work with earlier versions of HA (before 0.84).

@SurfingSpider
Copy link

I just did the same change it just needs new documentation.

So in home assistant instead of putting ......

  • platform: mqtt_json
    name: 'Master Bedroom'
    state_topic: 'AiLight-2'
    command_topic: 'AiLight-2/set'
    color_temp: true
    brightness: true
    rgb: true
    white_value: true
    effect: false
    optimistic: false

you put.....

  • platform: mqtt
    schema: json

    name: 'Master Bedroom'
    state_topic: 'AiLight-2'
    command_topic: 'AiLight-2/set'
    color_temp: true
    brightness: true
    rgb: true
    white_value: true
    effect: false
    optimistic: false

@stelgenhof
Copy link
Owner

@SurfingSpider The documentation needs to be changed, but also the firmware. For the HA auto discovery to work, the payload structure needs adjusting.

@donkawechico
Copy link
Contributor Author

Correct. It's the auto-discovery feature that seems to break with the latest. And all my bulbs are auto-discovered. I could add them all manually, but I have 12 bulbs and, well, I'd just really rather not :P

Thanks for looking into it @stelgenhof!

@stelgenhof
Copy link
Owner

@donkawechico As said, the change is simple but it will be a breaking change for those not running HA 0.84 yet with this update.

@donkawechico
Copy link
Contributor Author

Just curious -- does it necessarily need to break older versions? I'm envisioning something like LEGACY_PLATFORM = true in platform.io that switches the variable assignment in light.ino or something (I'm not familiar with the AiLight codebase so maybe that's all nonsense thinking).

I could try putting up a PR that makes that change, if that'd help. But if you already have a solution in the works, maybe not worth it?

@donkawechico
Copy link
Contributor Author

donkawechico commented Jan 28, 2019

@stelgenhof Went ahead and whipped up a PR that (maybe) would resolve this issue with new discovery syntax without breaking lights for users of older HA versions.

It builds locally, but I haven't had a chance to push it to an actual bulb for testing so I'm marking it as "explorational" only.

Could totally be a bad approach, but figured I'd at least give it a shot and see if it helps!

@stelgenhof
Copy link
Owner

@donkawechico Thanks! See my comment on the PR

@debsahu
Copy link

debsahu commented Feb 5, 2019

@stelgenhof See what we are doing here https://github.com/toblum/McLighting/blob/1578cafbf0aee2cbec9e5e1b76be3a6754072837/Arduino/McLighting/request_handlers.h#L1099

We have an issue open toblum/McLighting#327 to address on_command_type in discovery message.

@stelgenhof
Copy link
Owner

@debsahu Thanks for the update. Seems to me you are not following the specs :)

@stelgenhof
Copy link
Owner

@donkawechico Just made changes that enable the new syntax for Home Assistant 0.84 (or later) and an option for users that are still on Home Assistant 0.84 (or older).

Compiled/tested the code successfully on my side. I only don't have HA < 0.84 so wasn't able to test that. However, the code changes are pretty minimal so the chances of any issues are very slim.

Cheers! Sacha

@stelgenhof stelgenhof added this to the v0.6 milestone Feb 6, 2019
@stelgenhof stelgenhof self-assigned this Feb 6, 2019
@donkawechico
Copy link
Contributor Author

donkawechico commented Feb 11, 2019

Awesome! Thanks @stelgenhof!

Unrelated side-note, I work at a company under Microsoft, and at our recent hackathon, I presented a light-effects platform I've started that uses MQTT to generate effects on the bulb without having to store in flash. Presented to 100 or so folks and spoke a lot about your firmware -- even brought in a flashed bulb to show it off.

Just thought you might get a kick out of that :) Love these bulbs!

@stelgenhof
Copy link
Owner

@donkawechico Thanks! That's so nice to hear :) Hope the audience enjoyed it.

Cheers! Sacha

@stelgenhof
Copy link
Owner

@donkawechico Would you perhaps mind sharing an example of the light effects you demonstrated at that hackathon? It maybe makes a good practical example for others to see how to use this firmware :)

Cheers! Sacha

@stelgenhof
Copy link
Owner

Fixed in the just released version 0.6.0.

@donkawechico
Copy link
Contributor Author

@donkawechico Would you perhaps mind sharing an example of the light effects you demonstrated at that hackathon?

Happy to, but the code is reeeeally bad :P I was trying too hard to architect something extensible and ended up with a structural mess. I'm going to get back to the project soon, but not sure I'm ready to put my name to it yet ;)

That said, the mess is located here: https://github.com/donkawechico/mqtt-light-effects. Feel free to dig around (and even make suggestions if you like), but please ask before linking it in the wiki.

@stelgenhof
Copy link
Owner

@donkawechico Thanks for sharing! Don't worry it is messy, still we can learn from it :) (No worries, I am not linking it anywhere).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants