v0.8.950
This commit is contained in:
@@ -39,7 +39,8 @@ from homeassistant.const import (
|
||||
CONF_NAME,
|
||||
STATE_IDLE,
|
||||
STATE_PLAYING,
|
||||
STATE_OFF
|
||||
STATE_OFF,
|
||||
STATE_ON,
|
||||
)
|
||||
|
||||
SUPPORT_YORADIO = SUPPORT_PAUSE | SUPPORT_PLAY | SUPPORT_STOP |\
|
||||
@@ -265,3 +266,11 @@ class yoradioDevice(MediaPlayerEntity):
|
||||
await self.api.set_command("stop")
|
||||
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(status, 0, BUFLEN*3);
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -107,6 +107,19 @@ void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties
|
||||
player.stepVol(true);
|
||||
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;
|
||||
if ( sscanf(buf, "vol %d", &volume) == 1) {
|
||||
if (volume < 0) volume = 0;
|
||||
|
||||
@@ -146,6 +146,8 @@ void Player::setOutputPins(bool isPlaying) {
|
||||
}
|
||||
|
||||
void Player::play(uint16_t stationId, uint32_t filePos) {
|
||||
remoteStationName = false;
|
||||
config.setDspOn(1);
|
||||
display.putRequest(PSTOP);
|
||||
setDefaults();
|
||||
setOutputPins(false);
|
||||
@@ -175,6 +177,8 @@ void Player::play(uint16_t stationId, uint32_t filePos) {
|
||||
|
||||
#ifdef MQTT_ROOT_TOPIC
|
||||
void Player::browseUrl(){
|
||||
remoteStationName = true;
|
||||
config.setDspOn(1);
|
||||
resumeAfterUrl = mode==PLAYING;
|
||||
display.putRequest(PSTOP);
|
||||
setDefaults();
|
||||
|
||||
@@ -41,6 +41,7 @@ class Player: public Audio {
|
||||
#ifdef MQTT_ROOT_TOPIC
|
||||
void browseUrl();
|
||||
#endif
|
||||
bool remoteStationName = false;
|
||||
void stop(const char *nttl = NULL);
|
||||
void prev();
|
||||
void next();
|
||||
|
||||
@@ -142,9 +142,11 @@ void audio_showstation(const char *info) {
|
||||
bool p = printable(info);
|
||||
config.setTitle(p?info:config.station.name);
|
||||
netserver.requestOnChange(TITLE, 0);
|
||||
config.setStation(p?info:config.station.name);
|
||||
display.putRequest(NEWSTATION);
|
||||
netserver.requestOnChange(STATION, 0);
|
||||
if(player.remoteStationName){
|
||||
config.setStation(p?info:config.station.name);
|
||||
display.putRequest(NEWSTATION);
|
||||
netserver.requestOnChange(STATION, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user