MQTT Hub/Gateway

Just wanted to reply too, same issue here as @RonnyW describes here above… :frowning:

Finally, I found an example and figured it out, Jason Path is “SR04.Distance”.

1 Like

Hello,

I managed to install MQTT Broker on Homey, MQTT Client and MQTT Hub, and I used paho-mqtt · PyPI to create a simple MQTT client in python.

So far so good, I can see periodical updates of Homey state published on topic homey/system/info. But I don’t know which topic should I subscribe to see changes in device state.

I’m completely new to MQTT, so maybe I’m doing something wrong or even don’t understand the basics correctly… could I ask for a little guidance on how to see device state changes in my custom MQTT client?

I think the path is here?


.

If you intstall MQTT Explorer you can view all data passing by and discover what you’ll need.

Thank you! I knew I was missing some basics, I did 't know I should subscribe to all topics with a wildcard ‘homie/homey/#’.

1 Like

I just found your message, I would like to get on/off value using jsonPath, to convert them simply to True(On/Charging)/False(Off)…

{
  "onoff": {
    "capability": "onoff",
    "stateTopic": "vw-connect/0/VINVINVIN/charger/status/chargingStatusData/chargingState/content",
    "commandTopic": "vw-connect/0/VINVINVIN/remote/batterycharge",
    "valueTemplate": "",
    "outputTemplate": "",
    "displayName": "Charging"
  },
  "measure_battery": {
    "capability": "measure_battery",
    "stateTopic": "vw-connect/0/VINVINVIN/charger/status/batteryStatusData/stateOfCharge/content",
    "commandTopic": "",
    "valueTemplate": "",
    "outputTemplate": "",
    "displayName": "SoC"
  }
}

Is it achievable using jsonPath to put into outputTemplate something like :

{
  "value": [
 {
      "entry": "off", 
      "give": "false" 
 },
  { 
      "entry": "on", 
      "give": "true" 
  },
  { 
      "entry": "charging", 
      "give": "true" 
  }
  ]
}

…or I get it absolutely wrong ? Can someone help ?
Please note, as you can see, I’m NOT developer.

Custom capabilities or name/unit?

I’ve got the current electricity prices published to mqtt and I want that available in Homey as a sensor value. There does not seem to be a currency related capatibility in Homey. So I have to choose something else numeric. I’ve got it running using measure_voltage capability. But no matter what I set as displayName it still shows Spenning (Voltage in Norwegian) an V as unit. Is there any trick I can use to make it show something else than default name and unit? The correct would be unit “øre” and “Strømpris” where “Spenning” is shown.

image

Not that I know of.
See my ‘abuse’ of thermometers as MB indicators…

1 Like

How did you get this info to mqtt?

It’s not mqtt related, just as example we can’t change capabilities to custom ones.

How I got those RAM values, is done using Homeyscript.
I’ll be happy to share if you like.

Yes please, Aleta nice even though you can’t really do anything with it right?

Just for entertaining and informational purposes :wink:
Although it is possible to start a flow which reboots Homey if RAM is below X MB’s… But I like a warning better :wink:

// Get available SystemMemory values and write to variables/tags
mem = await Homey.system.getMemoryInfo( ); 
var array = []; var used = 0; 
var free = 0; var total = 0; 
var json_dict; for(var i in mem.types) 
array.push(mem.types [i]); 
array = array.sort((a, b) => { return (a.size > b.size) ? -1 : 1; }); 
json_dict = ""; for(var i in array){ used += array[i].size; array[i].size = Math.round(array[i].size /1000 /500)/2; json_dict += ''+array[i].name+': '+array[i].size+'MB'; 
if ( i<array.length-1) json_dict+=" || \n "; } 
json_dict += ""; free = ( mem.total - used ) / 1000 / 1000; 
used = used / 1000 / 1000; 
total = mem.total / 1000 / 1000; 
//
// Just for console testing purposes
//console.log(JSON.stringify(array)); 
//console.log(array); 
//console.log("Memory total: "+total.toFixed(2)); 
//console.log("Totals Apps: "+used.toFixed(2)); 
//console.log("Free: "+free.toFixed(2)); 
// console.log(json_dict); 
//
// Write total memory value to variable [memoryTotal]
await tag("memoryTotal", Math.round(total *10)/10 );
// Write used memory value to variable [memoryUsed]
await tag("memoryUsed", Math.round(used *10)/10 );
// Write free memory to variable [memoryFree]
await tag("memoryFree", Math.round(free *10)/10 ); 
// Write memory usage of Homey and all apps to variable [memoryAppList]
await tag("memoryAppList", json_dict ); 
return true;

Flows:

Flow 1


While HomeyScript tags aren’t shown in shared flows, a screenshot of THEN:

Screenshot from 2022-01-28 14-42-52

Flow 2

Screenshot from 2022-01-28 14-43-10

Flow 3

What I consider nice-to-have, when there’s no free RAM left: the overview of all memory users, from flow 3:

2 Likes

Be careful using the memory readings from Homey. I’ve seen a strange memory issue - homey core memory usage increases very fast and is not released. So it need a daily restart to solve this. That’s why I have deactivated this Flow/Homeyscript.

Thanks, but no issues so far. I must say I trigger the check flow only every 4mins.
This is my Homey system memory usage graph:

Hm, perhaps something changed with a firmware update.
I could reproduce a raising memory usage with each single call in a range of 2 to 4 MB for a call. I only have reconized it after Homey run out of memotry and stopped all apps. System momory has used all the memory at this time.

I’ve once tested with calling a random homeyscript every second, then the memory usage of Homeyscript seem to increase very quick, until the app gets killed by Homey.
I just tested it again and this bug is still present

I’ve been using the MQTT hub to share the devices to my Home Assistant and mostly that works fine. However, I now have an Ikea Styrbar remote control which only has a battery alarm available in MQTT. Is this somehow a problem with the MQTT hub or with the IKEA Tradfri app? I would like to get MQTT topics for the four buttons on the remote.
As the IKEA Tradfri app is built by Athom I really hope it can be somehow solved in the MQTT hub app :slight_smile:

You can send a topic with mqtt client, triggered by a button.
Example

1 Like

I’m using the hub for a few days now. Sometimes it just stops working. The app then is still running and the switch is to on state, but it doesn’t push anything to MQTT anymore. I’m validating this with MQTT-Explorer.

Is this something what happens to other users too?

1 Like

No, not overhere in combination with the homey broker.