Skip to content
Snippets Groups Projects
Commit cdd57e5b authored by Erick Hitter's avatar Erick Hitter
Browse files

Simplify how configuration is read, allowing arbitrary states to trigger arbitrary responses

Allows one handler to encompass what the Dash SHM and Dash Home Assistant integrations required.

Breaking change, though, as configuration variables change
parent 4d6ad710
Branches
No related tags found
No related merge requests found
......@@ -92,14 +92,11 @@ function buttonActivated( mac ) {
var service = 'services/',
postBody = {};
if ( 'off' === body.state ) {
service += buttonConfig.on.entity + '/' + buttonConfig.on.entity_action;
postBody.entity_id = buttonConfig.on.entity_id;
} else if ( 'on' === body.state ) {
service += buttonConfig.off.entity + '/' + buttonConfig.off.entity_action;
postBody.entity_id = buttonConfig.off.entity_id;
if ( 'object' === typeof buttonConfig[ body.state ] ) {
service += buttonConfig[ body.state ].entity + '/' + buttonConfig[ body.state ].entity_action;
postBody.entity_id = buttonConfig[ body.state ].entity_id;
} else {
console.error( 'Unknown state: ' + body.state );
console.error( 'Unhandled state: ' + body.state );
return;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment