Code Monkey home page Code Monkey logo

Comments (4)

OttoWinter avatar OttoWinter commented on June 30, 2024

Hmmm, haven't thought of that before - all the people I've shared this with privately group all devices per node. But I think you should be able to do something like app.set_name("home/living_room") because esphomelib doesn't really care much about the node name.

I will check this later today because maybe the WiFi hostname generation fails with such a name. But then one could also manually override the hostname on the WiFiComponent with set_hostname().

from esphome-core.

OttoWinter avatar OttoWinter commented on June 30, 2024

Oh, the name is included in the discovery topic (discovery_prefix/component_type/name/entity_id/config`) - so the "hack" would probably break discovery.

The thing is, I want to keep this library as simple as possible to use, but you're right, this functionality would probably be quite useful. Maybe a potential fix for this would be to have a separate MQTT prefix, that would by default be set to the name, but can be overridden. And then have some whitelisted chars for the discovery topic name. Do you have any suggestions for this?

from esphome-core.

fabaff avatar fabaff commented on June 30, 2024

I agree that things should be simple. Playing with app.set_name() was my first step just to make the same observation with the discovery topic as you did :-)

Unfortunately I have no real suggestion about the topics because almost everyone has it's own style. At some point in time the discovery topic in HA was extended to cover more ground (not only object_id but now we have also node_id). We simple use a regex to do some checking.

From my point of view is some flexibility needed because in a lot of cases you want to integrate a device into an existing environment and people will turn away if it's too limited. At the end of the day it's a simple trade-off between simplicity and usability.

from esphome-core.

OttoWinter avatar OttoWinter commented on June 30, 2024

Yes, you're completely right - and supporting these edge case (or in this case rather useful cases) is probably what really makes a library great . So I just added this functionality on the master branch and pushed an update. The way this can be done now is like this: First, set your name to anything you like (for example app.set_name("xyz");, then do the following:

auto *mqtt = app.init_mqtt(...);
mqtt->set_topic_prefix("home/living_room");

Thank you for reporting this!

from esphome-core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.