Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
HomeAssistant
Core
Commits
beac69ad
Commit
beac69ad
authored
9 years ago
by
Robbie Trencheny
Browse files
Options
Downloads
Patches
Plain Diff
Final clean up, flake8, pylint, change a variable name, remove unnecessary imports
parent
c33c2c01
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
homeassistant/components/http.py
+6
-3
6 additions, 3 deletions
homeassistant/components/http.py
homeassistant/components/zeroconf.py
+22
-23
22 additions, 23 deletions
homeassistant/components/zeroconf.py
with
28 additions
and
26 deletions
homeassistant/components/http.py
+
6
−
3
View file @
beac69ad
...
...
@@ -7,7 +7,6 @@ https://home-assistant.io/developers/api/
import
gzip
import
json
import
logging
import
socket
import
ssl
import
threading
import
time
...
...
@@ -28,7 +27,7 @@ from homeassistant.const import (
HTTP_HEADER_CONTENT_LENGTH
,
HTTP_HEADER_CONTENT_TYPE
,
HTTP_HEADER_EXPIRES
,
HTTP_HEADER_HA_AUTH
,
HTTP_HEADER_VARY
,
HTTP_METHOD_NOT_ALLOWED
,
HTTP_NOT_FOUND
,
HTTP_OK
,
HTTP_UNAUTHORIZED
,
HTTP_UNPROCESSABLE_ENTITY
,
SERVER_PORT
,
__version__
)
SERVER_PORT
)
DOMAIN
=
"
http
"
...
...
@@ -105,8 +104,12 @@ class HomeAssistantHTTPServer(ThreadingMixIn, HTTPServer):
self
.
paths
=
[]
self
.
sessions
=
SessionStore
()
self
.
protocol
=
'
https
'
if
ssl_certificate
is
not
None
else
'
http
'
if
server_address
[
0
]
==
'
0.0.0.0
'
:
self
.
routable_address
=
util
.
get_local_ip
()
else
:
self
.
routable_address
=
server_address
[
0
]
self
.
base_url
=
"
{}://{}:{}
"
.
format
(
self
.
protocol
,
util
.
get_local_ip
()
,
self
.
routable_address
,
self
.
server_address
[
1
])
# We will lazy init this one if needed
...
...
This diff is collapsed.
Click to expand it.
homeassistant/components/zeroconf.py
+
22
−
23
View file @
beac69ad
"""
This module exposes Home Assistant via Zeroconf, also sometimes known as
Bonjour, Rendezvous, Avahi or Multicast DNS (mDNS).
This module exposes Home Assistant via Zeroconf.
Zeroconf is also known as Bonjour, Avahi or Multicast DNS (mDNS).
For more details about Zeroconf, please refer to the documentation at
https://home-assistant.io/components/zeroconf/
...
...
@@ -8,10 +9,7 @@ https://home-assistant.io/components/zeroconf/
import
logging
import
socket
from
homeassistant.const
import
(
EVENT_HOMEASSISTANT_START
,
EVENT_HOMEASSISTANT_STOP
,
__version__
)
import
homeassistant.util
as
util
from
homeassistant.const
import
(
EVENT_HOMEASSISTANT_STOP
,
__version__
)
REQUIREMENTS
=
[
"
zeroconf==0.17.5
"
]
...
...
@@ -21,30 +19,31 @@ DOMAIN = "zeroconf"
ZEROCONF_TYPE
=
"
_home-assistant._tcp.local.
"
DEPENDENCIES
=
[
"
http
"
,
"
api
"
]
DEPENDENCIES
=
[
"
http
"
]
def
setup
(
hass
,
config
):
from
zeroconf
import
Zeroconf
,
ServiceInfo
def
setup
(
hass
,
config
):
"""
Set up Zeroconf and make Home Assistant discoverable.
"""
from
zeroconf
import
Zeroconf
,
ServiceInfo
zeroconf
=
Zeroconf
()
zeroconf
=
Zeroconf
()
zeroconf_name
=
"
{}.{}
"
.
format
(
hass
.
config
.
location_name
,
ZEROCONF_TYPE
)
zeroconf_name
=
"
{}.{}
"
.
format
(
hass
.
config
.
location_name
,
ZEROCONF_TYPE
)
params
=
{
"
version
"
:
__version__
,
"
base_url
"
:
hass
.
http
.
base_url
,
"
has_password
"
:
(
hass
.
http
.
api_password
!=
""
)}
params
=
{
"
version
"
:
__version__
,
"
base_url
"
:
hass
.
http
.
base_url
,
"
needs_auth
"
:
(
hass
.
http
.
api_password
!=
""
)}
info
=
ServiceInfo
(
ZEROCONF_TYPE
,
zeroconf_name
,
socket
.
inet_aton
(
util
.
get_local_ip
()
),
hass
.
http
.
server_address
[
1
],
0
,
0
,
params
)
info
=
ServiceInfo
(
ZEROCONF_TYPE
,
zeroconf_name
,
socket
.
inet_aton
(
hass
.
http
.
routable_address
),
hass
.
http
.
server_address
[
1
],
0
,
0
,
params
)
zeroconf
.
register_service
(
info
)
zeroconf
.
register_service
(
info
)
def
stop_zeroconf
(
event
):
"""
Stop Zeroconf.
"""
zeroconf
.
unregister_
all_
service
s
()
def
stop_zeroconf
(
event
):
"""
Stop Zeroconf.
"""
zeroconf
.
unregister_service
(
info
)
hass
.
bus
.
listen_once
(
EVENT_HOMEASSISTANT_STOP
,
stop_zeroconf
)
hass
.
bus
.
listen_once
(
EVENT_HOMEASSISTANT_STOP
,
stop_zeroconf
)
return
True
return
True
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment