Integrating Olight Spheres in HA

I recently bought this nice Olight Sphere (OLIGHT Sphere C Luce Notturna a Sferico Light Sfera Luminosa a Bagliore Pieno 75 Lumen Luce Atmosfera Ricairabile Colorata Quotidiano Appuntamenti Lampada Campeggio Decorazione di Festa : Amazon.it: Illuminazione)

and was looking for a way to integrate it in HA. It should use a BLE Sig Mesh standard and I was able to add one to a Moes Tuya Bluetooth Gateway (https://www.aliexpress.com/item/1005005637088709.html) but only via Olight proprietary app and not with SmartLife/Tuya app.
I had to put the gateway in pairing mode, then add it to Olight app (same procedure as adding a Sphere…). After this you can control the light (with the app) via the gateway through WiFi.
Now if I could extract the local keys it should be possible to control the Spheres in HA with LocalTuya/TuyaLocal etc…

Any hint?

To answer my own question, this is how I managed to integrate it in HA.
Step 1 - Add Sphere to Bluetooth Gateway
I followed the instrucions in this video: https://youtu.be/iRx4gJucEPI

  1. Install and open Olight app from your app store
  2. Register an account (can be a disposable one, it will be handy later)
  3. Pair the Sphere with the app
  4. Pair the Bluetooth Gateway with the app
  5. Click on the Bluetooth Gateway icon within the app
  6. Click “Add device”, then “Associate Bluetooth devices”
  7. You should be able to select the previously paired Shpere

In order to verify that you actually associated your Sphere to the Gateway try to control it (from the gateway) with phone’s bluetooth disabled

Step 2 - Retrieve DeviceIDs and localKeys
This is a bit complex, I won’t be able to give a step by step guide for this (YMMV)…
I broadly followed the method used in this post Retrieve localkey for Tuya Based Devices Using Bluestacks and Frida.
I rooted a (relatively) old Android phone in order to be able to install and run frida server (see this Android | Frida • A world-class dynamic instrumentation toolkit).
Then I installed the Olight app on the rooted phone and used frida to trace and log, from a PC connected to the phone via USB and ADB, all significative strings

frida-trace -U --decorate -j '*!*encodeString*' -f com.olight.omall -o trace.out

This will open Olight app, I logged in and fetched from Tuya servers the previously registered devices, opened both of them and stopped the trace with ctrl^c
In file trace.out I was able to identify the Json strings with all the info of the two devices…
You will need nodeId for the Sphere and devId and localKey for the gateway (but save the other info, they may be handy in the future…).

Step 3 - Integrate with Home Assistant
I had to use a modified version of Localtya, the standard one from rospogrigio don’t support devices connected though hubs/gateways and Tuya Local from make-all didn’t worked.
This is the version that I used (note that this will overwrite rospogrigio’s localtuya):

Add the integration, then Add a new device: you will need to use devId, localKey and IP (the private one, you may need to recover this from your router…) from the Bluetooth Gateway and nodeId from the Sphere…
In order to streamline the configuration, this is the template I saved with all the entities, you need to save this in config/custom_components/localtuya/templates/sphere.yaml

- light:
    entity_category: None
    brightness: '3'
    brightness_lower: 10
    brightness_upper: 1000
    color_mode: '2'
    color_mode_set: '0'
    color: '5'
    color_temp_min_kelvin: 2700
    color_temp_max_kelvin: 6500
    color_temp_reverse: false
    scene: '102'
    scene_values:
      colour_1: Colorato
      colour_10: Farfalle
      colour_11: Flusso
      colour_12: Gradiente
      colour_13: Carosello
      colour_14: colour_14
      colour_15: Palla magica
      colour_16: Lilla
      colour_17: Tramonto
      colour_18: Vibrante
      colour_19: colour_19
      colour_2: Aurora
      colour_20: Luce rossa
      colour_21: Cielo blu
      colour_22: colour_22
      colour_23: colour_23
      colour_24: Raccolto
      colour_25: Fuoco fantasma
      colour_26: Zombie
      colour_27: colour_27
      colour_28: Viola fantasma
      colour_29: Natale
      colour_3: Fuochi d'artificio
      colour_30: Bastoncino di zucchero
      colour_31: Neve
      colour_4: Fontana
      colour_5: colour_5
      colour_6: Spirale
      colour_7: colour_7
      colour_8: Lampo rosso
      colour_9: Coriandoli
      flame: Fuoco
    music_mode: true
    friendly_name: ''
    id: '1'
    platform: light
    icon: ''
- sensor:
    friendly_name: Battery
    entity_category: diagnostic
    unit_of_measurement: '%'
    device_class: battery
    state_class: measurement
    id: '103'
    platform: sensor
    icon: ''
- number:
    friendly_name: Countdown
    entity_category: config
    min_value: 0.0
    max_value: 43200.0
    step_size: 1.0
    restore_on_reconnect: false
    is_passive_entity: false
    unit_of_measurement: s
    id: '7'
    platform: number
    icon: ''
- number:
    friendly_name: Countdown_2
    entity_category: config
    min_value: 0.0
    max_value: 43200.0
    step_size: 1.0
    restore_on_reconnect: false
    is_passive_entity: false
    unit_of_measurement: s
    id: '101'
    platform: number
    icon: ''

And now your Sphere should be under HA control… Sometime, when it becomes unavailable, I need to turn it on manually in order to get it back, don’t know why.

Hope it helps

2 Likes