Advanced - Biorhythm

Function Introduction

  • Biorhythm: Bring the concept of natural light indoors through the device: Set a day to N moments (1≤N≤8), and set the corresponding brightness and color temperature. The device simulates the sun and automatically changes gradually according to these N moments in a day.
  • Tuya Human Lighting (Advanced Function): You can choose to locate the destination with precise latitude and longitude. After clicking Save Address, the longitude and latitude biorhythm function is turned on. After the function is turned on, the smart lighting device will automatically adjust its color temperature and brightness according to the time change to simulate the natural lighting conditions in the location area. The natural light environment can not only help balance the visual perception of the human eye, but also regulate hormone levels and biological clocks, thereby positively affecting the psychological and emotional health of the human body. Currently only a single device has this function, and the group is blocked. The number of channels only supports two and five channels

Biorhythm default mode

  • The default mode displays 4 nodes, WIFI protocol: 6 nodes are actually sent by dp, and sigMesh protocol: 4 nodes are sent.
  • The color and time of the sent data are not adjustable. Click the color wheel to gray it out. The default is the display function.

Biorhythm Natural Mode

  • The natural mode displays 3 nodes. When using the WIFI protocol: 5 nodes are actually sent. When using the sigMesh protocol: 3 nodes are sent. When entering [Natural Mode] for the first time, the default value is the same as [Default Mode]. There is a prompt above the color ring to select a city. Click to jump to the map page to select longitude and latitude. If the positioning function is not turned on on the phone, you need to be reminded to turn on the positioning function. When entering the map, if the GPS is not turned on, the default location is Beijing; if the GPS is turned on, the default location is the longitude and latitude of the phone's location. As long as the longitude and latitude have been selected, regardless of whether it is saved, the longitude and latitude selected last time will be remembered when entering [Natural Mode] next time. After selecting the longitude and latitude, the interface will obtain the three time nodes of sunrise, noon, and sunset according to the longitude and latitude, and supplement the remaining two hidden nodes based on these three nodes and send them down.

Biorhythm Custom Mode

  • The custom mode displays 4 nodes. When using the WIFI protocol: 6 nodes are actually sent down by dp, and 4 nodes are sent down by the sigMesh protocol.
  • Click the color circle below the time to customize the time and color temperature.

DP protocol

Default data:

0. Hidden nodes:
hour: 6,
minute: 0,
hue: 0,
saturation: 0,
value: 0,
brightness: 0,
temperature: 100,
1. Wake-up/sunrise
hour: 6,
minute: 30,
hue: 0,
saturation: 0,
value: 0,
brightness: 100,
temperature: 50,
2. Noon
hour: 11,
minute: 30,
hue: 0,
saturation: 0,
value: 0,
brightness: 100,
temperature: 100,
3. Sunset
hour: 17,
minute: 0,
hue: 0,
saturation: 0,
value: 0,
brightness: 70,
temperature: 50,
4. Hidden nodes
hour: 20,
minute: 30,
hue: 0,
saturation: 0,
value: 0,
brightness: 70,
temperature: 50,
5. Fall asleep
hour: 21,
minute: 0,
hue: 0,
saturation: 0,
value: 0,
brightness: 0,
temperature: 0,
Node 0 is half an hour earlier than Node 1 (get up)
Node 4 is half an hour earlier than Node 5 (fall asleep)
When the protocol is Wi-Fi, the hidden node needs to be sent, otherwise it is not used.

Specific protocol

  • Version 0x00
Version numberTask switchMode selectionDate settingNumber of nodesNode 1…….Node N
1byte:0x001byte1byte1byte1byte9byte9byte
  • Version 0x01
Version numberTask switchMode selectionDate settingParameter modeNumber of nodesNode 1…….Node N
1byte:0x011byte1byte1byte1byte: 0x01: Only BT 0x02: Only HSV 0x03: HSVBT1byte5-9byte 5byte/7byte/9byte5 - 9byte
  • Field description
FieldSerial numberLength (byte)Data representationDescription
Version number110x00: Initial version
Task switch210x00: Task closed 0x01: Task open
Mode selection310x00: Gradual change between two nodes 0x0F: Gradual change starts after reaching the node time, and the gradient completion time is the value of this field. The minimum allowed value is 15. For example: 0x0F means that the gradient is completed 15 minutes after the node time arrives
Date setting41Analyze the specific byte position, take effect on a certain day, the corresponding position is 1, see the fifth description below
Number of nodes510x01: 1 node. The allowed range is 1~8
Node parameterNode switch1The node switch priority is lower than the task switch. The node switch status is determined only when the task switch is turned on. 0x00: Node disabled, not effective 0x01: Node enabled, effective
Hour10x10: hex code, 16 points, the allowed range is 0~23.
Minute10x10: hex code, 16 minutes, the allowed range is 0~59
Hue20x03, 0x10: hex code. Big endian format, the first byte represents hundreds, the second byte represents tens, and the units. The actual value represents 316. The allowed range is 0~360.
Saturation percentage10x10: hex code, 16%; range allowed value 0~100
Brightness percentage10x10: hex code, 16%, range allowed value 1~100
Brightness percentage10x10: hex code, 16%, range allowed value 1~100
Color temperature percentage10x10: hex code, 16%. Range allowed value 0~100
  • The current biorhythm cannot select a date, the default is all 1
  • If all 0, it means single mode, which only takes effect once; otherwise, it is a cyclic mode, judging whether the corresponding bit is set to 1, and position 1 means it takes effect on the same day. For example, 0x42 means that the task takes effect on Saturday and Monday (note that the corresponding task switch must be turned on)
ReservedSaturdayFridayThursdayWednesdayTuesdayMondaySunday
bit7bit6bit5bit4bit3bit2bit1bit0

Biorhythm interface

How to develop

import RhythmCircle from '@ray-js/lamp-rhythm-circle';

export default function Home() {
  // Each time node 8> Number of nodes> 2
  const [rhythmNode, setRhythmNode] = useState([
    {
      activeColor: '#CE8040', // Gradient color corresponding to the node
      icon: res.icon1_colour, // Icon displayed corresponding to the node
      time: 390, // Time data corresponding to the node in minutes
      valid: true, // Whether the node can be dragged
    },
    {
      activeColor: '#CEECFE',
      icon: res.icon2_colour,
      time: 690,
      valid: true,
    },
    {
      activeColor: '#B3ABA8',
      icon: res.icon3_colour,
      time: 1020,
      valid: true,
    },
    {
      activeColor: '#1E272C',
      icon: res.icon4_colour,
      time: 1260,
      valid: true,
    },
  ]);

  const handleChange = v => {
    // When sliding, all current node data and the currently dragged node index will be returned
    const { value, activeIndex } = v;
    setRhythmNode(value);
  };

  const handleRelease = v => {};
  return (
    <View className={styles.view}>
      <DemoBlock title="Basic Usage">
        <Text className={styles.demoBlockTitleText}>Biological Rhythm</Text>
        // For detailed documents, see https://developer.tuya.com/material/library_oHEKLjj0/component?code=ComponentsTyLamp&subCode=LampRhythmCircle
        <RhythmsCircle
          // Outer circle radius
          innerRadius={107.5}
          // inner circle background
          radius={147.5}
          // minimum time interval of nodes
          timeOffset={30}
          // node data
          data={rhythmNode}
          // event triggered by move
          onChange={handleChange}
          // event triggered by end release
          onRelease={handleRelease}
        />
      </DemoBlock>
    </View>
  );
}

Notes

  • If Wi-Fi and zigbee devices are turned on when biorhythm is enabled, biorhythm needs to be downloaded again to make it effective