A workaround could be using an IR multi remote instead of the original one, program an esp8266 with an IR receiver to fire events for every key into HA and react to them to control both your TV and your receiver. I know, this is frustrating, but it avoids detective work. I can provide some codes for esphome and node-red how i did this:
node-red flow split-events
[{"id":"22e84c05.fe0b64","type":"tab","label":"RemoteCodesToEvents","disabled":false,"info":""},{"id":"b25c95cf.15a7f8","type":"server-events","z":"22e84c05.fe0b64","name":"","server":"e0fa7932.da39f8","event_type":"esphome.Remote","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"waitForRunning":true,"x":110,"y":100,"wires":[["5670c130.b572d"]]},{"id":"5670c130.b572d","type":"switch","z":"22e84c05.fe0b64","name":"","property":"payload.event.value","propertyType":"msg","rules":[{"t":"eq","v":"3772810873","vt":"str"},{"t":"eq","v":"3772819033","vt":"str"},{"t":"eq","v":"3772794553","vt":"str"},{"t":"eq","v":"3772778233","vt":"str"},{"t":"eq","v":"3772782313","vt":"str"},{"t":"eq","v":"3772833823","vt":"str"},{"t":"eq","v":"3772829743","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":8,"x":300,"y":120,"wires":[["1f29ed54.507aeb"],["5739ac15.28bf5c"],["da90bb59.8d5048"],["db8ed98e.956728"],["71177700.d8f02"],["cc7185d4.7e3cd8"],["e5288ee2.eb0d68"],["4101df31.f466d"]]},{"id":"30eebac5.47771e","type":"ha-fire-event","z":"22e84c05.fe0b64","name":"","server":"4ef35426.cb7c7c","event":"remote.down","data":"","dataType":"json","x":940,"y":20,"wires":[[]]},{"id":"487f56f.e2404a8","type":"ha-fire-event","z":"22e84c05.fe0b64","name":"","server":"e0fa7932.da39f8","event":"remote.left","data":"","dataType":"json","x":1130,"y":60,"wires":[[]]},{"id":"7702a337.3eb31c","type":"ha-fire-event","z":"22e84c05.fe0b64","name":"","server":"e0fa7932.da39f8","event":"remote.right","data":"","dataType":"json","x":870,"y":100,"wires":[[]]},{"id":"ee1463f3.6cb9c8","type":"ha-fire-event","z":"22e84c05.fe0b64","name":"","server":"e0fa7932.da39f8","event":"remote.up","data":"","dataType":"json","x":1270,"y":140,"wires":[[]]},{"id":"109fe954.615c7f","type":"ha-fire-event","z":"22e84c05.fe0b64","name":"","server":"e0fa7932.da39f8","event":"remote.ok","data":"","dataType":"json","x":930,"y":180,"wires":[[]]},{"id":"27cd08a2.18aba","type":"ha-fire-event","z":"22e84c05.fe0b64","name":"","server":"e0fa7932.da39f8","event":"remote.vol_up","data":"","dataType":"json","x":1100,"y":220,"wires":[[]]},{"id":"4c580669.88b958","type":"ha-fire-event","z":"22e84c05.fe0b64","name":"","server":"e0fa7932.da39f8","event":"remote.vol_down","data":"","dataType":"json","x":890,"y":260,"wires":[[]]},{"id":"1f29ed54.507aeb","type":"change","z":"22e84c05.fe0b64","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":20,"wires":[["dc03733a.84f528"]]},{"id":"5739ac15.28bf5c","type":"change","z":"22e84c05.fe0b64","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":60,"wires":[["b83ea568.ce198"]]},{"id":"db8ed98e.956728","type":"change","z":"22e84c05.fe0b64","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":140,"wires":[["f7a50cd2.b8f42"]]},{"id":"71177700.d8f02","type":"change","z":"22e84c05.fe0b64","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":180,"wires":[["4fed1091.108a58"]]},{"id":"cc7185d4.7e3cd8","type":"change","z":"22e84c05.fe0b64","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":220,"wires":[["27cd08a2.18aba"]]},{"id":"da90bb59.8d5048","type":"change","z":"22e84c05.fe0b64","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":100,"wires":[["c317413e.545e58"]]},{"id":"e5288ee2.eb0d68","type":"change","z":"22e84c05.fe0b64","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":260,"wires":[["4c580669.88b958"]]},{"id":"4101df31.f466d","type":"switch","z":"22e84c05.fe0b64","name":"","property":"payload.event.value","propertyType":"msg","rules":[{"t":"eq","v":"3772784863","vt":"str"},{"t":"eq","v":"3772817503","vt":"str"},{"t":"eq","v":"3772801183","vt":"str"},{"t":"eq","v":"3772780783","vt":"str"},{"t":"eq","v":"3772813423","vt":"str"},{"t":"eq","v":"3772797103","vt":"str"},{"t":"eq","v":"3772788943","vt":"str"},{"t":"eq","v":"3772821583","vt":"str"},{"t":"eq","v":"3772805263","vt":"str"},{"t":"eq","v":"3772811383","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":11,"x":300,"y":440,"wires":[["c60fd2fc.d76468"],["65b4187b.dbf81"],["2ea12959.466246"],["87af6389.c4abc"],["318cfc7.ba6c404"],["13948aa8.eaa735"],["32682e7a.2f032a"],["f204507f.3ad82"],["eb756953.1f4478"],["3432ae96.da3502"],["ae3bbf31.c4402"]]},{"id":"c60fd2fc.d76468","type":"change","z":"22e84c05.fe0b64","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":320,"wires":[["e0b6f4fe.82ad5"]]},{"id":"65b4187b.dbf81","type":"change","z":"22e84c05.fe0b64","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":360,"wires":[["1ffe0cee.c37ed3"]]},{"id":"2ea12959.466246","type":"change","z":"22e84c05.fe0b64","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":400,"wires":[["be0da9e5.22f1d"]]},{"id":"87af6389.c4abc","type":"change","z":"22e84c05.fe0b64","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":440,"wires":[["28ca99e6.395b2e"]]},{"id":"318cfc7.ba6c404","type":"change","z":"22e84c05.fe0b64","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":480,"wires":[["a4806c89.4ee9e8"]]},{"id":"13948aa8.eaa735","type":"change","z":"22e84c05.fe0b64","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":520,"wires":[["3da45379.327b6c"]]},{"id":"32682e7a.2f032a","type":"change","z":"22e84c05.fe0b64","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":560,"wires":[["d6ad661e.e5d938"]]},{"id":"f204507f.3ad82","type":"change","z":"22e84c05.fe0b64","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":600,"wires":[["dcca3cda.048bf"]]},{"id":"eb756953.1f4478","type":"change","z":"22e84c05.fe0b64","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":640,"wires":[["f4d010d5.c82d9"]]},{"id":"3432ae96.da3502","type":"change","z":"22e84c05.fe0b64","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":680,"wires":[["b47af573.b5c538"]]},{"id":"e0b6f4fe.82ad5","type":"ha-fire-event","z":"22e84c05.fe0b64","name":"","server":"e0fa7932.da39f8","event":"remote.1","data":"","dataType":"json","x":640,"y":320,"wires":[[]]},{"id":"1ffe0cee.c37ed3","type":"ha-fire-event","z":"22e84c05.fe0b64","name":"","server":"e0fa7932.da39f8","event":"remote.2","data":"","dataType":"json","x":680,"y":360,"wires":[[]]},{"id":"be0da9e5.22f1d","type":"ha-fire-event","z":"22e84c05.fe0b64","name":"","server":"e0fa7932.da39f8","event":"remote.3","data":"","dataType":"json","x":700,"y":400,"wires":[[]]},{"id":"28ca99e6.395b2e","type":"ha-fire-event","z":"22e84c05.fe0b64","name":"","server":"e0fa7932.da39f8","event":"remote.4","data":"","dataType":"json","x":740,"y":440,"wires":[[]]},{"id":"a4806c89.4ee9e8","type":"ha-fire-event","z":"22e84c05.fe0b64","name":"","server":"e0fa7932.da39f8","event":"remote.5","data":"","dataType":"json","x":760,"y":480,"wires":[[]]},{"id":"3da45379.327b6c","type":"ha-fire-event","z":"22e84c05.fe0b64","name":"","server":"e0fa7932.da39f8","event":"remote.6","data":"","dataType":"json","x":780,"y":520,"wires":[[]]},{"id":"d6ad661e.e5d938","type":"ha-fire-event","z":"22e84c05.fe0b64","name":"","server":"e0fa7932.da39f8","event":"remote.7","data":"","dataType":"json","x":800,"y":560,"wires":[[]]},{"id":"dcca3cda.048bf","type":"ha-fire-event","z":"22e84c05.fe0b64","name":"","server":"e0fa7932.da39f8","event":"remote.8","data":"","dataType":"json","x":840,"y":600,"wires":[[]]},{"id":"f4d010d5.c82d9","type":"ha-fire-event","z":"22e84c05.fe0b64","name":"","server":"e0fa7932.da39f8","event":"remote.9","data":"","dataType":"json","x":840,"y":640,"wires":[[]]},{"id":"b47af573.b5c538","type":"ha-fire-event","z":"22e84c05.fe0b64","name":"","server":"e0fa7932.da39f8","event":"remote.0","data":"","dataType":"json","x":860,"y":680,"wires":[[]]},{"id":"ae3bbf31.c4402","type":"switch","z":"22e84c05.fe0b64","name":"","property":"payload.event.value","propertyType":"msg","rules":[{"t":"eq","v":"3772793023","vt":"str"},{"t":"eq","v":"3772809343","vt":"str"},{"t":"eq","v":"3772799143","vt":"str"},{"t":"eq","v":"3772838413","vt":"str"},{"t":"eq","v":"3772808323","vt":"str"},{"t":"eq","v":"3772822603","vt":"str"},{"t":"eq","v":"3772839943","vt":"str"},{"t":"eq","v":"3772790473","vt":"str"},{"t":"eq","v":"3772786903","vt":"str"},{"t":"eq","v":"3772819543","vt":"str"},{"t":"eq","v":"3772803223","vt":"str"}],"checkall":"true","repair":false,"outputs":11,"x":340,"y":880,"wires":[["bf0e8087.e9af"],["f87fec35.abe098"],["f459dcba.576a6"],["d920c253.c1799"],["b9abcedc.19783"],["a911c3a4.f6a18"],["2270e471.5b42bc"],["29d9363c.e365aa"],["3f9dc702.f21c98"],["f4b07e74.0961f8"],["e6d6f01.094a41"]]},{"id":"bf0e8087.e9af","type":"change","z":"22e84c05.fe0b64","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":760,"wires":[["39e4d513.e96f2a"]]},{"id":"f87fec35.abe098","type":"change","z":"22e84c05.fe0b64","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":800,"wires":[["78b3613a.f6653"]]},{"id":"f459dcba.576a6","type":"change","z":"22e84c05.fe0b64","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":840,"wires":[["a4cd2784.ba4948"]]},{"id":"d920c253.c1799","type":"change","z":"22e84c05.fe0b64","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":880,"wires":[["e5459be.17568e8"]]},{"id":"b9abcedc.19783","type":"change","z":"22e84c05.fe0b64","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":920,"wires":[["9eae0db6.8cbba8"]]},{"id":"a911c3a4.f6a18","type":"change","z":"22e84c05.fe0b64","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":960,"wires":[["f1af4691.c078c8"]]},{"id":"2270e471.5b42bc","type":"change","z":"22e84c05.fe0b64","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":1000,"wires":[["3a368fe0.0adff8"]]},{"id":"29d9363c.e365aa","type":"change","z":"22e84c05.fe0b64","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":1040,"wires":[["11416ff1.a937c"]]},{"id":"3f9dc702.f21c98","type":"change","z":"22e84c05.fe0b64","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":1080,"wires":[["885bd3b.b0d5db"]]},{"id":"f4b07e74.0961f8","type":"change","z":"22e84c05.fe0b64","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":1120,"wires":[["2daf5775.1522b"]]},{"id":"39e4d513.e96f2a","type":"ha-fire-event","z":"22e84c05.fe0b64","name":"","server":"e0fa7932.da39f8","event":"remote.power","data":"","dataType":"json","x":700,"y":760,"wires":[[]]},{"id":"78b3613a.f6653","type":"ha-fire-event","z":"22e84c05.fe0b64","name":"","server":"e0fa7932.da39f8","event":"remote.av","data":"","dataType":"json","x":770,"y":800,"wires":[[]]},{"id":"a4cd2784.ba4948","type":"ha-fire-event","z":"22e84c05.fe0b64","name":"","server":"e0fa7932.da39f8","event":"remote.menu","data":"","dataType":"json","x":760,"y":840,"wires":[[]]},{"id":"e5459be.17568e8","type":"ha-fire-event","z":"22e84c05.fe0b64","name":"","server":"e0fa7932.da39f8","event":"remote.guide","data":"","dataType":"json","x":800,"y":880,"wires":[[]]},{"id":"9eae0db6.8cbba8","type":"ha-fire-event","z":"22e84c05.fe0b64","name":"","server":"e0fa7932.da39f8","event":"remote.screen","data":"","dataType":"json","x":820,"y":920,"wires":[[]]},{"id":"f1af4691.c078c8","type":"ha-fire-event","z":"22e84c05.fe0b64","name":"","server":"e0fa7932.da39f8","event":"remote.exit","data":"","dataType":"json","x":830,"y":960,"wires":[[]]},{"id":"3a368fe0.0adff8","type":"ha-fire-event","z":"22e84c05.fe0b64","name":"","server":"e0fa7932.da39f8","event":"remote.info","data":"","dataType":"json","x":850,"y":1000,"wires":[[]]},{"id":"11416ff1.a937c","type":"ha-fire-event","z":"22e84c05.fe0b64","name":"","server":"e0fa7932.da39f8","event":"remote.red","data":"","dataType":"json","x":890,"y":1040,"wires":[[]]},{"id":"885bd3b.b0d5db","type":"ha-fire-event","z":"22e84c05.fe0b64","name":"","server":"e0fa7932.da39f8","event":"remote.green","data":"","dataType":"json","x":900,"y":1080,"wires":[[]]},{"id":"2daf5775.1522b","type":"ha-fire-event","z":"22e84c05.fe0b64","name":"","server":"e0fa7932.da39f8","event":"remote.yellow","data":"","dataType":"json","x":920,"y":1120,"wires":[[]]},{"id":"4a3f8b70.bb057c","type":"ha-fire-event","z":"22e84c05.fe0b64","name":"","server":"e0fa7932.da39f8","event":"remote.blue","data":"","dataType":"json","x":830,"y":1200,"wires":[[]]},{"id":"e6d6f01.094a41","type":"change","z":"22e84c05.fe0b64","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":1200,"wires":[["4a3f8b70.bb057c"]]},{"id":"f7a50cd2.b8f42","type":"delay","z":"22e84c05.fe0b64","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"0.2","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":1030,"y":140,"wires":[["ee1463f3.6cb9c8"]]},{"id":"c317413e.545e58","type":"delay","z":"22e84c05.fe0b64","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"0.2","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":690,"y":100,"wires":[["7702a337.3eb31c"]]},{"id":"dc03733a.84f528","type":"delay","z":"22e84c05.fe0b64","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"0.2","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":730,"y":20,"wires":[["30eebac5.47771e"]]},{"id":"b83ea568.ce198","type":"delay","z":"22e84c05.fe0b64","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"0.2","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":620,"y":60,"wires":[["487f56f.e2404a8"]]},{"id":"4fed1091.108a58","type":"delay","z":"22e84c05.fe0b64","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"0.2","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":750,"y":180,"wires":[["109fe954.615c7f"]]},{"id":"e0fa7932.da39f8","type":"server","name":"Home Assistant","addon":true},{"id":"4ef35426.cb7c7c","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
Then, you can react to these events to trigger HA services and thus, control your TV.