Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
dash-button-home-assistant-controller
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open-source
dash-button-home-assistant-controller
Commits
51a76baa
Verified
Commit
51a76baa
authored
8 years ago
by
Erick Hitter
Browse files
Options
Downloads
Patches
Plain Diff
More customization
parent
3a3c1e8e
Branches
master
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
config-sample.json
+4
-3
4 additions, 3 deletions
config-sample.json
index.js
+5
-5
5 additions, 5 deletions
index.js
with
9 additions
and
8 deletions
config-sample.json
+
4
−
3
View file @
51a76baa
...
...
@@ -9,16 +9,17 @@
"mac"
:
""
,
"label"
:
""
,
"status"
:
{
"entity"
:
""
,
"entity_id"
:
""
},
"on"
:
{
"entity"
:
""
,
"entity_id"
:
""
"entity_id"
:
""
,
"entity_action"
:
""
},
"off"
:
{
"entity"
:
""
,
"entity_id"
:
""
"entity_id"
:
""
,
"entity_action"
:
""
}
}
}
...
...
This diff is collapsed.
Click to expand it.
index.js
+
5
−
5
View file @
51a76baa
...
...
@@ -40,7 +40,7 @@ function buttonActivated( mac ) {
'
x-ha-access
'
:
config
.
home_assistant_pass
}
};
console
.
log
(
req
);
// First, check the current status so we can toggle
request
(
req
,
function
(
err
,
res
,
body
)
{
// Handle error states
...
...
@@ -57,14 +57,14 @@ console.log( req );
// HA only deals with JSON
body
=
JSON
.
parse
(
body
);
var
service
=
null
,
postBody
=
{};
var
service
=
'
services/
'
,
postBody
=
{};
if
(
'
off
'
===
body
.
state
)
{
service
=
buttonConfig
.
on
.
entity
+
'
/
turn_
on
'
;
service
+
=
buttonConfig
.
on
.
entity
+
'
/
'
+
buttonConfig
.
on
.
entity_acti
on
;
postBody
.
entity_id
=
buttonConfig
.
on
.
entity_id
;
}
else
if
(
'
on
'
===
body
.
state
)
{
service
=
buttonConfig
.
off
.
entity
+
'
/
turn_off
'
;
service
+
=
buttonConfig
.
off
.
entity
+
'
/
'
+
buttonConfig
.
off
.
entity_action
;
postBody
.
entity_id
=
buttonConfig
.
off
.
entity_id
;
}
else
{
console
.
error
(
'
Unknown state:
'
+
body
.
state
);
...
...
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