Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add domain paramteter to wifi. #16

Merged
merged 3 commits into from May 21, 2018
Merged

Add domain paramteter to wifi. #16

merged 3 commits into from May 21, 2018

Conversation

HeMan
Copy link
Contributor

@HeMan HeMan commented May 21, 2018

  • To be able to do OTA updates on networks that doesn't use .local as
    local domain parameter domain is added to wifi section. It's currently
    only used for OTA.

- To be able to do OTA updates on networks that doesn't use .local as
  local domain parameter domain is added to wifi section. It's currently
  only used for OTA.
Copy link
Member

@OttoWinter OttoWinter left a comment

Choose a reason for hiding this comment

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

Great! Thanks, just a few comments

@@ -42,6 +42,7 @@ def validate_password(value):
vol.Optional(CONF_MANUAL_IP): AP_MANUAL_IP_SCHEMA,
}),
vol.Optional(CONF_HOSTNAME): cv.hostname,
vol.Optional(CONF_DOMAIN): cv.string,
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we include the . here? I think it would make the purpose of this variable a bit clearer.

Also, please set the default value here, and not in config[CONF_WIFI].get(CONF_DOMAIN, 'local').

    vol.Optional(CONF_DOMAIN, default="local"): cv.string,

    # later:
    domain = '.' + config[CONF_WIFI][CONF_DOMAIN]

(It helps keeping all defaults in a central place, if they're in all sorts of places it's hard to keep track of them)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I make it to work with and without the dot? So it accepts both
domain: '.local' and domain: 'local' and both renders to name.local?

Copy link
Member

Choose a reason for hiding this comment

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

I'm not really that big of a fan of these configuration options that do not strictly enforce values and try to auto-correct stuff. More of than not they end up confusing people and lead to a poor user experience.

A validator that checks if the strings starts with . and creates a vol.Invalid exception if it's invalid, would probably be better.

@@ -163,12 +163,13 @@ def upload_program(config, args, port):
_LOGGER.error("No serial port found and OTA not enabled. Can't upload!")
return -1

DOMAIN = '.' + config[CONF_WIFI].get(CONF_DOMAIN, 'local')
Copy link
Member

Choose a reason for hiding this comment

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

I think the python standard is to only have global constants with uppercase names.

(pylint isn't complaining about this because I shut the invalid-name lint off, because it produced many false positives with some recent updates to the C++ generation engine I did)

@OttoWinter OttoWinter merged commit ebb6d0d into esphome:master May 21, 2018
@esphome esphome locked and limited conversation to collaborators Jun 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants