Tobi78
(Tobi)
January 20, 2022, 7:11pm
1
Hello, I use ESPHome through my iobroker. I have a DFPlayer connected to a Wemos D1 Mini.
I flashed the YAML, but how do I control the DFPlayer?
esphome:
name: esp8266-ghwc
esp8266:
board: d1_mini
# Enable logging
logger:
level: VERBOSE
uart:
tx_pin: GPIO1
rx_pin: GPIO3
baud_rate: 9600
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
web_server:
port: 80
dfplayer:
on_finished_playback:
then:
logger.log: 'Playback finished event'
api:
services:
- service: dfplayer_next
then:
- dfplayer.play_next:
- service: dfplayer_previous
then:
- dfplayer.play_previous:
- service: dfplayer_play
variables:
file: int
then:
- dfplayer.play: !lambda 'return file;'
- service: dfplayer_play_loop
variables:
file: int
loop_: bool
then:
- dfplayer.play:
file: !lambda 'return file;'
loop: !lambda 'return loop_;'
- service: dfplayer_play_folder
variables:
folder: int
file: int
then:
- dfplayer.play_folder:
folder: !lambda 'return folder;'
file: !lambda 'return file;'
- service: dfplayer_play_loop_folder
variables:
folder: int
then:
- dfplayer.play_folder:
folder: !lambda 'return folder;'
loop: true
- service: dfplayer_set_device_tf
then:
- dfplayer.set_device: TF_CARD
- service: dfplayer_set_device_usb
then:
- dfplayer.set_device: USB
- service: dfplayer_set_volume
variables:
volume: int
then:
- dfplayer.set_volume: !lambda 'return volume;'
- service: dfplayer_set_eq
variables:
preset: int
then:
- dfplayer.set_eq: !lambda 'return static_cast<dfplayer::EqPreset>(preset);'
- service: dfplayer_sleep
then:
- dfplayer.sleep
- service: dfplayer_reset
then:
- dfplayer.reset
- service: dfplayer_start
then:
- dfplayer.start
- service: dfplayer_pause
then:
- dfplayer.pause
- service: dfplayer_stop
then:
- dfplayer.stop
- service: dfplayer_random
then:
- dfplayer.random
- service: dfplayer_volume_up
then:
- dfplayer.volume_up
- service: dfplayer_volume_down
then:
- dfplayer.volume_down
I hoped that the variables would be shown to me when the API is active.
Hellis81
(Hellis81)
January 20, 2022, 7:14pm
2
Go to developer tools → services.
There should be a service for each of the “stuff” you placed under api: in the yaml.
nickrout
(Nick Rout)
January 20, 2022, 8:01pm
3
iobroker is not HA. The answer is, I have no idea.
Hellis81
(Hellis81)
January 20, 2022, 8:06pm
4
ahh…
I didn’t get what OP meant.
Perhaps if you enable web server on the device you can use the webpage on the devices IP.
nickrout
(Nick Rout)
January 20, 2022, 8:22pm
5
Jpsy
(Jörg Wagner)
January 21, 2022, 2:48am
6
Wow. Isn’t it a bit scary to see how ESPHome creeps into other Home Automation systems and builds up pressure to migrate to HA?
1 Like
nickrout
(Nick Rout)
January 21, 2022, 3:59am
7
It seems from my reading that the underlying API does not yet support services, but I may be misreading or reading in the wrong place. The OP hasn’t replied that the integration I found is the one he is using.
Tobi78
(Tobi)
January 21, 2022, 4:56am
8
Yes exactly, I used this tool for that.
So far everything that I have used has worked, only the DFPlayer does not show any control variables.
I’m sorry for my bad English.
Tobi78
(Tobi)
January 21, 2022, 5:02am
9
Yes, I think it’s great because you can choose the best one. All very great work, no matter which system.
nickrout
(Nick Rout)
January 21, 2022, 6:15am
10
@Tobi78 no problem with your English.
As far as I can tell GitHub - DrozmotiX/ioBroker.esphome: Control your ESP8266/ESP32 with simple yet powerful configuration files created and managed by ESPHome (an ioBroker implementation of esphome) depends on GitHub - Nafaya/esphome-native-api (a nodescript implenentation of the esphome API). However esphome-native-api does not seem to implement services - see please add HomeAssistent service (get and command) · Issue #17 · Nafaya/esphome-native-api · GitHub
Quite what the solution is without access to services I am unsure. Perhaps ask on either of those githubs.
Maybe by using template buttons/swiches within esphome to get the functions exposed @Tobi78
Tobi78
(Tobi)
January 21, 2022, 2:24pm
12
It would be enough for me if I could address him via IP, for example:
http://192.168.178.174/cm?cmnd=MP3Track3
nickrout
(Nick Rout)
January 21, 2022, 7:18pm
13
That may be possible, I don’t have a dfplayer to try. See the api that the web server exposes
Jpsy
(Jörg Wagner)
January 21, 2022, 9:03pm
14
Sorry Nick, but I think this would rather be done through the HTTP Request component using a http_request.get
or http_request.send
action.
If needed you could use a lambda to build the DFPlayer URL including any variables in query string parameters.
nickrout
(Nick Rout)
January 21, 2022, 9:22pm
15
As I understand it, the http_request is to send an http_request FROM the esp device, whereas we are trying send a request TO the esp device.
Jpsy
(Jörg Wagner)
January 21, 2022, 9:35pm
16
Oh, if that’s the case then you are definitely correct!
Reading @Tobi78 ’s comment again I am still not sure which of these two options he is talking about.
1 Like
Tobi78
(Tobi)
January 22, 2022, 7:30pm
17
I’m sorry, I’m not that deep into the topic.
I actually just want to control the player from my IoBroker via the ESPHome tool.
since there are no controls, I thought you could do it with the command http://192.168.178.174/ Play Track 1.
But I don’t know exactly what I would have to enter for it.
Hellis81
(Hellis81)
January 22, 2022, 7:35pm
18
MQTT seems to be a way to do it.
MQTT Client Component — ESPHome
No experience of it though.
Jpsy
(Jörg Wagner)
January 22, 2022, 8:21pm
19
Still not clear to me:
Is 192.168.178.174 the IP of your ESP or of your DFPlayer? I don’t know this player so I cannot conclude if these are HTTP request that your player understands or request endpoints that you want to implement to control your ESP.
Hellis81
(Hellis81)
January 22, 2022, 8:23pm
20
The DF-player is a small component you connect to an arduino or ESP.
So I would assume the IP is the ESP since there is not IP on the DF-player since it is connected with UART.
DF-Player mini — ESPHome
1 Like