[APP][Pro] MQTT Hub - Community version

thermostat_mode doesn’t seem to be a valid capability

I did I by creating from a new device and added capability thermostat.
And also a lot of others like current, power, energy, text etc. After creating a new device. I could use the advanced topics to setup all my mqtt topics and used the example from post 116 to create a custom picker. Made me sweat whole day but it’s working so far.

So it’s working now?
The issue is this part:

  “capability”: “enum”,

You have to select a valid capability that offers the needed events.

“thermostat_mode”: {
  “capability”: “thermostat_mode”,
1 Like

Yes working great. Thanks!

I have a problem getting values updated. I connected a water meter to MQTT and i can see that it regulary reports values. When i create a new device, based on MQTT Hub it seems to work.. .but it never gets any update. At the moment i add a 2nd device for the exact same topic the new device gets the current value and the old stuck one gets updated too.

Thats a test… before updateing the left one showed 0.021 although there was other values reported to MQTT in between.

I was always watching MQTT with MQTT Explorer:

So im 100% sure, that there was updates which did not hit the device in Homey…

The devices are configured as sensor with this topic:

{
  "meter_water": {
    "capability": "meter_water",
    "stateTopic": "shellyplusuni-wasser-wm/watermeter/m3",
    "template": "{{ value | float }}",
    "displayName": "Water meter"
  }
}

What could be the reason, that these devices are working for a short time and then stop updateing the values from MQTT Server?

Can you check if MqttClient app is restarted in between?
In this case, the topic registration gets lost.

New test version 4.5.0:

  • adapted device settings for HomeyEnergy to new SDK options
  • possibility to add energy settings for home battery, ev charger and electric car.

For home battery:

  • set device option to “home battery”
  • add measure_power (positive/negative value dependent on charge/discharge).
  • add meter_power.charged and meter_power.discharged (you can use other names)
  • insert these capabilities in device settings into corresponding fields

For ev charger:

  • use measure_power and meter_power capability and set device option to “EV charger”.
  • If you are using V2G (vehicle top grid), you can set the meter power imported/exported capability

For electric car:

  • set device option to “electric car”
  • add measure_battery and ev_charging_state capability
1 Like

Im trying to add a device with multiple utilization and one temperature topic.

The device is sensor… i was a bit playing and came to that config:

{
  "measure_temperature": {
    "capability": "measure_temperature",
    "stateTopic": "home/system/temp",
    "valueTemplate": "{{value}}",
    "displayName": "CPU Temperature"
  },
  "measure_humidity": {
    "capability": "measure_humidity",
    "stateTopic": "home/system/cpu",
    "valueTemplate": "{{value}}",
    "displayName": "CPU Usage (%)"
  },
  "measure_luminance": {
    "capability": "measure_luminance",
    "stateTopic": "home/system/ram",
    "valueTemplate": "{{value}}",
    "displayName": "RAM Usage (%)"
  },
  "measure_pressure": {
    "capability": "measure_pressure",
    "stateTopic": "home/system/disk",
    "valueTemplate": "{{value}}",
    "displayName": "Disk Usage (%)"
  }
}

i had to use different types, because it seems only to accept one topic per type…

The result shows the correct values, but very strange:

Is there a way to show multiple utilization percentages with correct unit and a more generic icon?

You are using different standard capabilities. Using subcapabilities you can add a capability sevreal times.
And the app offers 2 custom capabilities: measure_number and measure_string for generic values.

Example:

{
  "measure_temperature": {
    "capability": "measure_temperature",
    "stateTopic": "home/system/temp",
    "valueTemplate": "{{value}}",
    "displayName": "CPU Temperature"
  },
  "measure_number.cpu": {
    "capability": "measure_number.cpu",
    "stateTopic": "home/system/cpu",
    "valueTemplate": "{{value}}",
    "displayName": "CPU Usage (%)",
    "unit": "%"
  },
  "measure_number.ram": {
    "capability": "measure_number.ram",
    "stateTopic": "home/system/ram",
    "valueTemplate": "{{value}}",
    "displayName": "RAM Usage (%)",
    "unit": "%"
  },
  "measure_number.disk": {
    "capability": "measure_number.disk",
    "stateTopic": "home/system/disk",
    "valueTemplate": "{{value}}",
    "displayName": "Disk Usage (%)",
    "unit": "%"
  }
}

The units should work, too (not tested). But the icons are predefined for the capability and not changeable.
I hope the example is working for you :slight_smile:

1 Like

Hello everyone. I have a smart meter device which provides regular readings via Local MQTT and I’d like to get them into Homey as a smart meter for use with the energy tab. Looks like I should be able to set up an MQTT device and configure accordingly. One thing I can’t see is how the value templates work.

My MQTT updates look like this:

glow/F1A8D1ED18E7/SENSOR/electricitymeter{
"electricitymeter": {
   "timestamp": "2022–06–01T16:32:16Z",
   "energy": {
     "export": {
       "cumulative": 0,
       "units": "kWh"
     },
     "import": {
       "cumulative": 201.95,
       "day": 1.05,
       "week": 0,
       "month": 0,
       "units": "kWh",
       "mpan": "9012224001407",
       "supplier": "— -",
       "price": {
         "unitrate": 0.20862,
         "standingcharge": 0.28403
       }
     }
  },
  "power": {
    "value": 0.063,
    "units": "kW"
  } 
 }
}

What would I enter as the value template in order to get at the power value (0.063 in my example)? Once I understand that I think I should be able to work out the others from there.

EDIT: In fact, I’m completely lost as to how to approach this. I was expecting to:

  1. Install this app
  2. Add a new MQTT device to represent the smart meter
  3. Configure it

But I’m stuck at step 2. The list of possible device types doesn’t seem to contain anything relevant. What should I choose?

Problem is your MQTT value. It’s not a simple number, it’s a complex JSON object.

So let’s start:

Create a MQTT device, the type is not relevant.

Add a capability (I’m using a test topic)

Use measure_power capability.

Add the topic (glow/F1A8D1ED18E7/SENSOR/electricitymeter for you)

Add the JSON path ($.electricitymeter.power.value)

Ready.

Now you get the value from the JSON element.

But it’s kW, and Homey wants W. And JSON path can’t be used with calculation (afaik).

So we are using JavaScript :slight_smile:

Go to device settings. Exchange the valueTemplate line with:
“valueTemplate”: “(value) => { return value.electricitymeter.power.value*1000}”,

:tada:

2 Likes

Thank you @RonnyW for detailed guidance. I will give this a go and see how I get on.

Thanks once again @RonnyW . I got stage 1 working - the device happily pulls through the current power value in W. But I still can’t get the valueTemplate working. When I make the change I think precisely as you describe above, when I hit ‘Save’ on the device settings, I get an error message “Invalid Value: class”.

Can you see what I am doing wrong?

In device settings is a field ‘device class’ where no value is set. Please select ‘sensor’ and save. This should work.

It seems I added class change without checking for blank value :sweat_smile:

Aha! That’s got it working now, thank you. I’ve also managed to get the cumulative energy usage showing up in meter_power and included that as a whole home energy meter in the energy tab now so working very nicely.

Thank you again for your help and efforts with this app

1 Like

Hi Ronny!

I have a little challenge.

I made this mode selector in a MQTT device and this works
Device class: Fan
Topics JSON:

{
    "fan_speed": {
    "capability": "fan_speed",
    "stateTopic": "itho/state",
    "setTopic": "itho/cmd",
    "valueTemplate": "round((value / 255) * 100)",
    "outputTemplate": "round((value / 100) * 255)",
    "displayName": "Fan Speed"
  },
"fan_mode": { 
    "capability": "fan_mode", 
    "stateTopic": "itho/ithostatus", 
    "setTopic": "itho/cmd", 
    "valueTemplate": "", 
    "outputTemplate": "", 
    "displayName": "Fan mode", 
    "values": [
  { "id": "low", "title": "Low" }, 
  { "id": "medium", "title": "Medium" }, 
  { "id": "high", "title": "High" } 
    ]
  }
}

This flow card works:

but when I add a second mode selector with capability, like, fan_mode.2, that card is not available anymore for adding to flows.

No big problem, so I picked this universal card below;
this doesn’t error, but doesn’t change the fan mode.
I’ve tried both fan_mode and Fan Mode, value names starting with and without capitals:

Device capabilities in developer tools:

Any ideas or comments on this? Doesn’t the card take string values maybe? (but it should error when that’s true).

2 remarks:

  1. Default flow cards are only created for main capabilities. If you add a subcapability, you won’t get these flow cards.

  2. You tried to set ‘High’. But you have to set ‘high’. That’s thd id of your enum value (case sensitive). ‘fan_mode’ as capability is right. That’s the capability ID.

Thanks for your prompt reply.

Ah, okay that’s clear.

Yea I tried both high / High.
So using the id is key!

Did you get the valueTempalate to work for your fan_mode? I think you want to set the capability based on Mqtt value?

Yea, when I tried capability fan_speed with value 0.5 the fan doesn’t respond either. My knowledge ends here :joy:
Any idea what to enter/change at the value or output templates?