v0.8.950
This commit is contained in:
@@ -39,7 +39,8 @@ from homeassistant.const import (
|
|||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
STATE_IDLE,
|
STATE_IDLE,
|
||||||
STATE_PLAYING,
|
STATE_PLAYING,
|
||||||
STATE_OFF
|
STATE_OFF,
|
||||||
|
STATE_ON,
|
||||||
)
|
)
|
||||||
|
|
||||||
SUPPORT_YORADIO = SUPPORT_PAUSE | SUPPORT_PLAY | SUPPORT_STOP |\
|
SUPPORT_YORADIO = SUPPORT_PAUSE | SUPPORT_PLAY | SUPPORT_STOP |\
|
||||||
@@ -265,3 +266,11 @@ class yoradioDevice(MediaPlayerEntity):
|
|||||||
await self.api.set_command("stop")
|
await self.api.set_command("stop")
|
||||||
self._state = STATE_IDLE
|
self._state = STATE_IDLE
|
||||||
|
|
||||||
|
async def async_turn_off(self):
|
||||||
|
await self.api.set_command("turnoff")
|
||||||
|
self._state = STATE_OFF
|
||||||
|
|
||||||
|
async def async_turn_on(self, **kwargs):
|
||||||
|
await self.api.set_command("turnon")
|
||||||
|
self._state = STATE_ON
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ void mqttPublishStatus() {
|
|||||||
memset(topic, 0, 140);
|
memset(topic, 0, 140);
|
||||||
memset(status, 0, BUFLEN*3);
|
memset(status, 0, BUFLEN*3);
|
||||||
sprintf(topic, "%s%s", MQTT_ROOT_TOPIC, "status");
|
sprintf(topic, "%s%s", MQTT_ROOT_TOPIC, "status");
|
||||||
sprintf(status, "{\"status\": %d, \"station\": %d, \"name\": \"%s\", \"title\": \"%s\"}", player.mode==PLAYING?1:0, config.store.lastStation, config.station.name, config.station.title);
|
sprintf(status, "{\"status\": %d, \"station\": %d, \"name\": \"%s\", \"title\": \"%s\", \"on\": %d}", player.mode==PLAYING?1:0, config.store.lastStation, config.station.name, config.station.title, config.store.dspon);
|
||||||
mqttClient.publish(topic, 0, true, status);
|
mqttClient.publish(topic, 0, true, status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -107,6 +107,19 @@ void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties
|
|||||||
player.stepVol(true);
|
player.stepVol(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (strcmp(buf, "turnoff") == 0) {
|
||||||
|
uint8_t sst = config.store.smartstart;
|
||||||
|
player.stop();
|
||||||
|
config.store.smartstart = sst;
|
||||||
|
config.save();
|
||||||
|
config.setDspOn(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (strcmp(buf, "turnon") == 0) {
|
||||||
|
config.setDspOn(1);
|
||||||
|
if (config.store.smartstart == 1) player.play(config.store.lastStation);
|
||||||
|
return;
|
||||||
|
}
|
||||||
int volume;
|
int volume;
|
||||||
if ( sscanf(buf, "vol %d", &volume) == 1) {
|
if ( sscanf(buf, "vol %d", &volume) == 1) {
|
||||||
if (volume < 0) volume = 0;
|
if (volume < 0) volume = 0;
|
||||||
|
|||||||
@@ -146,6 +146,8 @@ void Player::setOutputPins(bool isPlaying) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Player::play(uint16_t stationId, uint32_t filePos) {
|
void Player::play(uint16_t stationId, uint32_t filePos) {
|
||||||
|
remoteStationName = false;
|
||||||
|
config.setDspOn(1);
|
||||||
display.putRequest(PSTOP);
|
display.putRequest(PSTOP);
|
||||||
setDefaults();
|
setDefaults();
|
||||||
setOutputPins(false);
|
setOutputPins(false);
|
||||||
@@ -175,6 +177,8 @@ void Player::play(uint16_t stationId, uint32_t filePos) {
|
|||||||
|
|
||||||
#ifdef MQTT_ROOT_TOPIC
|
#ifdef MQTT_ROOT_TOPIC
|
||||||
void Player::browseUrl(){
|
void Player::browseUrl(){
|
||||||
|
remoteStationName = true;
|
||||||
|
config.setDspOn(1);
|
||||||
resumeAfterUrl = mode==PLAYING;
|
resumeAfterUrl = mode==PLAYING;
|
||||||
display.putRequest(PSTOP);
|
display.putRequest(PSTOP);
|
||||||
setDefaults();
|
setDefaults();
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ class Player: public Audio {
|
|||||||
#ifdef MQTT_ROOT_TOPIC
|
#ifdef MQTT_ROOT_TOPIC
|
||||||
void browseUrl();
|
void browseUrl();
|
||||||
#endif
|
#endif
|
||||||
|
bool remoteStationName = false;
|
||||||
void stop(const char *nttl = NULL);
|
void stop(const char *nttl = NULL);
|
||||||
void prev();
|
void prev();
|
||||||
void next();
|
void next();
|
||||||
|
|||||||
@@ -142,11 +142,13 @@ void audio_showstation(const char *info) {
|
|||||||
bool p = printable(info);
|
bool p = printable(info);
|
||||||
config.setTitle(p?info:config.station.name);
|
config.setTitle(p?info:config.station.name);
|
||||||
netserver.requestOnChange(TITLE, 0);
|
netserver.requestOnChange(TITLE, 0);
|
||||||
|
if(player.remoteStationName){
|
||||||
config.setStation(p?info:config.station.name);
|
config.setStation(p?info:config.station.name);
|
||||||
display.putRequest(NEWSTATION);
|
display.putRequest(NEWSTATION);
|
||||||
netserver.requestOnChange(STATION, 0);
|
netserver.requestOnChange(STATION, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void audio_showstreamtitle(const char *info) {
|
void audio_showstreamtitle(const char *info) {
|
||||||
DBGH();
|
DBGH();
|
||||||
|
|||||||
Reference in New Issue
Block a user