diff --git a/index.js b/index.js
index a522baacf5bbb7ee246af439c4711699339b29c1..a402f1a82103fa1b0bd64300cbc6d96152ce0583 100644
--- a/index.js
+++ b/index.js
@@ -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;
         }