Hi all,
I’ve recently tried to move into audio integration with Openhab, and have set up VoiceRSS (successfully downloading to the cache directory), and connected a Kodi Mediastation to be used as an audio sink.
Whenever I try to play to the Kodi Sink, either with playSound(doorbell.mp3) or say(“hello”), I get this in my error log:
2019-02-13 22:41:44.081 [INFO ] [pse.smarthome.model.script.TTS.rules] - Weather Announce Switch State Changed (rule engaged).
==> /var/log/openhab2/events.log <==
2019-02-13 22:41:50.457 [ome.event.ItemCommandEvent] - Item 'TTS_WeatherAnnounce' received command ON
2019-02-13 22:41:50.463 [vent.ItemStateChangedEvent] - TTS_WeatherAnnounce changed from OFF to ON
==> /var/log/openhab2/openhab.log <==
2019-02-13 22:41:50.481 [INFO ] [pse.smarthome.model.script.TTS.rules] - Weather Announce Switch State Changed (rule engaged).
2019-02-13 22:41:50.492 [INFO ] [pse.smarthome.model.script.TTS.rules] - Weather Announce - condition found to be ON, processing.
2019-02-13 22:41:50.495 [INFO ] [pse.smarthome.model.script.TTS.rules] - Attempting to turn Amp ON
==> /var/log/openhab2/events.log <==
2019-02-13 22:41:50.501 [ome.event.ItemCommandEvent] - Item 'Amplifier_Power' received command ON
==> /var/log/openhab2/openhab.log <==
2019-02-13 22:41:50.506 [INFO ] [pse.smarthome.model.script.TTS.rules] - Attempting to set Amp Mode
==> /var/log/openhab2/events.log <==
2019-02-13 22:41:50.513 [nt.ItemStatePredictedEvent] - Amplifier_Power predicted to become ON
2019-02-13 22:41:50.518 [ome.event.ItemCommandEvent] - Item 'Amplifier_Input' received command MPLAY
2019-02-13 22:41:50.527 [nt.ItemStatePredictedEvent] - Amplifier_Input predicted to become MPLAY
==> /var/log/openhab2/openhab.log <==
2019-02-13 22:41:50.527 [INFO ] [pse.smarthome.model.script.TTS.rules] - Attempting to set Amp Volume
==> /var/log/openhab2/events.log <==
2019-02-13 22:41:50.533 [ome.event.ItemCommandEvent] - Item 'Amplifier_Volume' received command 30
2019-02-13 22:41:50.542 [nt.ItemStatePredictedEvent] - Amplifier_Volume predicted to become 30
==> /var/log/openhab2/openhab.log <==
2019-02-13 22:41:50.548 [INFO ] [pse.smarthome.model.script.TTS.rules] - Attempting to play a sound
2019-02-13 22:41:50.553 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Announce Weather': null
I am able to see in PaperUI the Kodi
==
Openhab 2.4 stable, running on up-to-date Openhabian on Raspberry Pi3B.
The Kodi installation is running on a Ubuntu box, and the binding in PaperUI successfully displays what Kodi is playing and is able to play/stop the media. By this I assume the binding is working correctly.
In PaperUI > Configuration > Audio Sink, it’s set to Kodi Media Center
The context of all of this is a rules file that has 2 rules - one to say good morning/time to go to school for the kids (hasn’t been run yet), and the other one will read out the current and forecasted weather whenever the TTS_Weather_Announce switch is changed to ON (which is how I’ve been testing this).
// Test TTS Rules
var targetDenonVolume = 30
var targetMediaVolume = 50
rule "Ensure weather announce switch starts as off"
when
System started
then
TTS_WeatherAnnounce.sendCommand(OFF)
end
rule "Say Stuff"
when
Time cron "0 20 7 ? * MON-FRI" // perhaps add switch for if it is a school day or nots
then
var denonSource = "MPLAY" // placeholder, will be replaced by the initial Denon source
var denonVolume = 20 // placeholder, will be replaced by the initial Denon volume
var denonPower = OFF // placeholder
denonPower = Amplifier_Power.state
denonSource = Amplifier_Input.state
denonVolume = Amplifier_Volume.state
Amplifier_Power.sendCommand(ON)
Amplifier_Input.sendCommand("MPLAY")
Amplifier_Volume.sendCommand(targetDenonVolume)
say ("Good Morning. It's time go get going to school", new PercentType(targetMediaVolume))
Amplifier_Power.sendCommand(denonPower)// set power back to previous state
Amplifier_Input.sendCommand(denonSource)// set source back to previous state
Amplifier_Volume.sendCommand(denonVolume) // set volume back to previous volume
TTS_WeatherAnnounce.sendCommand(ON) // trigger reading out of the weather
end
rule "Announce Weather"
when
Item TTS_WeatherAnnounce changed
then
var tempCurrent = 0
var weatherCurrent = "blank"
var weather3h = "blank"
var weather6h = "blank"
var denonSource = "MPLAY" // placeholder, will be replaced by the initial Denon source
var denonVolume = 20 // placeholder, will be replaced by the initial Denon volume
var denonPower = OFF // placeholder
logInfo("TTS.rules", "Weather Announce Switch State Changed (rule engaged).")
denonPower = Amplifier_Power.state
denonSource = Amplifier_Input.state
denonVolume = Amplifier_Volume.state
if (TTS_WeatherAnnounce.state==ON){
logInfo("TTS.rules", "Weather Announce - condition found to be ON, processing.")
logInfo("TTS.rules", "Attempting to turn Amp ON")
Amplifier_Power.sendCommand(ON)
logInfo("TTS.rules", "Attempting to set Amp Mode")
Amplifier_Input.sendCommand("MPLAY")
logInfo("TTS.rules", "Attempting to set Amp Volume")
Amplifier_Volume.sendCommand(targetDenonVolume)
weatherCurrent = localCurrentCondition.state
tempCurrent = localCurrentTemperature.state
weather3h = local3hCondition.state
weather6h = local3hCondition.state
// for later, design with daily rain: localDailyForecastTodayRainVolume
// for later, design with daily snow: localDailyForecastTodaySnowVolume
logInfo("TTS.rules", "Attempting to play a sound")
playSound("doorbell.mp3")
logInfo("TTS.rules", "Attempting first simple SAY command")
say("Testing")
logInfo("TTS.rules", "Attempting rest of SAY commands")
if ((weatherCurrent==weather3h)&&(weatherCurrent==weather6h)) {
say ("The weather today will be all", new PercentType(targetMediaVolume))
say (weatherCurrent, new PercentType(targetMediaVolume))
}
else {
say ("The weather currently is")
say (weatherCurrent, new PercentType(targetMediaVolume))
say ("and later will be", new PercentType(targetMediaVolume))
say (weather3h, new PercentType(targetMediaVolume))
if (weather3h != weather6h) {
say ("and", new PercentType(targetMediaVolume))
say (weather6h, new PercentType(targetMediaVolume))
}
}
say ("The temperature is", new PercentType(targetMediaVolume))
say (tempCurrent, new PercentType(targetMediaVolume))
say ("degrees, with a high of", new PercentType(targetMediaVolume))
say (localDailyForecastTodayMaxTemperature.state, new PercentType(targetMediaVolume))
say ("degrees, and a low of", new PercentType(targetMediaVolume))
say (localDailyForecastTodayMinTemperature.state, new PercentType(targetMediaVolume))
say ("degrees", new PercentType(targetMediaVolume))
logInfo("TTS.rules", "Weather Announce - Speech Completed")
Amplifier_Power.sendCommand(denonPower)// set power back to previous state
Amplifier_Input.sendCommand(denonSource)// set source back to previous state
Amplifier_Volume.sendCommand(denonVolume) // set volume back to previous volume
TTS_WeatherAnnounce.sendCommand(OFF) // reset the weather announce flag
logInfo("TTS.rules", "Weather Announce - Rule Completed")
}
end
It seems I’ve been running around in circles trying to debug this. In this process I managed to create several problems, then solve them - leaving me with the initial problem of trying to use Kodi as an audio sink.
In Kodi’s guisettings.xml, all the UPNP options are enabled, on the off chance that’s important.
Any suggestions for debugging this?
Thanks!