feature-requests icon indicating copy to clipboard operation
feature-requests copied to clipboard

Warn name less components when internal is not set to true

Open glmnet opened this issue 5 years ago • 13 comments

Describe the problem you have/What new integration you would like People often creates components, they set them an id but they set no name then the component does not show up on HA nor mqtt and they don't know why. ESPHome implicitly sets those components as internal: true

I suggest:

  • make name optional only if internal is set to true, or
  • write a warning in the compiler if the name is not set and the component is not marked explicitly as internal

Please describe your use case for this integration and alternatives you've tried:

Additional context I've seen this issue in several places already.

https://github.com/esphome/esphome-docs/pull/486

https://github.com/esphome/issues/issues/942

glmnet avatar Feb 13 '20 14:02 glmnet

I think Otto specifically wanted to make internal implicit if things are unnamed. If anything I think we need a docs update rather than compile time warnings.

brandond avatar Mar 12 '20 20:03 brandond

Another option would be using id suffixed with _ like we do in code. Those won’t get the warning if internal true is not explicit

glmnet avatar Apr 25 '20 20:04 glmnet

I think a good solution is to make name compulsory if internal is set to false or undefined. Then we could add to the docs:

**name** (**Required** unless internal=true, string): The name of the sensor.

That way we prevent unnamed sensors.

Does the automatic 'unnamed implies internal' help besides making yaml files shorter?

Currently the documentation is suggesting that name is compulsory, meaning people (inc me) are creating external entities, then adding the internal=true to stop them from filling up HA with unnecessary entities. The doc should not say it's compulsory when it isn't.

davet2001 avatar Nov 24 '21 12:11 davet2001

It's specified in the docs at the internal configuration parameter:

  • id (Optional, string): Manually specify the ID for code generation. At least one of id and name must be specified.
  • name (Optional, string): The name for the sensor. At least one of id and name must be specified.
  • internal (Optional, boolean): Mark this component as internal. Internal components will not be exposed to the frontend (like Home Assistant). Only specifying an id without a name will implicitly set this to true.

nagyrobi avatar Jul 06 '22 11:07 nagyrobi

Yes, the documentation was updated making this clearer.

davet2001 avatar Jul 06 '22 11:07 davet2001

Indeed, but this feature request was not closed at that time.

nagyrobi avatar Jul 06 '22 11:07 nagyrobi

I don't think the feature request has been implemented.

The issue seems to be that users are unknowingly making sensors invisible to HA by not giving them a name.

The compiler output/warnings don't make this obvious.

The documentation is better now but the PR is requesting a warning (which would push people in the direction of explicitly defining whether they wanted a sensor to be internal or not).

davet2001 avatar Jul 06 '22 16:07 davet2001

I as the OP would highly appreciate @jesserockz and @ssieb input in this issue. I'm ok of it being closed, but they who are constantly answering questions at discord might really be aware weather this is useful or not.

glmnet avatar Jul 07 '22 00:07 glmnet

Btw I can really implement this myself. This is more a discussion which was kept open more than a request. I didn't implemented it because I didn't receive positive feedback.

glmnet avatar Jul 07 '22 00:07 glmnet

It does happen sometimes, but not that often. I would personally find it really annoying to have this warning. A general documentation page with tips like this would be useful. Or making sure every component describes the internal state. I think there are some that even describe it wrongly.

ssieb avatar Jul 07 '22 01:07 ssieb

I agree that this is something to be documented. I don't think forcing internal: true on everyones configs is the right approach.

jesserockz avatar Jul 07 '22 01:07 jesserockz

@jesserockz do you think that @glmnet's original PR against the docs https://github.com/esphome/esphome-docs/pull/1645 fulfills your requirement?

nagyrobi avatar Jul 07 '22 07:07 nagyrobi