I did manage to get this to work. In summary, Lyngdorf has a tcp interface to receive commands. I set up media_template to interface with a Node-RED interface via MQTT commands.
That said, someone is in the works to create a full Lyngdorf integration - am eagerly waiting for that!
First, you’ll need to create some sensors using MQTT (to receive the tcp commands and volume control), and also a boolean status to detect power mode:
mqtt:
sensor:
- name: "TDAI-TCP"
state_topic: "/tdai/tcp"
- name: "TDAI-SetVol"
state_topic: "/tdai/setvolume"
input_boolean:
tdai_powerstatus:
name: TDAI Power
icon: mdi:receiver
initial: off
This is the media template configuration. Not everything is working but it suffices for me.
media_player:
- platform: media_player_template
media_players:
tdai_1120:
friendly_name: TDAI-1120
device_class: receiver
current_source_template: "{{ states('sensor.tdai_1120_source') }}"
current_volume_template: "{{ states('sensor.tdai_1120_volume') }}"
value_template: >
{% if is_state("input_boolean.tdai_powerstatus", "on") -%}
on
{%- else -%}
off
{%- endif %}
turn_on:
service: mqtt.publish
data:
topic: "tdai/tcp"
payload: "!ON"
turn_off:
service: mqtt.publish
data:
topic: "tdai/tcp"
payload: "!OFF"
volume_up:
service: mqtt.publish
data:
topic: "tdai/tcp"
payload: "!VOLUP"
volume_down:
service: mqtt.publish
data:
topic: "tdai/tcp"
payload: "!VOLDN"
inputs:
Computer:
service: mqtt.publish
data:
topic: "tdai/tcp"
payload: "!SRC(6)"
Spotify:
service: mqtt.publish
data:
topic: "tdai/tcp"
payload: "!SRC(8)"
Chromecast:
service: mqtt.publish
data:
topic: "tdai/tcp"
payload: "!SRC(7)"
set_volume:
service: input_text.set_value
data:
entity_id: input_text.selected_volume
value: "{{volume}}"
mute:
service: mqtt.publish
data:
topic: "tdai/tcp"
payload: "!MUTE"
# service: input_number.set_value
# data:
# entity_id: input_number.selected_is_muted
# value: "{{is_muted}}"
# current_is_muted_template: >
# {{ states('input_boolean.is_muted') }}
# album_art_template: "{{ states('input_text.album_art') }}"
# title_template: "{{ states('input_text.title') }}"
# album_template: "{{ states('input_text.album') }}"
# artist_template: "{{ states('input_text.artist') }}"
Lastly, you need to install Node-RED, and import the code here. You will need to update all nodes indicated “TDAI TCP” with your TDAI’s IP address.
[{"id":"817bda0157563770","type":"tab","label":"TDAI","disabled":false,"info":"","env":[]},{"id":"1e25f439db7c41f2","type":"function","z":"817bda0157563770","name":"VOL","func":"msg.payload = \"!VOL?\\n\"\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":870,"y":560,"wires":[["5adc54bbd5e1f1b4"]]},{"id":"21dc72af88200195","type":"inject","z":"817bda0157563770","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":620,"y":520,"wires":[[]]},{"id":"5adc54bbd5e1f1b4","type":"tcp request","z":"817bda0157563770","name":"TDAI TCP","server":"192.168.3.14","port":"84","out":"char","ret":"string","splitc":"\\n","newline":"","trim":false,"tls":"","x":1010,"y":560,"wires":[["a2481608fb510172"]]},{"id":"c19b2d05ba8ae091","type":"poll-state","z":"817bda0157563770","name":"TDAI Power","server":"8ceaa1a2.5a09f","version":3,"exposeAsEntityConfig":"","updateInterval":"10","updateIntervalType":"num","updateIntervalUnits":"seconds","outputInitially":true,"outputOnChanged":true,"entityId":"input_boolean.tdai_powerstatus","stateType":"str","ifState":"on","ifStateType":"str","ifStateOperator":"is","outputs":2,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":610,"y":580,"wires":[["1e25f439db7c41f2","1fc49fb532090529"],[]]},{"id":"a2481608fb510172","type":"function","z":"817bda0157563770","name":"Parse VOL","func":"msg.payload = msg.payload.toString('utf8')\nlet trim = msg.payload.trim()\nlet text = trim.split('(')[1]\nlet output = text.slice(0,-1)\nmsg.payload = output / 10\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1170,"y":560,"wires":[["03895453be07f1c9"]]},{"id":"03895453be07f1c9","type":"ha-sensor","z":"817bda0157563770","name":"TDAI Volume","entityConfig":"0ffbecd6a8416847","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":1330,"y":560,"wires":[[]]},{"id":"1fc49fb532090529","type":"function","z":"817bda0157563770","name":"SRCNAME","func":"msg.payload = \"!SRCNAME?\\n\"\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":850,"y":500,"wires":[["ee2e4b89572a97f0"]]},{"id":"ee2e4b89572a97f0","type":"tcp request","z":"817bda0157563770","name":"TDAI TCP","server":"192.168.3.14","port":"84","out":"char","ret":"string","splitc":"\\n","newline":"","trim":false,"tls":"","x":1010,"y":500,"wires":[["e8c6b9573b656402"]]},{"id":"e8c6b9573b656402","type":"function","z":"817bda0157563770","name":"Parse SRC","func":"msg.payload = msg.payload.toString('utf8')\nlet trim = msg.payload.trim()\nlet text = trim.split('\"')[1]\nmsg.payload = text\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1170,"y":500,"wires":[["51eb191e94cb82ea"]]},{"id":"51eb191e94cb82ea","type":"ha-sensor","z":"817bda0157563770","name":"TDAI Source","entityConfig":"b0f71ceab7f4a062","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":1330,"y":500,"wires":[[]]},{"id":"0998489497d46ce2","type":"mqtt in","z":"817bda0157563770","name":"TDAI-TCP","topic":"tdai/tcp","qos":"0","datatype":"auto-detect","broker":"de32d2e0f0f9525e","nl":false,"rap":true,"rh":0,"inputs":0,"x":300,"y":360,"wires":[["729487b213e153ab"]]},{"id":"e679d3429217cac4","type":"tcp request","z":"817bda0157563770","name":"TDAI TCP","server":"192.168.3.14","port":"84","out":"char","ret":"string","splitc":"\\n","newline":"","trim":false,"tls":"","x":610,"y":360,"wires":[[]]},{"id":"729487b213e153ab","type":"function","z":"817bda0157563770","name":"TCP Input","func":"msg.payload = msg.payload + '\\n'\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":440,"y":360,"wires":[["e679d3429217cac4","4b8f6b9e6a0faee1"]]},{"id":"910f7fc789cc5cda","type":"function","z":"817bda0157563770","name":"PWR","func":"msg.payload = \"!PWR?\\n\"\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":870,"y":700,"wires":[["15a103e255b62575"]]},{"id":"15a103e255b62575","type":"tcp request","z":"817bda0157563770","name":"TDAI TCP","server":"192.168.3.14","port":"84","out":"char","ret":"buffer","splitc":"\\n","newline":"","trim":false,"tls":"","x":1010,"y":700,"wires":[["bdf1e35213934646"]]},{"id":"bdf1e35213934646","type":"function","z":"817bda0157563770","name":"Parse PWR","func":"msg.payload = msg.payload.toString('utf8')\nlet trim = msg.payload.trim()\nlet text = trim.split('(')[1]\nlet output = text.slice(0,-1)\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1170,"y":700,"wires":[["87f83d4f9fef106c"]]},{"id":"1a614b9dff49fbc8","type":"poll-state","z":"817bda0157563770","name":"Powered on?","server":"8ceaa1a2.5a09f","version":3,"exposeAsEntityConfig":"","updateInterval":"60","updateIntervalType":"num","updateIntervalUnits":"seconds","outputInitially":true,"outputOnChanged":true,"entityId":"media_player.room","stateType":"str","ifState":"unavailable","ifStateType":"str","ifStateOperator":"is_not","outputs":2,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":610,"y":700,"wires":[["910f7fc789cc5cda"],[]]},{"id":"64e5674550ee4c62","type":"api-call-service","z":"817bda0157563770","name":"TDAI is on","server":"8ceaa1a2.5a09f","version":5,"debugenabled":true,"domain":"input_boolean","service":"turn_on","areaId":[],"deviceId":[],"entityId":["input_boolean.tdai_powerstatus"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1510,"y":680,"wires":[[]]},{"id":"87f83d4f9fef106c","type":"switch","z":"817bda0157563770","name":"PWR status","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"!PWR(ON)","vt":"str"},{"t":"cont","v":"!PWR(OFF)","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1330,"y":700,"wires":[["64e5674550ee4c62"],["8cf2286bc9be0ab8"]]},{"id":"8cf2286bc9be0ab8","type":"api-call-service","z":"817bda0157563770","name":"TDAI is off","server":"8ceaa1a2.5a09f","version":5,"debugenabled":true,"domain":"input_boolean","service":"turn_off","areaId":[],"deviceId":[],"entityId":["input_boolean.tdai_powerstatus"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1510,"y":740,"wires":[[]]},{"id":"29b65025d6def908","type":"api-call-service","z":"817bda0157563770","name":"TDAI is on","server":"8ceaa1a2.5a09f","version":5,"debugenabled":true,"domain":"input_boolean","service":"turn_on","areaId":[],"deviceId":[],"entityId":["input_boolean.tdai_powerstatus"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":850,"y":380,"wires":[[]]},{"id":"4b8f6b9e6a0faee1","type":"switch","z":"817bda0157563770","name":"Parse input trigger","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"!ON","vt":"str"},{"t":"cont","v":"!OFF","vt":"str"},{"t":"cont","v":"SRC","vt":"str"},{"t":"cont","v":"!VOL","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":630,"y":420,"wires":[["29b65025d6def908"],["911ee78b2a565feb"],["1fc49fb532090529"],["1e25f439db7c41f2"]]},{"id":"911ee78b2a565feb","type":"api-call-service","z":"817bda0157563770","name":"TDAI is off","server":"8ceaa1a2.5a09f","version":5,"debugenabled":true,"domain":"input_boolean","service":"turn_off","areaId":[],"deviceId":[],"entityId":["input_boolean.tdai_powerstatus"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":850,"y":420,"wires":[[]]},{"id":"8ceaa1a2.5a09f","type":"server","name":"HomeAssistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"","connectionDelay":false,"cacheJson":false,"heartbeat":false,"heartbeatInterval":"","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true},{"id":"0ffbecd6a8416847","type":"ha-entity-config","server":"8ceaa1a2.5a09f","deviceConfig":"30f7e9dc29c13dea","name":"tdai.volume","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"TDAI-1120 Volume"},{"property":"icon","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":"dB"},{"property":"state_class","value":""}],"resend":false,"debugEnabled":false},{"id":"b0f71ceab7f4a062","type":"ha-entity-config","server":"8ceaa1a2.5a09f","deviceConfig":"30f7e9dc29c13dea","name":"tdai.source","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"TDAI-1120 Source"},{"property":"icon","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""}],"resend":false,"debugEnabled":false},{"id":"de32d2e0f0f9525e","type":"mqtt-broker","name":"HA-MQTT","broker":"localhost","port":"1883","clientid":"core-mosquitto","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""},{"id":"30f7e9dc29c13dea","type":"ha-device-config","name":"TDAI-1120","hwVersion":"","manufacturer":"Lyngdorf","model":"","swVersion":""}]