# Thoughts on making Tags more first class citizens?

**URL:** <https://forum.genieacs.com/t/thoughts-on-making-tags-more-first-class-citizens/20>\
**Category:** Uncategorized\
**Created:** [January 17, 2019, 6:02pm UTC](https://forum.genieacs.com/t/thoughts-on-making-tags-more-first-class-citizens/20 "2019-01-17T18:02:52Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![akcoder](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/akcoder/32/11_2.png) [@akcoder](https://forum.genieacs.com/u/akcoder)\
**Post date:** [January 17, 2019, 6:02pm UTC](https://forum.genieacs.com/t/thoughts-on-making-tags-more-first-class-citizens/20/1 "2019-01-17T18:02:52Z")

</div>

I have a need to temporarily store arbitrary data about a CPE in GenieACS. Right now, I’m using Tags and splitting on the \_ in the tag name to encode multiple pieces of information. This works, but is kind of hacky. Now I also need to store the date of the event and so I end up with a really long and ugly Tag: Diag\_Download\_CAF\_2019-01-17T17-48-47Z

The pieces of information I need to store are event type (Diagnostic), diagnostic to be performed (Download), initiator of the diagnostic event (CAF) and the time the event was requested. I need to store the time so I can know when a diagnostic event has not completed in the expected time and do the appropriate action.

So I guess my request would be for either a better way to externally add structured information to a device instance, or maybe turning Tags into first class citizens in the data model by making them full objects with \_timestamp, \_type, \_value, etc.

-dan

---

<div class="post-metadata">

**Author:** ![zaidka](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/zaidka/32/9_2.png) [@zaidka](https://forum.genieacs.com/u/zaidka)\
**Post date:** [January 17, 2019, 8:15pm UTC](https://forum.genieacs.com/t/thoughts-on-making-tags-more-first-class-citizens/20/2 "2019-01-17T20:15:01Z")

</div>

Have you considered using a virtual parameter and encode that data as JSON?

---

<div class="post-metadata">

**Author:** ![akcoder](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/akcoder/32/11_2.png) [@akcoder](https://forum.genieacs.com/u/akcoder)\
**Post date:** [January 17, 2019, 8:27pm UTC](https://forum.genieacs.com/t/thoughts-on-making-tags-more-first-class-citizens/20/3 "2019-01-17T20:27:22Z")

</div>

I have, except as far as I know there is no way to create a v-param from an external system.

-dan

---

<div class="post-metadata">

**Author:** ![zaidka](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/zaidka/32/9_2.png) [@zaidka](https://forum.genieacs.com/u/zaidka)\
**Post date:** [January 18, 2019, 12:04am UTC](https://forum.genieacs.com/t/thoughts-on-making-tags-more-first-class-citizens/20/4 "2019-01-18T00:04:16Z")

</div>

Oh I see what you mean. You can edit an existing vparam through the API though. However it’ll require the device to be online.

---

<div class="post-metadata">

**Author:** ![akcoder](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/akcoder/32/11_2.png) [@akcoder](https://forum.genieacs.com/u/akcoder)\
**Post date:** [January 18, 2019, 12:15am UTC](https://forum.genieacs.com/t/thoughts-on-making-tags-more-first-class-citizens/20/5 "2019-01-18T00:15:39Z")

</div>

How do you change the value of an existing v-param via the API? Via SetParameterValue?

---

<div class="post-metadata">

**Author:** ![zaidka](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/zaidka/32/9_2.png) [@zaidka](https://forum.genieacs.com/u/zaidka)\
**Post date:** [January 18, 2019, 12:17am UTC](https://forum.genieacs.com/t/thoughts-on-making-tags-more-first-class-citizens/20/6 "2019-01-18T00:17:07Z")

</div>

Yes. The vparam needs to have writable: true for this to work.

---

<div class="post-metadata">

**Author:** ![akcoder](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/akcoder/32/11_2.png) [@akcoder](https://forum.genieacs.com/u/akcoder)\
**Post date:** [January 18, 2019, 1:05am UTC](https://forum.genieacs.com/t/thoughts-on-making-tags-more-first-class-citizens/20/7 "2019-01-18T01:05:03Z")

</div>

When I try to edit the value of the v-param from the gui I get a too many commit iterations error.

-dan

---

<div class="post-metadata">

**Author:** ![zaidka](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/zaidka/32/9_2.png) [@zaidka](https://forum.genieacs.com/u/zaidka)\
**Post date:** [January 18, 2019, 1:15am UTC](https://forum.genieacs.com/t/thoughts-on-making-tags-more-first-class-citizens/20/8 "2019-01-18T01:15:56Z")

</div>

Can you share your vparam script or a simpler version of it?

---

<div class="post-metadata">

**Author:** ![akcoder](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/akcoder/32/11_2.png) [@akcoder](https://forum.genieacs.com/u/akcoder)\
**Post date:** [January 18, 2019, 1:28am UTC](https://forum.genieacs.com/t/thoughts-on-making-tags-more-first-class-citizens/20/9 "2019-01-18T01:28:27Z")

</div>

return {\_writable:true, value:["", “xsd:string”]};

-dan

---

<div class="post-metadata">

**Author:** ![zaidka](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/zaidka/32/9_2.png) [@zaidka](https://forum.genieacs.com/u/zaidka)\
**Post date:** [January 18, 2019, 2:43am UTC](https://forum.genieacs.com/t/thoughts-on-making-tags-more-first-class-citizens/20/10 "2019-01-18T02:43:49Z")

</div>

Should be “writable”, not “\_writable”. In any case this isn’t what’s causing the fault. I’ll test this later.

---

<div class="post-metadata">

**Author:** ![akcoder](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/akcoder/32/11_2.png) [@akcoder](https://forum.genieacs.com/u/akcoder)\
**Post date:** [January 18, 2019, 2:56am UTC](https://forum.genieacs.com/t/thoughts-on-making-tags-more-first-class-citizens/20/11 "2019-01-18T02:56:25Z")

</div>

I tried writable. When I use just writable, I can’t change the value from the GUI. If I use \_writable I can.

-dan

---

<div class="post-metadata">

**Author:** ![zaidka](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/zaidka/32/9_2.png) [@zaidka](https://forum.genieacs.com/u/zaidka)\
**Post date:** [January 18, 2019, 4:04am UTC](https://forum.genieacs.com/t/thoughts-on-making-tags-more-first-class-citizens/20/12 "2019-01-18T04:04:35Z")

</div>

You got a fault because the returned value after the set operation doesn’t match the declared value, so it kept trying.

This works for me using latest master:

```javascript
// args: [{declare timestamps}, {declare values}, {current timestamps}, {current values}]
let value;
if ("value" in args[1]) // Set declared value
  value = args[1].value;
else if ("value" in args[3]) // No declared value, keep current value
  value = args[3].value;
else // No current value, use default
  value = ["default value", "xsd:string"];
return {"writable": true, "value": value};

```

---

<div class="post-metadata">

**Author:** ![akcoder](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/akcoder/32/11_2.png) [@akcoder](https://forum.genieacs.com/u/akcoder)\
**Post date:** [January 18, 2019, 9:32pm UTC](https://forum.genieacs.com/t/thoughts-on-making-tags-more-first-class-citizens/20/13 "2019-01-18T21:32:35Z")

</div>

Thank you for your help on this! This works perfectly!

---

<div class="post-metadata">

**Author:** ![zaidka](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/zaidka/32/9_2.png) [@zaidka](https://forum.genieacs.com/u/zaidka)\
**Post date:** [January 19, 2019, 12:03pm UTC](https://forum.genieacs.com/t/thoughts-on-making-tags-more-first-class-citizens/20/14 "2019-01-19T12:03:05Z")

</div>

You’re welcome! On your original suggestion, I have been thinking of replacing tags with a ‘metadata’ structure which is a flat key-value map. Just like tags, this structure can be updated through the API without having to reach the device. Does that sound like what you originally had in mind?

---

<div class="post-metadata">

**Author:** ![akcoder](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/akcoder/32/11_2.png) [@akcoder](https://forum.genieacs.com/u/akcoder)\
**Post date:** [January 19, 2019, 10:37pm UTC](https://forum.genieacs.com/t/thoughts-on-making-tags-more-first-class-citizens/20/15 "2019-01-19T22:37:34Z")

</div>

If the value can be complex, I.e. and object, then it would work perfectly for me.

Speaking of reaching the device, I notice when I update the vparam via SPV, genie does a connection request to the CPE, but doesn’t do any other actions on the device. Probably an artifact of how things work under the covers, and not a huge deal.

-dan

---

<div class="post-metadata">

**Author:** ![zaidka](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/zaidka/32/9_2.png) [@zaidka](https://forum.genieacs.com/u/zaidka)\
**Post date:** [January 20, 2019, 9:25am UTC](https://forum.genieacs.com/t/thoughts-on-making-tags-more-first-class-citizens/20/16 "2019-01-20T09:25:09Z")

</div>

> [@akcoder](#):
>
> If the value can be complex, I.e. and object, then it would work perfectly for me.

I’m thinking value is a simple string but you should be able to encode JSON objects.

> [@akcoder](#):
>
> Speaking of reaching the device, I notice when I update the vparam via SPV, genie does a connection request to the CPE, but doesn’t do any other actions on the device. Probably an artifact of how things work under the covers, and not a huge deal.

Yes, tasks can only run during a session.

---

<div class="post-metadata">

**Author:** ![akcoder](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/akcoder/32/11_2.png) [@akcoder](https://forum.genieacs.com/u/akcoder)\
**Post date:** [January 21, 2019, 8:13pm UTC](https://forum.genieacs.com/t/thoughts-on-making-tags-more-first-class-citizens/20/17 "2019-01-21T20:13:26Z")

</div>

> [@zaidka](#):
>
> I’m thinking value is a simple string but you should be able to encode JSON objects.

The more I think about this, while JSON would work, it create a lot of extra work from the perspective that I then have to manage the entire JSON payload. I.e., instead of doing a deleteObject for some sub-item (Metadata.Diagnostics.DSL.Line1), I would have to manage all of that in my app, and make sure I don’t collide with another session (i.e., read all of the Metadata.Diagnostics data in, decode the JSON, add/delete/modify anything I need to, then do a SPF).

I don’t know how difficult it would be to make the Metadata structure be able to complex object (much like the rest of the TR-069 data model), but if its not a lot of work, that would be my preference.

-dan

---

<div class="post-metadata">

**Author:** ![zaidka](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/zaidka/32/9_2.png) [@zaidka](https://forum.genieacs.com/u/zaidka)\
**Post date:** [January 29, 2019, 6:41am UTC](https://forum.genieacs.com/t/thoughts-on-making-tags-more-first-class-citizens/20/18 "2019-01-29T06:41:13Z")

</div>

It sounds like you’d be better off storing that in its own database and integrate using an extension. Because even if this metadata idea comes to fruition it’ll probably be a simple key-value map.
