> For the complete documentation index, see [llms.txt](https://sryvkver.gitbook.io/cobi.bike/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sryvkver.gitbook.io/cobi.bike/namespaces/hub/ambient-light-state.md).

# Ambient Light State

The current ambient light state.&#x20;

Based on the value measured by the hubs ambient light sensor, one of the categories is reported.

{% tabs %}
{% tab title="Typescript" %}

```typescript
const onAmbientLightStateChange = (value: AmbientLightState, timestamp?: Date) => {
    console.log(value, timestamp);
};

COBI.hub.ambientLightState.read(onAmbientLightStateChange); // Instantly get the current value
COBI.hub.ambientLightState.subscribe(onAmbientLightStateChange);
COBI.hub.ambientLightState.unsubscribe(onAmbientLightStateChange);
```

{% endtab %}

{% tab title="Javascript" %}

```javascript
const onAmbientLightStateChange = (value, timestamp) => {
    console.log(value, timestamp);
};

COBI.hub.ambientLightState.read(onAmbientLightStateChange); // Instantly get the current value
COBI.hub.ambientLightState.subscribe(onAmbientLightStateChange);
COBI.hub.ambientLightState.unsubscribe(onAmbientLightStateChange);
```

{% endtab %}
{% endtabs %}

{% content-ref url="/pages/MzBI5msh6bouCas2FNEw" %}
[AmbientLightState](/cobi.bike/entities/ambientlightstate.md)
{% endcontent-ref %}
