Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var entity = "light.living_room1";
- var entity_group = "group.living_room";
- var brightness = parseInt(global.get('homeassistant').homeAssistant.states[entity].attributes.brightness);
- // Establish standard payload to be passed to service call node
- msg.payload = {domain: "light", service: "turn_on",
- data: { entity_id: entity_group, } };
- if (brightness > 200) { new_brightness = 200 }
- else if (brightness > 150) {new_brightness = 150 }
- else if (brightness > 100) {new_brightness = 100 }
- else if (brightness > 50) {new_brightness = 50 }
- else {new_brightness = 255 }
- node.status({text: "From: " + brightness + " To: " + new_brightness});
- msg.payload.data.brightness = new_brightness.toString();
- return msg;
Advertisement
Add Comment
Please, Sign In to add comment