How to retrieve data via Alexa skills from a string/numeric item

Hi all, I recently setup with success the Amazon Alexa Smart Home Skill allowing me to control via voice recognition the switch items I defined in my items file.

That is, if I say “Alexa, turn on applique”, the switch item GF_LivingRoom_Light is set to ON, as Alexa recognize the label I assigned to each item

Switch    GF_LivingRoom_Door                     "Faretti ingresso"             <door>               (GF_LivingRoom, gDoor)   {alexa="PowerState"}
Switch    GF_LivingRoom_Light                    "Applique"                     <light>              (GF_LivingRoom, gLight)  {alexa="PowerState"}

Now, I have also String items normally used for feedback (e.g. measured global power consumption, heating running/idle,…) which are not set by user, but just by system.

String    G_Porch_PowerLoadValue        "Consumo  [%s W]"                   <batterylevel>  (G_Porch,gLoadVal) {alexa=???????}
String    G_Porch_PowerLoadAlarm        "Controllo carichi [%s]"            <siren>         (G_Porch,gLoadMonitor) {alexa=???????}

They appear like that

The question is: How can I retrieve the value of such items saying something like “Alexa, what is the consumption?” getting back from Alexa "I, consumption is five hundred and seventy-two watt"

I dig and dig in Amazon Alexa Smart Home Skill but could not find the way. :sleepy:
I can also replace String with Contact (or Number) if needed.

Thx everyone

For the G_Porch_PowerLoadValue item, you can use the RangeValue generic attribute to accomplish that to a certain degree as the unit of measure “Watts” is not supported by the Alexa API as of yet. The item type should be Number.

String    G_Porch_PowerLoadValue        "Consumo  [%s W]"                   <batterylevel>  (G_Porch,gLoadVal) {alexa="RangeValue" [nonControllable=true]}

As far as G_Porch_PowerLoadAlarm, if it’s a toggle on/off then use ToggleState. The item type should probably be Switch otherwise you will need to map the on/off state in metadata parameters.

Switch    G_Porch_PowerLoadAlarm        "Controllo carichi [%s]"            <siren>         (G_Porch,gLoadMonitor) {alexa="ToggleState" [nonControllable=true]}

OK, I updated my items in the following way:

for G_Porch_PowerLoadValue

Number  G_Porch_PowerLoadValue                  "Consumo [%.0f W]"              <energy>                (G_Porch,gLoadVal) {alexa="RangeValue" [nonControllable=true]}


  • item replaced from Switch to Number
  • string format changed from “Consumo [%s W]” to "Consumo [%.0f W]", else was bad formatted in opehHAB APP
  • added {alexa="RangeValue" [nonControllable=true]} according to your suggestion

Now I have G_Porch_PowerLoadValue listed in my Alexa

but I cannot still figure out what I need to ask to Alexa to retrieve back the current numeric value (no problem if it comes without unit of measurement).
If I ask *Alexa, what is the consumo" (means consumption), Alexa answers with a off-topic wikipedia definition.
What should I ask???

for G_Porch_PowerLoadAlarm if I replace String with Switch I obtain in openHAB app the usual toggle left/right switch, but in this case it would be unwanted/confusing as it shouldn’t be imposed by user (user has to just read its ON/OFF state)

If I solve the Alexa retrieving when item is Number (G_Porch_PowerLoadValue case), I could turn also G_Porch_PowerLoadAlarm to Number

You have to include the capability name, which defaults to “range value” since it’s a single endpoint. So you should be asking Alexa, what’s the consumption range value

You may want to set both functionalities as a group endpoint.

Group gPowerMeter "Power Meter" {alexa="Other"}
String    G_Porch_PowerLoadValue        "Consumo  [%s W]"                   <batterylevel>  (G_Porch,gLoadVal,gPowerMeter) {alexa="RangeValue" [capabilityNames="Consumption", nonControllable=true]}
Switch    G_Porch_PowerLoadAlarm        "Controllo carichi [%s]"            <siren>         (G_Porch,gLoadMonitor,gPowerMeter) {alexa="ToggleState" [capabilityNames="Load Control", nonControllable=true]}

Alexa, what is the power meter consumption?
Alexa, is the power meter load control on?

I unfortunately don’t understand what you are trying to say.

1 Like

Ok, if I say Alexa, what’s the consumption value, she answers with proper value, good!

But, after adding the group

Group gPowerMeter "Power Meter" {alexa="Altro"}
Number    G_Porch_PowerLoadValue        "Consumo  [%s W]"                   <batterylevel>  (G_Porch,gPowerMeter) {alexa="RangeValue" [capabilityNames="Consumo", nonControllable=true]}
String    G_Porch_PowerLoadAlarm        "Controllo carichi [%s]"            <siren>         (G_Porch,gPowerMeter) {alexa="ToggleState" [capabilityNames="Carico", nonControllable=true]


every question I ask, in any form, in any language, swapping the terms in any way, Alexa answers with wikipedia/off-topic content (not with the current value as before).

Have you any hint for retrieving status when items are in group? Else I must remove the group.


  • I need to use Number rather than String for G_Porch_PowerLoadValue else I lose the persistency graph in OH, not available when item is String
  • I need to use String rather than Switch for G_Porch_PowerLoadAlarm since this represents a STATUS (just feedback to the user)

In other words:
item is string (wanted, as user can only read it)

item is switch (not wanted/meaningless, as user could senseless toggle it)

That’s because you translated the Alexa metadata syntax. It should be {alexa="Other"}. Only user-defined label names can be translated.

You do know that you can configure a read-only Switch as a Text element in your sitemap page.

Text item=G_Porch_PowerLoadAlarm

If you intend to use a String for that item, then you will have to define the on/off mappings in the metadata parameters as indicated in the ToggleState documentation.

Group gPowerMeter "Potenza Misuratore" {alexa="Other"}
Number    G_Porch_PowerLoadValue        "Consumo  [%s W]"                   <batterylevel>  (G_Porch,gPowerMeter) {alexa="RangeValue" [capabilityNames="Consumo", nonControllable=true]}
String    G_Porch_PowerLoadAlarm        "Controllo carichi [%s]"            <siren>         (G_Porch,gPowerMeter) {alexa="ToggleState" [capabilityNames="Carico", nonControllable=true, ON="ON", OFF="OFF"]}

No, I really miss it and slowly realize my sitemap was all mixed up (too many copy-paste without deeper knowledge). Now I am fixing, also observing some example projects with their sitemap/items/rules