Skip to content

[MKC-461] IoT Cloud CS Fixes #235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 16, 2022
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -192,44 +192,44 @@ For your convenience, IoT Cloud provides specialized types which are just wrappe
You can use them just like a normal variable of the wrapped type, since they support assignment and comparison operators.

| Type | Declaration | Wrapped data type |
| -------------------- | ---------------------------------------- | ------- |
| Acceleration | `CloudAcceleration variableName;` | `float` |
| Angle | `CloudAngle variableName;` | `float` |
| Area | `CloudArea variableName;` | `float` |
| Capacitance | `CloudCapacitance variableName;` | `float` |
| Color | `CloudColor variableName;` | `float` |
| Contact Sensor | `CloudContactSensor variableName;` | `bool` |
| Counter | `CloudCounter variableName;` | `int` |
| Data Rate | `CloudDataRate variableName;` | `float` |
| Electric Current | `CloudElectricCurrent variableName;` | `float` |
| Electric Potention | `CloudElectricPotention variableName;` | `float` |
| Electric Resistance | `CloudElectricResistance variableName;` | `float` |
| Energy | `CloudEnergy variableName;` | `float` |
| Flow Rate | `CloudFlowRate variableName;` | `float` |
| Force | `CloudForce variableName;` | `float` |
| Frequency | `CloudFrequency variableName;` | `float` |
| Heart Rate | `CloudHeartRate variableName;` | `float` |
| Information Content | `CloudInformationContent variableName;` | `int` |
| Length | `CloudLength variableName;` | `float` |
| Light | `CloudLight variableName;` | `bool` |
| Location | `CloudLocation variableName;` | `float` |
| Logarithmic Quantity | `CloudLogarithmicQuantity variableName;` | `float` |
| Luminance | `CloudLuminance variableName;` | `float` |
| Luminous Flux | `CloudLuminousFlux variableName;` | `float` |
| Luminous Intensity | `CloudLuminousIntensity variableName;` | `float` |
| Mass | `CloudMass variableName;` | `float` |
| Motion Sensor | `CloudMotionSensor variableName;` | `bool` |
| Percentage | `CloudPercentage variableName;` | `float` |
| Power | `CloudPower variableName;` | `float` |
| Pressure | `CloudPressure variableName;` | `float` |
| Relative Humidity | `CloudRelativeHumidity variableName;` | `float` |
| Smart Plug | `CloudSmartPlug variableName;` | `bool` |
| Switch | `CloudSwitch variableName;` | `bool` |
| CloudTemperature | `CloudTemperature variableName;` | `float` |
| Temperature Sensor | `CloudTemperatureSensor variableName;` | `float` |
| Time | `CloudTime variableName;` | `float` |
| Velocity | `CloudVelocity variableName;` | `float` |
| Volume | `CloudVolume variableName;` | `float` |
| -------------------- | ---------------------------------------- | ----------------- |
| Acceleration | `CloudAcceleration variableName;` | `float` |
| Angle | `CloudAngle variableName;` | `float` |
| Area | `CloudArea variableName;` | `float` |
| Capacitance | `CloudCapacitance variableName;` | `float` |
| Color | `CloudColor variableName;` | `float` |
| Contact Sensor | `CloudContactSensor variableName;` | `bool` |
| Counter | `CloudCounter variableName;` | `int` |
| Data Rate | `CloudDataRate variableName;` | `float` |
| Electric Current | `CloudElectricCurrent variableName;` | `float` |
| Electric Potention | `CloudElectricPotention variableName;` | `float` |
| Electric Resistance | `CloudElectricResistance variableName;` | `float` |
| Energy | `CloudEnergy variableName;` | `float` |
| Flow Rate | `CloudFlowRate variableName;` | `float` |
| Force | `CloudForce variableName;` | `float` |
| Frequency | `CloudFrequency variableName;` | `float` |
| Heart Rate | `CloudHeartRate variableName;` | `float` |
| Information Content | `CloudInformationContent variableName;` | `int` |
| Length | `CloudLength variableName;` | `float` |
| Light | `CloudLight variableName;` | `bool` |
| Location | `CloudLocation variableName;` | `float` |
| Logarithmic Quantity | `CloudLogarithmicQuantity variableName;` | `float` |
| Luminance | `CloudLuminance variableName;` | `float` |
| Luminous Flux | `CloudLuminousFlux variableName;` | `float` |
| Luminous Intensity | `CloudLuminousIntensity variableName;` | `float` |
| Mass | `CloudMass variableName;` | `float` |
| Motion Sensor | `CloudMotionSensor variableName;` | `bool` |
| Percentage | `CloudPercentage variableName;` | `float` |
| Power | `CloudPower variableName;` | `float` |
| Pressure | `CloudPressure variableName;` | `float` |
| Relative Humidity | `CloudRelativeHumidity variableName;` | `float` |
| Smart Plug | `CloudSmartPlug variableName;` | `bool` |
| Switch | `CloudSwitch variableName;` | `bool` |
| CloudTemperature | `CloudTemperature variableName;` | `float` |
| Temperature Sensor | `CloudTemperatureSensor variableName;` | `float` |
| Time | `CloudTime variableName;` | `float` |
| Velocity | `CloudVelocity variableName;` | `float` |
| Volume | `CloudVolume variableName;` | `float` |


### Complex Types
Expand All @@ -249,42 +249,80 @@ Declared as `CloudDimmedLight x;`

Declared as `CloudColoredLight x;`

| Property | Type | Read value | Set value |
| ----------| -------------------| -------------------------------| ------------------------------|
| Switch | `bool` | `x.getSwitch()` | `x.setSwitch()` |
| Hue | `float` (0-360) | `x.getHue()` | `x.setHue()` |
| Saturation| `float` (0-100) | `x.getSaturation()` | `x.setSaturation()` |
| Brightness| `float` (0-100) | `x.getBrightness()` | `x.setBrightness()` |
| Property | Type | Read value | Set value |
| ---------- | --------------- | ------------------- | ------------------- |
| Switch | `bool` | `x.getSwitch()` | `x.setSwitch()` |
| Hue | `float` (0-360) | `x.getHue()` | `x.setHue()` |
| Saturation | `float` (0-100) | `x.getSaturation()` | `x.setSaturation()` |
| Brightness | `float` (0-100) | `x.getBrightness()` | `x.setBrightness()` |

#### CloudColor

Declared as `CloudColor x;`
Declared as `CloudColor x;`.

To read the Color values, we can use the following method `Color colorValues = x.getValue();`. This will assign the hue, saturation, and brightness values to the `colorValues` variable.

To read the Color values, we can use the following method `Color colorValues = x.getValue();`. This will assign the hue, saturation, and brightness values to the colorValues variable. If we want too access the values individually we can use `Serial.println(colorValues.hue)`, `Serial.println(colorValues.sat)`, and `Serial.println(colorValues.bri)`.
| Property | Type | Read value | Set value |
| ---------- | ------- | ----------------- | -------------------------------------- |
| Hue | `float` | `colorValues.hue` | `x = Color(hue,saturation,brightness)` |
| Saturation | `float` | `colorValues.sat` | `x = Color(hue,saturation,brightness)` |
| Brightness | `float` | `colorValues.bri` | `x = Color(hue,saturation,brightness)` |

To set the color, we can assign the CloudColor variable directly to float variables `x = {hue,saturation,brightness}`, or using the method ` x = Color(hue,saturation,brightness)`.

#### CloudLocation

Declared as `CloudLocation x;`
Declared as `CloudLocation x;`.

To read the location values, we can use the following method `Location coordinates = x.getValue();`. This will assign the longitude and latitude values to the coordinates variable. If we want too access the values individually we can use `Serial.println(coordinates.lat)` and `Serial.println(coordinates.lat)`.
To read the location values, we can use the following method `Location coordinates = x.getValue();`. This will assign the longitude and latitude values to the coordinates variable. If we want too access the values individually we can use `Serial.println(coordinates.lat)` and `Serial.println(coordinates.lon)`.

To set the coordinates, we can assign the CloudLocation variable directly to float variables `x = {latitude, longitude}`, or using the method ` x = Location(latitude, longitude)`.
| Property | Type | Read value | Set value |
| --------- | ------- | ----------------- | --------------------------- |
| Latitude | `float` | `coordinates.lat` | This variable is ready only |
| Longitude | `float` | `coordinates.lon` | This variable is ready only |

#### Television

Declared as `CloudTelevision x;`

| Property | Type | Read Value | Set value |
| -----------------| ---------------------------------------------------------------------------------------| -------------------------| -------------------------|
| Switch | `bool` | `x.getSwitch()` | `x.setSwitch()` |
| Volume | `int`(0-100) | `x.getVolume()` | `x.setVolume()` |
| Mute | `bool` | `x.getMute()` | `x.setMute()` |
| PlaybackCommands | `PlaybackCommands` (FastForward, Next, Pause, Play, Previous, Rewind, StartOver, Stop) | `x.getPlaybackCommand()` | `x.setPlaybackCommand()` |
| Input | `InputValue` ([Up to 60 values](https://github.com/arduino-libraries/ArduinoIoTCloud/blob/master/src/property/types/automation/CloudTelevision.h) such as HDMI1, HDMI2, DVD, GAME...etc.) | `x.getInput()` | `x.setInput()` |
| Channel | `int` | `x.getChannel()` | `x.setChannel()` |
| Property | Type | Read Value | Set value |
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------ | ------------------------ |
| Switch | `bool` | `x.getSwitch()` | `x.setSwitch()` |
| Volume | `int`(0-100) | `x.getVolume()` | `x.setVolume()` |
| Mute | `bool` | `x.getMute()` | `x.setMute()` |
| PlaybackCommands | `PlaybackCommands` (FastForward, Next, Pause, Play, Previous, Rewind, StartOver, Stop) | `x.getPlaybackCommand()` | `x.setPlaybackCommand()` |
| Input | `InputValue` ([Up to 60 values](https://github.com/arduino-libraries/ArduinoIoTCloud/blob/master/src/property/types/automation/CloudTelevision.h) such as HDMI1, HDMI2, DVD, GAME...etc.) | `x.getInput()` | `x.setInput()` |
| Channel | `int` | `x.getChannel()` | `x.setChannel()` |


### Utilities

The following utilities are available using any IoT Cloud sketch.

#### Check Connection Status

To check connection to the cloud, use:

```arduino
ArduinoCloud.connected()
```

This will return in an `int` format:
- `0` (not connected)
- `1` (connected).

#### Get Local Time (Unix)

To check local time, use:

```arduino
ArduinoCloud.getLocalTime()
```

This will return in a `long` format:
- Epoch Unix time stamp. Example: `1652442415`.

***This utility can be used together with the `CloudTime` variable and the `Time Picker` widget.***

### Examples

Expand Down