Page 1 of 1

Radio LUA script help

Posted: Monday 25 July 2016 13:23
by fergalom
Could someone tell me why this code does not switch on and set the level of the dummy dimmable switch "Radio Volume" ?

script_device_radio.lua

Code: Select all

commandArray = {}

if (devicechanged['Radio Channels'] == 'CDNX' and otherdevices['Radio Volume'] == 'Off' ) then
        commandArray['Radio Volume'] = 'On'
        print('Radio Volume')
        newlevel = 10
        print(newlevel)
        commandArray['Radio Volume'] = 'Set Level' ..newlevel
        print("radio on")
        print(otherdevices_svalues['Radio Volume'])
end


if (devicechanged['Radio Volume']) then
        v = otherdevices_svalues['Radio Volume']
        os.execute('mpc volume ' ..v)
        print("radio volume " ..v)
end

return commandArray
Extract from the log:

Code: Select all

2016-07-25 12:19:04.310 User: Admin initiated a switch command
2016-07-25 12:19:04.325 LUA: Radio Volume
2016-07-25 12:19:04.326 LUA: 10
2016-07-25 12:19:04.326 LUA: radio on
2016-07-25 12:19:04.326 LUA: 0
2016-07-25 12:19:04.327 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_device_radio.lua
2016-07-25 12:19:04.311 (DUMMY) Light/Switch (Radio Channels)
2016-07-25 12:19:04.954 Executing script: /home/pi/domoticz/scripts/mpc_CDNX.sh
2016-07-25 12:19:10.040 LUA: radio volume 0
2016-07-25 12:19:09.998 (DUMMY) Light/Switch (Radio Volume)

Re: Radio LUA script help

Posted: Monday 25 July 2016 13:30
by trixwood
commandArray['Radio Volume'] = 'Set Level' ..newlevel
->
commandArray['Radio Volume'] = 'Set Level ' ..newlevel

you know the space.... between level and the number..

Re: Radio LUA script help

Posted: Monday 25 July 2016 13:37
by fergalom
always the simple things...............thank you!! (it's been driving me nuts)

Re: Radio LUA script help

Posted: Monday 25 July 2016 14:12
by Derik
What radio are u using?
And how?

Re: Radio LUA script help

Posted: Monday 25 July 2016 14:18
by trixwood
(it's been driving me nuts)
That's why I quit working in IT 7 years ago :lol:

Re: Radio LUA script help

Posted: Monday 25 July 2016 14:27
by trixwood
My wild guess is media player classic a software radio player for windows listening to http://www.cdnx.co.uk.
Did I win a prize?

Re: Radio LUA script help

Posted: Monday 25 July 2016 14:33
by Derik
trixwood wrote:My wild guess is media player classic a software radio player for windows listening to http://www.cdnx.co.uk.
Did I win a prize?
Yes you win.... :D :D :D :D

Only the how part... :?:
And the second question.. :idea:
Is there something like this possible with Youtube or 3Fm? :?:
I try to make a Badroom radio... only :-(

Re: Radio LUA script help

Posted: Monday 25 July 2016 14:38
by trixwood
Like this?

https://raspberrytips.nl/internet-radio ... pberry-pi/

Or better:

http://www.dronkert.net/rpi/radio.html <--- Has command line scripting ready to go...

Re: Radio LUA script help

Posted: Monday 25 July 2016 14:45
by trixwood
Youtube from command line audio only:

http://tsengf.blogspot.nl/2014/12/play- ... ne-on.html

Re: Radio LUA script help

Posted: Monday 25 July 2016 14:53
by trixwood
But not easier to have like an shows/bath bluetooth/airplay speaker instead of a whole radio?

http://nl.aliexpress.com/store/product/ ... 40191.html

or

http://bathroominspiration.net/bathroom ... eqa-84062/

This one even has FM build in as extra feature...
http://nl.aliexpress.com/item/VTIN-Wate ... 59212.html

This one you can take with you in bath (yes listen to it underwater, you can dive, recommended music: https://www.youtube.com/watch?v=YVxXbTk-zsQ or https://www.youtube.com/watch?v=savCAd6RyPI :lol: )

http://nl.aliexpress.com/item/2016-New- ... 32598.html

Re: Radio LUA script help

Posted: Monday 25 July 2016 15:16
by trixwood
This is ofcourse the ultimate shower speaker:

http://www.tuvie.com/kohler-moxie-showe ... room-diva/

Re: Radio LUA script help

Posted: Monday 25 July 2016 15:19
by fergalom
Derik wrote:What radio are u using?
And how?
Yes, I use some internet radio stream and also some playlists from my music collection.

I run forked-daapd in the background so I can use my airplay speakers.

Each level of the selector switch calls an internet radio script or a local playlist.
General format of the script is:

mpc_CDNX.sh

Code: Select all

#!/bin/bash
mpc clear
mpc enable 56665 #Airplay1
mpc enable 17552 #Airplay2
mpc add http:/svr1.msmn.co:8136
mpc play
Also have a selector switch to select which speakers I want to stream to.

Re: Radio LUA script help

Posted: Monday 25 July 2016 15:22
by Derik
yes yes...
I was looking @:
https://www.mopidy.com/
More options then the others?[ not eol ]

Only there a so maaaaaany rpi players..
Rune is nice only not a good api..

What should be the best overal player.
So 1 device plays all.
Mp3 youtube spoti google air etc etc etc..

Re: Radio LUA script help

Posted: Monday 25 July 2016 19:17
by trixwood
I would buy a dedicated pi zero and like a wireless shower speaker, hook it up and put kodi on it... json api, plays everything, remote app on your tablet phone... tons of plugins... think it would set me back 50 euro total.

Re: Radio LUA script help

Posted: Monday 25 July 2016 19:41
by Derik
trixwood wrote:I would buy a dedicated pi zero and like a wireless shower speaker, hook it up and put kodi on it... json api, plays everything, remote app on your tablet phone... tons of plugins... think it would set me back 50 euro total.
MM

Why did i not think about this option....
[Perhaps you have a nice how to? ]
Think Kodi is the best option..


Thanks...

Re: Radio LUA script help

Posted: Monday 25 July 2016 19:57
by trixwood
Only the basic ones:

http://kodi.wiki/view/HOW-TO:Install_Ko ... spberry_Pi
https://www.domoticz.com/wiki/Kodi
http://kodi.wiki/view/JSON-RPC_API/v6

do not know how you connect bluetooth speaker... I got airplay. But probably very simple.

Kodi has a domoticz plugin like domoticz has a kodi plugin ;-)

Control Domoticz
http://forum.kodi.tv/showthread.php?tid=180840

NL Radio streams:
http://bigfoot87.com/radiostreams/

Control HUE
https://github.com/michaelrcarroll/scri ... .ambilight

I do not run it on a pi anymore, kodi v15 was ok (pi on both osx), v16 was a disaster on osx bug ridden piece of crap, v17 works ok again on osx.