# Tasmota InfraRed + Android + Chromecast Binding = Convenient Volume Control

**URL:** <https://community.openhab.org/t/tasmota-infrared-android-chromecast-binding-convenient-volume-control/90120>\
**Category:** Solutions\
**Created:** [January 11, 2020, 3:16pm UTC](https://community.openhab.org/t/tasmota-infrared-android-chromecast-binding-convenient-volume-control/90120 "2020-01-11T15:16:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![max-e-moose](https://community.openhab.org/user_avatar/community.openhab.org/max-e-moose/32/29681_2.png) [@max-e-moose](https://community.openhab.org/u/max-e-moose)\
**Post date:** [January 11, 2020, 3:16pm UTC](https://community.openhab.org/t/tasmota-infrared-android-chromecast-binding-convenient-volume-control/90120/1 "2020-01-11T15:16:50Z")

</div>

When watching videos on Chromecast I regularly see the message “Chromecast is at max volume. Still too quiet? Increase your TV’s volume”. Last night it dawned on me that if I could capture that max volume event, OpenHAB could respond to it and increase the volume of the TV using IR. That way I could just keep pressing the volume up button on my Android phone without needing to open another app. This is my second attempt but here is the solution so far:

Things, technologies and apps used:  
Scenes  
[Tasmotised IR Bridge](https://tasmota.github.io/docs/#/devices/YTF-IR-Bridge)  
[OpenHAB](https://play.google.com/store/apps/details?id=org.openhab.habdroid&hl=en)  
[Tasker](https://play.google.com/store/apps/details?id=net.dinglisch.android.taskerm&hl=en)  
[AutoInput](https://play.google.com/store/apps/details?id=com.joaomgcd.autoinput&hl=en)  
[Chromecast Binding](https://www.openhab.org/addons/bindings/chromecast/)

One of the scenes I have set up is called “Cinema” and it is triggered by [the Chromecast appName channel](https://www.openhab.org/addons/bindings/chromecast/#channels) changing from Backdrop or UNDEF to displaying a specific app (i.e. YouTube, Plex, LocalCast, Netflix, etc). If you want to know how to set up scenes, [check out these great solution options](https://community.openhab.org/t/3-different-methods-to-use-scenes-with-google-home-openhab/42859).

The IR Bridge:

- The Tasmota documentation covers [how to flash the firmware](https://tasmota.github.io/docs/#/devices/YTF-IR-Bridge).
- Add a Thing to your things file that should look something like this:

```auto
Thing topic irbridge "IR Bridge" @ "Postbox" {
    Channels:
        Type string : status "Status" [stateTopic="tele/ir-bridge/LWT"]
        Type string : recievedproto "Received Protocol" [stateTopic="tele/ir-bridge/RESULT", transformationPattern="JSONPATH:$.IrReceived.Protocol"]
        Type string : recievedbits "Received Bits" [stateTopic="tele/ir-bridge/RESULT", transformationPattern="JSONPATH:$.IrReceived.Bits"]
        Type string : recieveddata "Received Data" [stateTopic="tele/ir-bridge/RESULT", transformationPattern="JSONPATH:$.IrReceived.Data"]
        Type string : recievedhash "Received Hash" [stateTopic="tele/ir-bridge/RESULT", transformationPattern="JSONPATH:$.IrReceived.Hash"]
        Type string : senddata "Send" [stateTopic="tele/ir-bridge/RESULT", commandTopic="cmnd/ir-bridge/IRsend"]
        Type number : rssi "WiFi Signal Strength" [stateTopic="tele/ir-bridge/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI"]
}

```

- Then add lines to an items file that look something like these:

```auto
Group IR_Bridge "IR Bridge" <ir_bridge> (LivingRoom, InfraRed)
String IR_Bridge_Status "Status: [%s]" <contactable> (IR_Bridge) { channel="mqtt:topic:bridge:irbridge:status" }
String IR_Bridge_Received_Protocol "Protocol: [%s]" <none> (IR_Bridge) { channel="mqtt:topic:bridge:irbridge:recievedproto" }
String IR_Bridge_Received_Bits "Bits: [%s]" <none> (IR_Bridge) { channel="mqtt:topic:bridge:irbridge:recievedbits" }
String IR_Bridge_Received_Data "Data: [%s]" <none> (IR_Bridge) { channel="mqtt:topic:bridge:irbridge:recieveddata" }
String IR_Bridge_Received_Hash "Hash: [%s]" <none> (IR_Bridge) { channel="mqtt:topic:bridge:irbridge:recievedhash" }
String IR_Bridge_Send_Data "Send: [%s]" <none> (IR_Bridge) { channel="mqtt:topic:bridge:irbridge:senddata" }
Number IR_Bridge_RSSI "WiFi Signal [%d %%]" <wifi> (IR_Bridge) { channel="mqtt:topic:bridge:irbridge:rssi" }

```

The Chromecast setup is very straightforward:

1. Install the Binding
2. Add the Chromecast Thing using the PaperUI \> Inbox
3. Get the channels from PaperUI \> Configuration \> Things \> Chromecast
4. Create an items file with a String item and a Dimmer item in it that subscribe to the Chromecast appName and volume channels. i.e.:

```auto
String ChromecastAppName "App Name [%s]" <text> (ChromecastGroup) {channel="chromecast:chromecast:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:appName"}
Dimmer ChromecastVolume "Volume" <soundvolume> (ChromecastGroup) {channel="chromecast:chromecast:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:volume"}

```

The Android setup:

- Create items to represent the volume buttons on your phone:

- Create a Tasker variable:

- Now set up a Tasker profile. Mine is called “Volume Up Button Pressed”. You’ll also need to have AutoInput installed. There are currently three context triggers:

- Add a task to the profile:

The rule setup:

- Chromecast controlling a Scene:

- Phone button controlling IR Bridge:  
You can look up some known IR codes in [the Tasmota documentation](https://tasmota.github.io/docs/#/Codes-for-IR-Remotes-(for-YTF-IR-Bridge)). The code shown in the rule here is for volume up on an LG TV. There is [more detailed information about how to send and receive IR](https://tasmota.github.io/docs/#/Tasmota-IR?id=sending-ir-commands) too. If you need to send IR codes that use an unknown protocol, [there are ways around that](https://tasmota.github.io/docs/#/IRSend-RAW-Encoding?id=_rawirdecode_-output) but I won’t be expanding on that here.

That’s it. OpenHAB now knows if I am watching something on the Chromecast and if the Chromecast volume reaches the maximum, I can keep mashing the volume button on my phone to increase the TV volume instead. Nifty. 🕶

Anyone got suggestions/improvements?

---

<div class="post-metadata">

**Author:** ![max-e-moose](https://community.openhab.org/user_avatar/community.openhab.org/max-e-moose/32/29681_2.png) [@max-e-moose](https://community.openhab.org/u/max-e-moose)\
**Post date:** [February 18, 2020, 10:31pm UTC](https://community.openhab.org/t/tasmota-infrared-android-chromecast-binding-convenient-volume-control/90120/2 "2020-02-18T22:31:24Z")

</div>

Updated the post to reflect some changes made after living with the first revision. It had some flaws. The new methodology has been far more reliable.
