Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


HA integration render and others.
#1
I am using home assistant and integrate Moode (on my pri4) by mid integration. It work well but I don't know what render is in use. 
I mean when Moode playing something by airplay from my iPhone or by bluetooth from my wife's smartphone I don't see it in home assistant.
So I try to do something like that:

add new sensors in my HA:
  1.    - platform: command_line
  2.      name: Moode Renderer
  3.      command: curl http://moode.local/currentsong.txt | sed -n 's/^file=//p'
  4.      value_template: >-
  5.        {% if value == 'Airplay Active' %}
  6.        Airplay
  7.        {% elif value == 'Bluetooth Active' %}
  8.        Bluetooth
  9.        {% elif value == '' %}
  10.        Brak
  11.        {% else %}
  12.        MPD
  13.        {% endif %}
  14.      scan_interval: 15
  15.  
  16.    - platform: command_line
  17.      name: Moode MPD State
  18.      command: curl http://moode.local/currentsong.txt | sed -n 's/^state=//p'
  19.      value_template: >-
  20.        {% if value == 'play' %}
  21.        Play
  22.        {% elif value == 'pause' %}
  23.        Pause
  24.        {% elif value == 'stop' %}
  25.        Stop
  26.        {% else %}
  27.        Brak

  28.        {% endif %}
  29.      scan_interval: 15
    Enable metadata file in setting in Moode.try to link that file by sudo ln /var/local/www/currentsong.txt /var/www/currentsong.txt
And here starts problem.
At 1st try I linked file in/var/www/ doesn't change when I change render in Moode. I mean. I play something by airplay, and see that in "Moode.local/currentsong.txt".
When I change course to some internet radio file doesn't changed. so render sensor is useless.
When I try to link file with -sfn parameters in command it work well but file disappear after few hours.

Anyone can help me ?
I just won't to know what is playing on my Moode audio in my home assistant, because deflate integration does not support that feature.
Reply
#2
You will need to use a symbolic (soft) link instead of a hard link because the currentsong.txt file is updated via writing to a /tmp file first then renaming it to /var/local/www/currentsong.txt. This effectively creates a new file which causes the hard link to become broken.

Try this

Code:
# Remove hard linked file
sudo rm /var/www/currentsong.txt

# Create soft linked file
sudo ln -s /var/local/www/currentsong.txt /var/www/currentsong.txt
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#3
I have to use sudo before ln… otherwise i have premission denied.
Anyway i am pretty shure that this gile will disappear.
But ill check it

Edited:
And Here it is as i said. File disappear. Why?
Reply
#4
Thats probably due to some old code in worker.php maintenance task that removes temp files and any symlinks in /var/www.

Edit the file /var/www/command/worker.php and comment out or delete the code block below in the function chkMaintenance()

Code:
// Purge temp or unwanted resources
sysCmd('find /var/www/ -type l -delete'); // There shouldn't be any symlinks in the web root
sysCmd('rm ' . STATION_EXPORT_DIR . '/stations.zip > /dev/null 2>&1'); // Possible leftover temp file created by Radio Manager export
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#5
Hmmm. it seems like You're right.
I deleted that lines and for now file is still in place.
Hope it doesnt changeBig Grin
Thank You so much.

Anyway.
Is there a chance to little integration in home assistant with something like that?
You know. official way but what i made is just workaround.

EDIT:
Nope. file currentsong.txt disappear again Sad
Reply
#6
It would probably be a good thing to do but I don't have any experience with HA and so I'm not sure what "integration" would look like. Maybe another dev with HA experience can help us out :-)
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#7
Nope. file currentsong.txt from /var/www/ disappear again
Reply
#8
(05-23-2022, 10:12 PM)Tim Curtis Wrote: It would probably be a good thing to do but I don't have any experience with HA and so I'm not sure what "integration" would look like. Maybe another dev with HA experience can help us out :-)

As I read this thread, all the Op is asking for is that the currentsong.txt file (with enhanced metadata) be made accessible through the moOde Command API.

Regards,
Kent
Reply
#9
(05-23-2022, 11:45 PM)TheOldPresbyope Wrote:
(05-23-2022, 10:12 PM)Tim Curtis Wrote: It would probably be a good thing to do but I don't have any experience with HA and so I'm not sure what "integration" would look like. Maybe another dev with HA experience can help us out :-)

As I read this thread, all the Op is asking for is that the currentsong.txt file (with enhanced metadata) be made accessible through the moOde Command API.

Regards,
Kent

i just wont to see in HA status of mpd player with render. i mean i play via airplay wont to see in HA media player is playng via airplay, same for BT.
No matter how.
Any ideas how?
Reply
#10
(05-23-2022, 11:19 PM)kuduacz Wrote: Nope. file currentsong.txt from /var/www/ disappear again

Very odd.

There is no other code in moOde that would delete symlinks in /var/www/
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply


Forum Jump: