Setting an attribute to a string containing a Unicode emoji results in device.currentValue of null

When setting an attribute to a string containing a Unicode emoji / extended character, reading device.currentValue(attribute) from the device code results in a null value.

Example:
sendEvent(name: "arrow", value: "↑")

later device code run:
device.currentValue("arrow") <<< this is always null

LE: I had a misspelled attribute name

Have you tried encoding it instead of copy and pasting it?

1 Like

How do you mean?

Thank you

Thank you for your reply. The attribute is defined as an enum and provides an array with the five arrows supported as strings. The device page shows the arrow alright, but the device code itself, upon trying to check if the value changed, always gets null as the currentValue. The event log also shows the attribute always changing to the same value.

nvm... found my issue :frowning:

@Field TREND_ARROWS = ["↑", "↘", "→", "↗", "↑"]
@Field TREND_MESSAGES = ["Rising rapidly", "Rising", "Steady", "Dropping", "Dropping rapidly"]


metadata {
  definition(name: "Freestyle Libre User", namespace: "ady624", author: "Adrian Caramaliu") {
    capability "Refresh"

    attribute "firstName", "string"
    attribute "lastName", "string"
    attribute "country", "string"
    attribute "sensorSerialNumber", "string"
    attribute "sensorActivated", "long"
    attribute "glucoseTargetLow", "int"
    attribute "glucoseTargetHigh", "int"
    attribute "glucoseTimestamp", "long"
    attribute "glucose", "int"
    attribute "glucoseTrend", "int"
    attribute "glucoseTrentArrow", "enum", TREND_ARROWS <<< MISSPELLED Trend as Trent GRRR
    attribute "glucoseTrendMessage", "enum", TREND_MESSAGES
}

  preferences {
  }
}

void update(user) {
    updateAttribute("firstName", user.firstName as String)
    updateAttribute("lastName", user.lastName as String)
    updateAttribute("country", user.country as String)
    updateAttribute("sensorSerialNumber", user.sensorSerialNumber as String)
    updateAttribute("sensorActivated", user.sensorActivated as long)
    updateAttribute("glucoseTargetLow", user.glucoseTargetLow as int)
    updateAttribute("glucoseTargetHigh", user.glucoseTargetHigh as int)
    updateAttribute("glucoseTimestamp", user.glucoseTimestamp as long)
    updateAttribute("glucose", user.glucose as int, "mg/dL")
    updateAttribute("glucoseTrend", user.glucoseTrend as int)
    updateAttribute("glucoseTrendArrow", getTrendArrow(user.glucoseTrend) as String)
    updateAttribute("glucoseTrendMessage", getTrendMessage(user.glucoseTrend) as String)
}

Thank you so much for your time!
Adrian

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.