d_sellers1

Simple Cycle Brightness

Nov 13th, 2021 (edited)
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var entity = "light.living_room1";
  2. var entity_group = "group.living_room";
  3.  
  4. var brightness = parseInt(global.get('homeassistant').homeAssistant.states[entity].attributes.brightness);
  5.  
  6. // Establish standard payload to be passed to service call node
  7. msg.payload = {domain: "light", service: "turn_on",
  8.     data: { entity_id: entity_group, }  };
  9.  
  10. if (brightness > 200) { new_brightness = 200 }
  11. else if (brightness > 150) {new_brightness = 150 }
  12. else if (brightness > 100) {new_brightness = 100 }
  13. else if (brightness > 50) {new_brightness = 50 }
  14. else {new_brightness = 255 }
  15.  
  16. node.status({text: "From: " + brightness + " To: " + new_brightness});
  17. msg.payload.data.brightness = new_brightness.toString();
  18.  
  19. return msg;
Advertisement
Add Comment
Please, Sign In to add comment