MQTT Hub/Gateway

I could not find an answer to my question in this topic. I have a door contact sensor connected through MQTT. The state of this contact sensor is “open” or “closed”. The option isn’t available in MQTT hub, but in JSON code?

Scherm­afbeelding 2023-08-15 om 09.30.47

I tried some values, but no succes yet, who can help me?

{
"alarm_contact": {
"capability": "alarm_contact",
"stateTopic": "enocean/contact/Voordeur/state",
"setTopic": "",
"valueTemplate": "{{value}}",
"outputTemplate": "",
"displayName": "Deur open"
}
}

@HarriedeGroot the last commit for this app on Github is on 2021. Is it still actively maintained?

Do you have a specific issue?

1 Like

I have some improvements for the app:

  • add open/closed to on/of values
  • the “next” button doesn’t show, it seems blank
  • expand the screen with the “topic” or create a separate screen
  • a bit more information about “discovering devices”

Use templating?

"valueTemplate": "{{ value === 'closed' ? 'off' : 'on' }}"

True, this is an issue that I think popped up with the recent Homey rewrites. It’s annoying but it doesn’t hinder the functionality of the app (at least when you know about it).

Not possible, the layout is mostly handled by the Homey app.

Documentation is not part of the app itself. Perhaps someone more versed in this app can explain things.

The valueTemplate should be an option, but it doesn’t work and is more complex for users like me.

This app is meant to be as flexible as possible, which means that it’s up to the user to define capabilities and to provide a mapping between the input ("open"/"closed") and (in the case of boolean capabilities) true/false.

It does work, it just uses a different format that I thought (I don’t use this app):

"valueTemplate": "value == 'open'"

But if it’s too complex, you can also use virtual devices and the MQTT Client flows to set their capabilities based on the input. This app is for advanced users, its MQTT Device implementation doesn’t offer things that you cannot also do with flows.

Thanks Robert, but even with the new Json code is does nothing:

{
  "alarm_contact": {
    "capability": "alarm_contact",
    "stateTopic": "enocean/contact/Voordeur/state",
    "valueTemplate": " value == 'open' ",
    "displayName": "Deur open"
  }
}

screenshot log Mqtt hub

I also tried this code:

{
  "alarm_contact": {
    "capability": "alarm_contact",
    "stateTopic": "enocean/contact/Voordeur/state",
    "valueTemplate": "value === 'open' ? 'on' : 'off' ",
    "displayName": "Deur open"
  }
}

screenshot log Mqtt hub

This is working fine for me:

{
  "alarm_contact": {
    "capability": "alarm_contact",
    "stateTopic": "homey/alarm_contact/blabla/state",
    "setTopic": "",
    "valueTemplate": "value == 'open'",
    "outputTemplate": "",
    "displayName": "Contact alarm"
  }
}
1 Like

Not a clue what the difference is, but now it does work!!

{
  "alarm_contact": {
    "capability": "alarm_contact",
    "stateTopic": "enocean/contact/Voordeur/state",
    "setTopic": "",
    "valueTemplate": "value == 'open'",
    "outputTemplate": "",
    "displayName": "Contact alarm"
  }
}

Scherm­afbeelding 2023-08-15 om 17.17.15

The only difference is a space after " and before ".
old
“valueTemplate”: " value == ‘open’ ",
new
“valueTemplate”: “value == ‘open’”

No, but if I use it as a central infrastructure piece I just want to make sure it’s maintained :slight_smile:

:thinking: Interesting POV on community apps. Even Athom apps aren’t always ‘maintained’ (or just really slow, months or a year may pass :face_with_peeking_eye: , so maybe you’re on the wrong platform somehow?
I mean, it’s not KNX or a PLC.
And what exactly should be maintained when an app works as designed? What’s wrong with MQTT Hub for instance?

1 Like

Correction, yes I do. I started installing it and playing around with it - and every time I start the app, it starts broadcasting and then at at certain point crashes. I never got it running, unfortunately.

What am I doing wrong? In Mqtt the voltage is 2.98, but with my Json code the battery percentage is still 0%.
MQTT message
image

Homey result

JSON code

{
  "measure_battery": {
    "capability": "measure_battery",
    "stateTopic": "enocean/motion/Toilet_beneden/battery",
    "setTopic": "",
    "valueTemplate": "",
    "outputTemplate": "",
    "displayName": "Battery"
  },
  "measure_luminance": {
    "capability": "measure_luminance",
    "stateTopic": "enocean/motion/Toilet_beneden/brightness",
    "setTopic": "",
    "valueTemplate": "",
    "outputTemplate": "",
    "displayName": "Luminance"
  },
  "alarm_motion": {
    "capability": "alarm_motion",
    "stateTopic": "enocean/motion/Toilet_beneden/motion",
    "setTopic": "",
    "valueTemplate": "",
    "outputTemplate": "",
    "displayName": "Motion alarm"
  },
  "measure_voltage": {
    "capability": "measure_voltage",
    "stateTopic": "enocean/motion/Toilet_beneden/voltage",
    "setTopic": "",
    "valueTemplate": "{{ value }}",
    "outputTemplate": "{{ (value / 3) * 100 }}%",
    "displayName": "Battery Percentage"
  }
}

After some tweaks I managed to get 2.98 V into 2.98%, but that’s not wat I need.
I think the battery is low when it’s 2.5 volt and full at 3.0 volt.

image

{
  "measure_voltage": {
    "capability": "measure_voltage",
    "stateTopic": "enocean/motion/Toilet_boven/voltage",
    "setTopic": "",
    "valueTemplate": "",
    "outputTemplate": "",
    "displayName": "Battery"
  },
  "measure_luminance": {
    "capability": "measure_luminance",
    "stateTopic": "enocean/motion/Toilet_boven/brightness",
    "setTopic": "",
    "valueTemplate": "",
    "outputTemplate": "",
    "displayName": "Luminance"
  },
  "alarm_motion": {
    "capability": "alarm_motion",
    "stateTopic": "enocean/motion/Toilet_boven/motion",
    "setTopic": "",
    "valueTemplate": "",
    "outputTemplate": "",
    "displayName": "Motion alarm"
  },
  "measure_battery": {
    "capability": "measure_battery",
    "stateTopic": "enocean/motion/Toilet_boven/voltage",
    "setTopic": "",
    "valueTemplate": "{{ value | float | round(2) }}",
    "outputTemplate": "{{ ((value - 2.5) / (3.0 - 2.5)) * 100 | round(0) }}%",
    "displayName": "Battery Percentage"
  }
}

you think? :stuck_out_tongue_winking_eye: a regular 3V battery runs from 3.3V (sometimes a little higher) till mostly 2.8V (though really depending on device it can be from 2.9V till 2.6V), the battery capability in Homey does use 0 - 100 (so not percentage (2 decimals)! like all other percentile capabilities)

Do you have a solution for my question too? I surely hope so? If not, where can I find more informatie about the JSON options?

hulp gezocht om mijn data waardes vanaf mqtt naar homey te krijgen.

zit er al even op te stoeien en kom steeds verder maar loop nu beetje vast op het importeren van die data.
dit is voor mij de eerste keer dat ik met homey en met mqtt werk dus sorry als ik er de ballen niet van snap hahaha

wat ik wil,

is deze data in homey te krijgen Dus mijn p1 gegevens en het aansturen van mijn laadpaal.

dit is wat ik zie op mqtt explorer,

waar ik tegen aanloop is wat moet ik hier instellen?

en hier vind ik niets… maar gebruik vermoedelijk verkeerde zoekterm?

en ik heb dit ook geprobeerd zonder resultaat,

met dit ingevuld bij topics:

{
“measure_current”: {
“capability”: “measure_current”,
“stateTopic”: “”,
“setTopic”: “”,
“valueTemplate”: “{ "name": "Mains Current L2", "object_id": "SmartEVSE-45242-MainsCurrentL2", "unique_id": "SmartEVSE-45242-MainsCurrentL2", "state_topic": "SmartEVSE-45242/MainsCurrentL2", "availability_topic": "SmartEVSE-45242/connected", "device": { "model": "SmartEVSE v3", "identifiers": "SmartEVSE-45242", "name": "SmartEVSE-45242", "manufacturer": "Stegen", "configuration_url": "http://xxx.xxx.xxx.xxx", "sw_version": "SERKRI-1.7.3" }, "device_class": "current", "unit_of_measurement": "A", "value_template": "{{ value | int / 10 }}" }”,
“outputTemplate”: “”,
“displayName”: “Current”
}
}

oh ik zou zo graag hier uit willen komen…
wie kan mij helpen?

1 Like

Heb je de apps MQTT broker en evt. MQTT Client ook draaien?

Yes. Beide draaien op de homey. Apps van Menno van grinsven.