# Converting wind direction

**URL:** <https://forums.losant.com/t/converting-wind-direction/490>\
**Category:** Help\
**Created:** [May 12, 2017, 3:14pm UTC](https://forums.losant.com/t/converting-wind-direction/490 "2017-05-12T15:14:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joshua\_Brown](https://avatars.discourse-cdn.com/v4/letter/j/f17d59/32.png) [@Joshua\_Brown](https://forums.losant.com/u/Joshua_Brown)\
**Post date:** [May 12, 2017, 3:14pm UTC](https://forums.losant.com/t/converting-wind-direction/490/1 "2017-05-12T15:14:59Z")

</div>

I’m trying to do some additional work with the darksky api tutorial and I wanted to convert the wind direction in degrees to cardinal direction using conditionals and setting the output to different strings. Could somebody help me out?

---

<div class="post-metadata">

**Author:** ![anaptfox](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/anaptfox/32/873_2.png) [@anaptfox](https://forums.losant.com/u/anaptfox)\
**Post date:** [May 12, 2017, 3:28pm UTC](https://forums.losant.com/t/converting-wind-direction/490/2 "2017-05-12T15:28:45Z")

</div>

Hi Joshua! I’d be happy to help. Could you give more detail on the problem you are having?

---

<div class="post-metadata">

**Author:** ![Joshua\_Brown](https://avatars.discourse-cdn.com/v4/letter/j/f17d59/32.png) [@Joshua\_Brown](https://forums.losant.com/u/Joshua_Brown)\
**Post date:** [May 12, 2017, 3:41pm UTC](https://forums.losant.com/t/converting-wind-direction/490/3 "2017-05-12T15:41:23Z")

</div>

I’m trying to convert the incoming wind direction in degrees taken from the darksky api data in the tutorial and turning it into a string to be displayed on the dashboard.

Example:

Winddirection : 182  
to be displayed as:  
Winddirection: South

---

<div class="post-metadata">

**Author:** ![anaptfox](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/anaptfox/32/873_2.png) [@anaptfox](https://forums.losant.com/u/anaptfox)\
**Post date:** [May 12, 2017, 3:57pm UTC](https://forums.losant.com/t/converting-wind-direction/490/4 "2017-05-12T15:57:36Z")

</div>

That make since. I guess I’m trying to figure out where you need help.

Do you have the Wind direction in degrees already displayed on a dashboard?

Or, Do you need help with the conversion in the workflow?

I did find this:

> <https://stackoverflow.com/questions/7490660/converting-wind-direction-in-angles-to-text-words/7490772#7490772>

Which may help.

---

<div class="post-metadata">

**Author:** ![Joshua\_Brown](https://avatars.discourse-cdn.com/v4/letter/j/f17d59/32.png) [@Joshua\_Brown](https://forums.losant.com/u/Joshua_Brown)\
**Post date:** [May 12, 2017, 3:59pm UTC](https://forums.losant.com/t/converting-wind-direction/490/5 "2017-05-12T15:59:29Z")

</div>

I understand how to do the coding, but I don’t know how to integrate code like that into the Losant workflow.

---

<div class="post-metadata">

**Author:** ![anaptfox](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/anaptfox/32/873_2.png) [@anaptfox](https://forums.losant.com/u/anaptfox)\
**Post date:** [May 12, 2017, 4:28pm UTC](https://forums.losant.com/t/converting-wind-direction/490/6 "2017-05-12T16:28:04Z")

</div>

Ah got it.

So, first, you’ll want to add `windDirection` as an attribute on your device. This is important because Dashboards graph/display attributes on the device’s state.

Then, you need to do the math. In this step, after you made the HTTP request, you updated the state on the device:

 ![](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/1X/f9dc366f18883d9428088fec96f4992b7a322a6e.png)

Before we update the state, we want to perform the conversion. You can insert a function node in between the HTTP and Device State node.

> **[Function Node](https://docs.losant.com/workflows/logic/function/)**
>
> Learn more about the Losant Function Node.

In the function node, you can update the value `{{ weather.body.currently. windBearing }}` to be the cardinal direction.

Then, you’ll update the new attribute you created using the Device State Node.
