teddycloud icon indicating copy to clipboard operation
teddycloud copied to clipboard

Send MQTT event when Tonie gets removed from the Toniebox

Open monsdar opened this issue 1 year ago • 8 comments

It would be very useful for Home Assistant integration if an MQTT event (value?) is send when the Tonie finally gets removed from the box.

From the Forum thread (regarding the behavior of a Creative Tonie):

I noticed that the Content Audio Id first changes from Unknown to the Id of the media I’ve recorded. When I remove the Tonie while this is playing it changes back to Unknown. But when I leave the Tonie on the box, as soon as my recorded audio is finished the Content Audio Id changes to something else. When I now remove the Tonie the Id stays as it is.

Values for Tag Valid are changing in a similar manner: When I remove the Tonie during my recorded audio plays the value changes back to Unknown. But when the recorded audio is finished the Tag Valid won’t change anymore.

I checked the RTNL messages that occur when removing a Tonie and found that (besides a few others) the following messages appear every time:

Creative Tonie:

Raw2 | #1141 Uptime: 503842 Func: 15-8630 Payload: '10A41470E0040350' ASCII: '...p...P'
Raw2 | #1142 Uptime: 503842 Func: 24-6158 Payload: 'CA170000' ASCII: '....'

Benjamin Bluemchen Tonie:

Raw2 | #1521 Uptime: 884906 Func: 15-8630 Payload: '172091E4E0040350' ASCII: '. .....P'
Raw2 | #1523 Uptime: 884909 Func: 24-6139 Payload: 'CB170000CA170000' ASCII: '........'

Paddington Tonie:

Raw2 | #1428 Uptime: 743952 Func: 15-8630 Payload: '15EC056BE0040350' ASCII: '...k...P'
Raw2 | #1430 Uptime: 743955 Func: 24-6139 Payload: 'CB170000CA170000' ASCII: '........'

Perhaps this is a message we can use for this feature?

monsdar avatar Feb 11 '24 19:02 monsdar

Perhaps we can have a MQTT value like Tonie present = True/False that is updated whenever a Tonie is placed/removed.

monsdar avatar Feb 11 '24 19:02 monsdar

Do these also work after the tonies content was fully played?

PS: Here is the code responsible for the decoding. https://github.com/toniebox-reverse-engineering/teddycloud/blob/21f9c08e3daa13dde35991f7f568674f2e98641f/src/handler_rtnl.c#L156 https://github.com/toniebox-reverse-engineering/teddycloud/blob/master/include/handler_rtnl.h#L72

SciLor avatar Feb 11 '24 20:02 SciLor

Yes, these are also working after the Tonie has been fully played (just went through a whole playback of Benjamin Bluemchen for it...).

After Benjamin finished I took the Tonie off and got this:

Raw2 | #331 Uptime: 2641791 Func: 15-8630 Payload: '172091E4E0040350' ASCII: '. .....P'
Raw2 | #332 Uptime: 2641791 Func: 24-6158 Payload: 'CA170000' ASCII: '....'

So it's similar to the one I'm getting for the finished Creative Tonie.

monsdar avatar Feb 11 '24 21:02 monsdar

In addition: The following appears whenever I place a Tonie onto the box:

Raw2 | #381 Uptime: 2853368 Func: 15-8627 Payload: '172091E4E0040350' ASCII: '. .....P'
Raw3 | Datetime: 1707685649 Unknown: 11
Raw2 | #382 Uptime: 2853369 Func: 24-6139 Payload: 'CA170000CB170000' ASCII: '........'

Only thing that differs in 15-8627 is the Payload. Seems to be the ID of the Tonie I placed. I guess it's used in conjunction with the Timestamp, i.e. "Tonie XYZ has been placed at XX:YY".

Note that in 24-6139 the payload is in reverse to what is being shown when a Tonie is removed. It seems to be some kind of transition:

  • Tonie is placed on the box: CA170000CB170000
  • Tonie is removed during play: CB170000CA170000
  • Tonie is removed after play finished: CA170000

monsdar avatar Feb 11 '24 21:02 monsdar

Which kind of box do you have?

SciLor avatar Feb 12 '24 10:02 SciLor

It's a CC3200 with PD_V3.1.0_BF5-0 firmware.

monsdar avatar Feb 19 '24 20:02 monsdar

It's a CC3200 with PD_V3.1.0_BF5-0 firmware.

Are you sure you are booting the PD Firmware? This shouldn't be the case, as this is a production firmware. Slot ofw2 doesn't boot mcuimg2.

SciLor avatar Feb 19 '24 21:02 SciLor

Which kind of box do you have?

Has anyone experimented with this on V4 (ESP32) boxes? I am looking to make this work as well.

Koraikoaw avatar Jul 11 '24 14:07 Koraikoaw