Smart Friends Bridge Addon

oh sorry, i think i have the wrong one.
i installed this one: hassio-addons/DOCS.md at 4fc37ab780ec11ab3ea2044eddf08a01ce50d5e8 · airthusiast/hassio-addons · GitHub

And yes, i have the supervisor version

That’s not this one. That guy never responds to anything, I tried contributing to his but he ignores it… That’s why I wrote my own and made it actually work. If you install this one I can help you if you’re having problems. hassio-addons/smartfriends-bridge at main · GimpArm/hassio-addons · GitHub

Hi, I’m so sorry for the mix-up!

I’ve just started with the SmartFriends Rest API. Set it up and try the link: http: // homeassistant: 5001 / list -great, it works :slight_smile:
4 weeks ago I started with homeassistant, that was my first project that made me desperate. But now it worked. :smile:
i stoped this Addon and installed "control your SmartFreinds devices through REST or MQTT.
try the link: it also work!

now I’m not getting any further. I thought that my MQTT broker would find the devices if everything is configured. But now I read, I have to enter the devices in “deviceMap.json” and “DataPath”.
Where can i find it?
Unfortunately, as a beginner, I can’t do anything with these terms.
I am currently missing the transition to control the devices, or to make them visible in homeassistant
i hope you can understand what i mean :slight_smile:
Have a nice evening

The DataPath is where your configure.yaml file is located. After enabling MQTT and starting there should be a smartfriends2mqtt folder there. Inside that you can set which devices you want to pass to MQTT by giving their device id and what Type of device it is. Class is optional but helps for a little more detail. Get your list of types and classes in the HASSIO documentation. MQTT Discovery - Home Assistant

  {
    "Id": 11716,
    "Type": "cover",
    "Class": "shutter"
  }

You’ll need to restart the add-on for changes to your devices.json to be read.

Hi GimpArm,
thanks for your Add-on!
The REST-API works fine for me, but I cannot run the MQTT-Interface.
I run a MQTT-Server out of Home Assistant, can that be a problem?
My config look like this:

Mqtt:
  Enabled: true
  DataPath: /config/smartfriends2mqtt
  BaseTopic: smartfriends
  Server: mqtt://192.168.x.x
  Port: 1883
  User: mqtt
  Password: xxxx
  UseSsl: false

First, is it connecting but just not showing your devices or are you seeing connection errors in your log?

I suspect it isn’t connecting. Do not include “mqtt://” for the server, just give it the name. I would also make sure that is really the correct IP. Since add-ons run as docker containers on a virtual network, usually it is best to not use an IP and instead a domain name. I think the default name is hassio.local

Thanks for the hints, I will try first the HASSIO Add-on and if that works try with a domain name!
Will give feedback if done :slight_smile:

Thanks, with the HASSIO MQTT Server it worked…

Hi,

I am currently trying to make my devices available in HA.
Unfortunately, I fail on the devices that have more than one ID.
The Mosquitto broker finds the devices, but without any function.
ID 13753 is a window sensor from ABUS. - Appears with status “unknown” and does not change it
ID 618 is a ceiling lamp with cct and dimmable. – is only displayed as a switch, but cannot be switched.
Here is an excerpt from my /config/smartfriends2mqtt/deviceMap.json
The first two entries are my shutters (10044+6177) which are working.

[
  {
    "Id": 10044,
    "Type": "cover",
    "Class": "shutter"
  },
  {
    "Id": 6177,
    "Type": "cover",
    "Class": "shutter"
  },
  {
    "Id": 13753,
    "Type": "binary_sensor",
    "Class": "door"
  },
  {
    "Id": 618,
    "Type": "switch",
    "Parameters": {
      "icon": "hass:lightbulb"
    }
  }
]

I hope you can help me
Many greetings
Daniel

Hi Daniel,

Can you post what the status is from REST? Like http://homeassistant.local:5001/get/13753
Most likely they are reporting information different than it expects (I just try to guess how it works) and its getting it wrong. If you show me the output of the devices as I showed you I can probably help you make something that works.

Also important, the devices must work from the official app too. If they don’t work there then the SmartFriends box doesn’t support it at all.

Hi,

Thank you for the fast answer. The devices all work. But my entries are probably wrong :wink:

Here is the data from the window sensor:

{
    "id": 13753,
    "name": "Fenster",
    "room": "Schlafzimmer",
    "gatewayDevice": "SmartFriendsBox",
    "kind": "DoorWindowContact",
    "manufacturer": "ABUS KG",
    "devices": {
      "doorWindowContact": {
        "Id": 18482,
        "description": "AbusDoorWindowNoc"
      },
      "failureStatus": {
        "Id": 4827,
        "description": "AbusFailureDevice"
      }
    }
  },

And from my ceiling lamp:

{
    "id": 618,
    "name": "Büro Lampe",
    "room": "6 Büro",
    "gatewayDevice": "SmartFriendsBox",
    "kind": "SwitchActuator",
    "manufacturer": "Paulmann Licht GmbH ",
    "model": "CCT light ",
    "state": "Off",
    "devices": {
      "switchActuator": {
        "Id": 8302,
        "description": "ZigbeeSwitch",
        "commands": {
          "On": 1,
          "Toggle": 2,
          "Off": 0
        },
        "currentValue": "Off"
      },
      "brightness": {
        "Id": 165,
        "description": "ZigbeeBrightnessDimmer",
        "max": 100,
        "min": 0,
        "precision": 0,
        "step": 1
      },
      "colortemp": {
        "Id": 17113,
        "description": "ZigbeeCCT",
        "max": 6500,
        "min": 2700,
        "precision": 100
      },
      "failureStatus": {
        "Id": 9380,
        "description": "ZigbeeFailureDevice"
      }
    }
  },

Many greetings

So this is a little strange. There’s a lot of “currentValue” values that are missing, which is probably why it doesn’t know the current state of things. At least for the door sensor and the brightness and color temp of the light. Its either they are sending values my bridge isn’t aware of or there is something more going on. If you can give me the contents from http://homeassistant.local:5001/raw right after the add-on is restarted, then I could debug your entire setup and see if I’m missing data.

As for what needs to be done, we have to tell HA how to talk to these devices a little better. More documentation is available at MQTT Discovery - Home Assistant

For your switch we’re going to have to do something like this.

{
  "Id": 618,
  "Type": "switch",
  "Parameters": {
    "icon": "hass:lightbulb",
    "command_topic": "{baseTopic}/{deviceId}/switchActuator/set",
    "payload_on": "On",
    "payload_off": "Off",
    "brightness": true,
    "brightness_state_topic": "{baseTopic}/{deviceId}/brightness",
    "brightness_command_topic": "{baseTopic}/{deviceId}/brightness/set",
    "brightness_scale": 100,
    "color_mode": true,
    "color_temp_state_topic": "{baseTopic}/{deviceId}/colortemp",
    "color_temp_command_topic": "{baseTopic}/{deviceId}/colortemp/set",
    "supported_color_modes": ["color_temp"]
  }
}

Hi,

you mean my complete list with all devices?
So that’s what I get when I type http://homeassistant:5001/list?
With stop with raw at the end :blush:
I ran the MQTT Explorer once.
Regarding the window sensor: The explorer shows whether it is closed or open, but nothing arrives in HA.
Regarding the ceiling light: Explorer shows the change. So on/off, or for example warm white, cold white. So every change I make. Then appears with the ID as it is in the list.

Thanks for the link: MQTT Discovery – Home Assistant available
Unfortunately, I have to say that I am a complete beginner. I’ve looked at it, but I can’t find a way to build such codes myself. sorry

I copied your code and swapped it for mine for the lamp. Unfortunately the addon doesn’t start anymore. I only have a very long log

s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
Unhandled exception. Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: [. Path '[3].Parameters.supported_color_modes', line 32, position 30.
   at Newtonsoft.Json.JsonTextReader.ReadStringValue(ReadType readType)
   at Newtonsoft.Json.JsonTextReader.ReadAsString()
   at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateDictionary(IDictionary dictionary, JsonReader reader, JsonDictionaryContract contract, JsonProperty containerProperty, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value)
   at SmartFriends.Mqtt.MqttClient.LoadDeviceMap(String path) in D:\Projects\smartfriends-bridge\source\SmartFriends.Mqtt\MqttClient.cs:line 69
   at SmartFriends.Mqtt.MqttClient..ctor(MqttConfiguration mqttConfig, ILogger logger, TypeTemplateEngine templateEngine) in D:\Projects\smartfriends-bridge\source\SmartFriends.Mqtt\MqttClient.cs:line 60
   at SmartFriends.Host.Startup.<>c.<ConfigureServices>b__4_2(IServiceProvider x) in D:\Projects\smartfriends-bridge\source\SmartFriends.Host\Startup.cs:line 34
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitIEnumerable(IEnumerableCallSite enumerableCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass1_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
   at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
   at SmartFriends.Host.Program.Main(String[] args) in D:\Projects\smartfriends-bridge\source\SmartFriends.Host\Program.cs:line 11
/run.sh: line 12:   197 Aborted                 (core dumped) dotnet /opt/SmartFriends.Host.dll --urls=http://0.0.0.0:80
/run.sh: line 12: http://[::]:80: No such file or directory
[cmd] /run.sh exited 127
[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.

MQTT Explorer

No, there is also a /raw which is the raw data coming from the SmartFriends box. With that data I can debug your entire setup. It doesn’t contain any private information or passwords or anything like that.

Apparently I have no support for objects inside templates. I’ll make an update for that in the next week.

Right now remove the line that says

"supported_color_modes": ["color_temp"]

I made an update, so update your add-on to version 3.4. I think it will fix your unknown problem. I also added the ability to set the supported_color_modes so my initial template suggestion should work now.

Hi,
Thanks very much.
I did the update and copied your code in again, without the last line.
Now I can switch the ceiling light on/off with HA. Dimming and/or color temperature is not displayed. Is it correct that way?
I left the window sensor as is, it still doesn’t work.
This is what http://homeassistant.local:5001/raw looks like for me.
What exactly do you need from it? If I just go to copy, that’s over 600 pages.
Is there perhaps also a function that I could send it to you as a pm? Can’t find anything about it…
Many greetings
raw

Glad you can turn that on and off, that was definitely a bug on my end that I’m glad I finally figured out.

The dimming/color aren’t working because the SmartFriends box either isn’t sending any value for them or my add-on is receiving the value but doesn’t know how to handle it. That’s why it’s easiest if I get the entire contents of the /raw. Most of it is manufacturer device definitions and language translations but its still much easier if you send me the whole thing. Something like pastebin.com works well.

Hi,
here is the raw of my lamp.

    {
      "automatable": true,
      "counter": 1,
      "deviceDesignation": "${ZigbeeIdentify}",
      "deviceID": 865,
      "deviceName": "${Identify}",
      "deviceState": "active",
      "deviceTimestamp": 20211117133345,
      "deviceTypClient": "CCT light ",
      "deviceTypServer": "digitalActuator",
      "favorite": false,
      "firstLevel": true,
      "group": "${GroupSwitching}",
      "hidden": false,
      "icon": "icon.SmartHome.Devices.Steinel.RS_LED_D2",
      "iconName": "icon.SmartHome.Devices.Steinel.RS_LED_D2",
      "id": 865,
      "logging": false,
      "manufacturer": "Paulmann Licht GmbH ",
      "masterDeviceID": 618,
      "masterDeviceName": "Büro Lampe",
      "name": "${Identify}",
      "productDesignation": "CCT light ",
      "radioStandard": "${SystemZigbee}",
      "ranking": 1,
      "roomID": 24229,
      "timestamp": 20211117133345,
      "type": "Device",
      "voiceAssistant": {
        "enabled": true
      }
    },

I tried to test your code for my window sensor as well. Unfortunately without success. Error in line 5… Do you know which one?
Many greetings

{
    "Id": 13753,
    "Type": "binary_sensor",
    "Class": "door"
    "command_topic": "{baseTopic}/{deviceId}/binary_sensor/set",
    "payload_on": "On",
    "payload_off": "Off",
  }

I really do need that entire raw dump if you want my help. It contains device information that describes how each device operates and current state information. Each device has a master device that tie together multiple sensors. My bridge software connects all these together to try to draw a simple picture of what each device looks like. The only piece of information I don’t need from that is the language translations but its just easier to copy & paste all of it. Post a link with a 1 day expiration on pastesbin.com or DM me or go to the project’s GitHub repository and open a support ticket with the file attached.

As for your window sensor, you have a syntax error in the json, after “door” there needs to be a comma ,. This still isn’t the right format because all the HA custom parts need to be inside a Parameters object. Although even that isn’t going to be correct because binary_sensors do not have commands, you would want to use the state_topic for reading the state as per the MQTT documentation. But you shouldn’t need to do any of this because binary_sensors are pretty simple and they work in my bridge without anything special. This is why I need the full raw data, the correct values are not getting to the bridge or it is being interpreted incorrectly. I’m afraid you’re wasting your time trying to go around sending me this the information I need to help you.

Hi,
I not only want your help, I need it!

Unfortunately I can’t PM here. I can also only upload one picture. Guess that’s because I’m new?
But via Github has worked!!!
Thanks for the tip!!!