[dev] Plugin for Beocreate

Hi !

Long time user of Yatse ( since 2013 with 3 donations ).

I recently bought a HiFiBerry Beocreate ( Beocreate | HiFiBerry ), it’s supposed to be used with HiFiBerry OS which as web-app for remote.
Unfortunately HiFiBerry OS is not meant to play video, so I switched to OSMC (Kodi).

So, I started to write my own remote from scratch ( GitHub - vincss/beocreate-remote: beocreate-remote ; https://support.hifiberry.com/hc/en-us/community/posts/16595781083933-Beocreate-Remote-Android-App ).

Then I noticed that there is a way to make a custom plugin to use in Yatse, how awesome it is !

I forked the plugin repo and tried to make it work, with the help of Android Studio, I got a working APK, unfortunately there is an issue when I load the plugin into the config.
When I uncomment this line, the plugin crash, I guess it’s not how I’m supposed to handle the connection…

Do you have any tips to debug it ?

I made some UnitTest that are working properly to control the Beocreate sound board.

Thanks a lot for this project, I’m looking forward to control my sound system with a custom plugin. :slight_smile:

Without the crash message it’s hard to know :slight_smile:

I don’t remember all the details but the error is probably network on main thread ?

If yes then you need to do all network connection on a different thread via any mechanism you want like coroutines.

Thanks for the hints.

Is there any way to run in locally trough the debugger of Android Studio ?

Without the crash message it’s hard to know :slight_smile:

There is any logs to retrieve ?

Android studio can show the device logcat that will have the crash log.

Edit: And you can check for example GitHub - danielhstahl/onkyo-yatse-plugin: yatse plugin for onkyo/integra receivers that have a full working plugin example.

Hi !
Thanks for your hints, I got something that is working. :blush:

One issue is that when I open the app for the first time with the plugin, the volume control with the physical button is at 100% :

While when I use the button from the GUI, it gets the volume before changing it.

Did I miss something ?

Don’t use runBlocking you still block the mainthread so remove the error but not the root issue :slight_smile:

You need to really run the code asynchronously.

And you probably miss some updates in the refresh or the getVolume commands.

I’m pretty new to kotlin, I understand that it’s not the best way, but it seems to be working for now.

I’ve checked the volume initialization and refresh, it seems good to me.
It retrieves the volume just after the connection, but in the setVolumeLevel, it sends 100.0.
I don’t understand on what this value is based.

2024-02-10 17:54:03.238 15177-15486 SuspendedController     tv.yatse.plugin.avreceiver.sample    D  -- Connected to 192.168.0.4 tv.yatse.plugin.avreceiver.sample.helpers.SigmaTcpController@3bcf26b
2024-02-10 17:54:03.284 15177-15486 SigmaTcpController      tv.yatse.plugin.avreceiver.sample    D  --- getVolume 0.25
2024-02-10 17:54:03.286 15177-15177 AVPluginService         tv.yatse.plugin.avreceiver.sample    D  - getVolumeLevel volume:25.0
2024-02-10 17:54:03.286 15177-15177 AVPluginService         tv.yatse.plugin.avreceiver.sample    D  - refresh mVolumePercent:25.0 mIsMuted:true
2024-02-10 17:54:11.499 15177-15481 AVPluginService         tv.yatse.plugin.avreceiver.sample    D  - setVolumeLevel volume:100.0 mVolumePercent:25.0
2024-02-10 17:54:11.501 15177-15486 SigmaTcpController      tv.yatse.plugin.avreceiver.sample    D  --- setVolume 1.0

The behaviour seems the same in the sample when I try it, it doesn’t take the mVolumePercent into account.

The called function when pressing physical button shouldn’t be volumePlus & volumeMinus ?

Thanks for your help.

If you disable the dialog in Yatse settings then it calls the volume plus / minus else it use the current volume and apply the volume change to it.

It should be based on the plugin answer to getVolumeLevel()

1 Like

It works well with the dialog setting disabled.

It’s only on the first button pressed that the volume is at 100% after that it’s based on the last value; this value seems to be stored somewhere (or based on the value stored in Kodi ?), because on further calls, it doesn’t retrieve the getVolume value.

Calls from the physical buttons

2024-02-13 11:39:24.115 32364-1419  AVPluginService         tv.yatse.plugin.avreceiver.sample    D  - setVolumeLevel volume:22.0 mVolumePercent:17.0
2024-02-13 11:39:24.117 32364-32407 SigmaTcpController      tv.yatse.plugin.avreceiver.sample    D  --- setVolume 0.22
2024-02-13 11:39:24.378 32364-1419  AVPluginService         tv.yatse.plugin.avreceiver.sample    D  - setVolumeLevel volume:27.0 mVolumePercent:22.0
2024-02-13 11:39:24.380 32364-32407 SigmaTcpController      tv.yatse.plugin.avreceiver.sample    D  --- setVolume 0.27

Calls from the GUI

2024-02-13 11:42:23.228 32364-1419  AVPluginService         tv.yatse.plugin.avreceiver.sample    D  - getVolumeLevel volume:39.0
2024-02-13 11:42:23.231 32364-32407 SigmaTcpController      tv.yatse.plugin.avreceiver.sample    D  --- setVolume 0.4
2024-02-13 11:42:23.389 32364-32407 SigmaTcpController      tv.yatse.plugin.avreceiver.sample    D  --- getVolume 0.3999999761581421
2024-02-13 11:42:23.390 32364-1419  AVPluginService         tv.yatse.plugin.avreceiver.sample    D  - getVolumeLevel volume:40.0
2024-02-13 11:42:23.392 32364-32407 SigmaTcpController      tv.yatse.plugin.avreceiver.sample    D  --- setVolume 0.41

Can you have a look, please ?
Thanks.

Provide proper full logs of Yatse from app start after force kill.
And triple check that you do not return 100 on the first call to get volume.

Your log from GUI does not show a 100 volume call.

I added some logs in the plugin.
There is the log file, I pushed 3 times on the physical button then 3 times on the GUI button.

Thanks :slight_smile:

debug.log (10.8 KB)

I do not see the initial volume request, probably because your plugin is too slow to connect :wink: (As I said don’t use runblocking as it well block :stuck_out_tongue:

I’ll see to add a workaround in next release to force a refresh after a slow connection.

1 Like

As I said, I think the issue is also in the sample, so I retried to get the full log from the sample. Before, I didn’t restarted the application after enabling the debug option, sorry, my bad.

In this new log with the start, I can see that it retrieves the volume before changing it :

2024-02-13 16:36:50.028 Verbose/FirebaseManager: Setup successful.
2024-02-13 16:36:50.044 Verbose/ApiReceiver: API call: tv.yatse.api.LOG_VERBOSE - TAG : AVPluginService
- MESSAGE : Getting volume level: 5.0
2024-02-13 16:36:50.045 Verbose/API-AVPluginService: Getting volume level: 5.0
2024-02-13 16:36:50.056 Verbose/ApiReceiver: API call: tv.yatse.api.LOG_VERBOSE - TAG : AVPluginService
- MESSAGE : Refreshing values from receiver volumePercent:5.0 isMuted:false

...

2024-02-13 16:36:51.493 Verbose/KodiNexus: <-- [544] {"id":35,"jsonrpc":"2.0","result":{"muted":false,"volume":100}}
2024-02-13 16:36:51.494 Verbose/StatusObserver: No Widgets and no UI / Wear / MediaBrowser
2024-02-13 16:36:51.514 Verbose/StatusObserver: UI status changed to true from false
2024-02-13 16:36:52.350 Verbose/VolumeManager: Set plugin volume to: 95
2024-02-13 16:36:52.358 Verbose/ApiReceiver: API call: tv.yatse.api.LOG_VERBOSE - TAG : AVPluginService
- MESSAGE : Setting volume level: 95.0

beocreate_debug.log (28.1 KB)
sample_debug.log (20.2 KB)

Ok so you face a small race that is 100% unrelated to plugins or not.

Strange that you can repro it at 100% on your device but well.

To confirm press down instead of up and it will set the volume to 0.

Hi,
I’m already pressing down in this case, since it goes from 100 to 95.

Well can’t reproduce anything except that small race so we’ll have to hope it fixes this too :slight_smile:

Hi,
Thanks for the fix, it seems so far so good. :slight_smile: