Nanoleaf Lines used to display solar system production

The Nanoleaf Lines are some pretty cool LED wall art, wifi connected with a local API and a HA integration. For anyone who isn’t familiar with them, you can connect the lines in any layout you like and they stick on the wall.

I have an Enphase Envoy solar system monitor which also has a local API connected to HA. It includes whole-home electricity consumption tracking as well.

I set up a few template sensors to indicate whether I am currently producing more energy than consuming, and the total kWh produced today out of a target. I used a number slider helper to make a changeable target for solar production.

Then HA sets the Lines to one of 14 scenes - the stem of the flower is green, or blue, depending on if production exceeds current consumption. The flower petals light up from yellow to pink, one by one, with the solar production target for the day representing 6/6.

1 Like

I would love to see your code for this project! That is a rad idea and we are considering Nanoleaf. We already have the solar component.

Also, nice The Cheat avatar.

Thanks for recognizing the avatar! Sorry for the holiday related delay…

You can’t program the Lines segment by segment from HA (at least, when I set this up, you couldn’t), so you have to create various scenes to match the possible states. I named them things like “Green 16” and “Blue 36” to mean e.g. a green stem with 1/6 petals lit up. So I needed an automation to set the right scene at a given time.

I have a numeric input for the daily target of production that I can change around, but I leave it at roughly the max my system can produce, around 45 kwh.

I created two template sensors shown below. The first compares current production to consumption and is simply a true/false value. The second takes in the day’s solar production and compares it to the target, and outputs a value of 0 thru 6.

template:
   - sensor:
       - name: "Solar Production"
         unique_id: "solar_production_template"
         state: '{{ int(states("sensor.envoy_current_power_production")) > int(states("sensor.envoy_current_power_consumption")) }}'
         icon: mdi:weather-sunny
       - name: "Daily Achievement"
         unique_id: "solar_achievement_template"
         state: '{% if( int(states("sensor.envoy_today_s_energy_production"))
 > int(states("input_number.solar_target")) ) %}6{%
 elif( int(states("sensor.envoy_today_s_energy_production")) > int(states("input_number.solar_target"))*5/6) %}5{%
 elif( int(states("sensor.envoy_today_s_energy_production")) > int(states("input_number.solar_target"))*4/6) %}4{%
 elif( int(states("sensor.envoy_today_s_energy_production")) > int(states("input_number.solar_target"))*3/6) %}3{%
 elif( int(states("sensor.envoy_today_s_energy_production")) > int(states("input_number.solar_target"))*2/6) %}2{%
 elif( int(states("sensor.envoy_today_s_energy_production")) > int(states("input_number.solar_target"))*1/6) %}1{%
 else %}0{% endif %}'

Finally, I have a helper toggle called Solar Status Mode that I use automations to turn on at sunrise and off at sunset. I set other various scenes manually on the Lines at night. With solar status mode on, an automation tracks any change to the two template sensors, and triggers a script.

This is the automation that triggers the update script:

- id: '1637546180412'
  alias: Set Nanoleaf Lines to Solar Status
  description: ''
  trigger:
  - platform: state
    entity_id: sensor.daily_achievement
  - platform: state
    entity_id: sensor.solar_production
  condition:
  - condition: state
    entity_id: input_boolean.solar_status_mode
    state: 'on'
  action:
  - service: script.solar_status_setup
  mode: single

And here’s the script that assigns the right scene (Nanoleaf calls it a scene, in HA terms it’s an effect) to the Lines. It has a template that assembles the two sensor values from earlier into an effect name:

solar_status_setup:
  alias: Solar Status Update
  sequence:
  - service: light.turn_on
    target:
      entity_id: light.lines_bcbc
    data:
      effect: '{% if(is_state("sensor.solar_production", "True")) %}Green {% else
        %}Blue {% endif %}{{ states("sensor.daily_achievement") }}6'
  mode: single

Enjoy setting up the Lines, they are really cool looking. I have some Nanoleaf Shapes as well, which I like, but IMO the Lines are vastly superior. Let me know if you have questions about this code and post pictures if you get it working!

1 Like