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
574de3b1
Commit
574de3b1
authored
9 years ago
by
Philip Lundrigan
Browse files
Options
Downloads
Patches
Plain Diff
Handle template error
To be more consistent with the other sensor implementations of templates
parent
4e6b01b0
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
homeassistant/components/sensor/arest.py
+10
-4
10 additions, 4 deletions
homeassistant/components/sensor/arest.py
with
10 additions
and
4 deletions
homeassistant/components/sensor/arest.py
+
10
−
4
View file @
574de3b1
...
@@ -13,6 +13,7 @@ import requests
...
@@ -13,6 +13,7 @@ import requests
from
homeassistant.const
import
ATTR_UNIT_OF_MEASUREMENT
,
CONF_VALUE_TEMPLATE
,
\
from
homeassistant.const
import
ATTR_UNIT_OF_MEASUREMENT
,
CONF_VALUE_TEMPLATE
,
\
DEVICE_DEFAULT_NAME
DEVICE_DEFAULT_NAME
from
homeassistant.exceptions
import
TemplateError
from
homeassistant.helpers.entity
import
Entity
from
homeassistant.helpers.entity
import
Entity
from
homeassistant.util
import
template
,
Throttle
from
homeassistant.util
import
template
,
Throttle
...
@@ -55,10 +56,15 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
...
@@ -55,10 +56,15 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
"""
Creates renderer based on variable_template value
"""
"""
Creates renderer based on variable_template value
"""
if
value_template
is
None
:
if
value_template
is
None
:
return
lambda
value
:
value
return
lambda
value
:
value
else
:
return
lambda
value
:
template
.
render
(
hass
,
def
_render
(
value
):
value_template
,
try
:
{
'
value
'
:
value
})
return
template
.
render
(
hass
,
value_template
,
{
'
value
'
:
value
})
except
TemplateError
:
_LOGGER
.
exception
(
'
Error parsing value
'
)
return
value
return
_render
dev
=
[]
dev
=
[]
...
...
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