Hi Guys,
is it possible to switch the Channel with the Panasonic Viera Component?
I’m not getting into, how this will work.
My Viera is already visible and i can turn it off and on throw the Mediaplayer switch.
Thanks
BR
Lukas
Hi Guys,
is it possible to switch the Channel with the Panasonic Viera Component?
I’m not getting into, how this will work.
My Viera is already visible and i can turn it off and on throw the Mediaplayer switch.
Thanks
BR
Lukas
Does anyone have an Idea?
I can see already:
But there’s no way to change the Input or the Channel:
He Guys,
i dig into my Problem.
On my Home Assistant Installation (Install with AIO-Installer) i’ve found in the .homeassistant/deps/pansonic_viera a Python-Script where many Keys are defined.
Here The Script:
“”"
Command line tool to remote control your Panasonic Viera TV.
“”"
import argparse
import code
import shlex
import sys
import socket
import logging
from sys import stderr
import panasonic_viera
class CommandRunner(object):
“Runs defined commands.”
def init(self):
self.commands = {}
self.command(‘help’, self.help)
def help(self): print('Commands:') for c in self.commands: print('{}'.format(c)) print('')
def command(self, name, fn): self.commands[name] = fn
def run(self, line): tokens = shlex.split(line, comments=True) command, args = tokens[0], tokens[1:] if command not in self.commands: print('{}: no such command'.format(command), file=stderr) return result = self.commands[command](*args) if result is not None: print(result)
class Console(object):
ps1 = '> ’
ps2 = '. ’
def __init__(self, runner): self.runner = runner
def run(self, fd): for line in fd: self.runner.run(line)
def interact(self, locals=None): class LambdaConsole(code.InteractiveConsole): def runsource(code_console, source, filename=None, symbol=None): try: self.runner.run(source) except SystemExit: raise except: code_console.showtraceback() return False
try: import readline; readline except ImportError: pass
ps1, ps2 = getattr(sys, 'ps1', None), getattr(sys, 'ps2', None) try: sys.ps1, sys.ps2 = self.ps1, self.ps2 LambdaConsole(locals=locals, filename="<demo>").interact(banner='') finally: sys.ps1, sys.ps2 = ps1, ps2
def run(self, fd=None): if fd is None: fd = sys.stdin if fd.isatty(): self.interact() else: try: self.run(fd=fd) except Exception as err: print(err, file=stderr) return 1 return 0
class RemoteControl(object):
“”“A remote control implementation”“”
def __init__(self, remote_control): self._remote_control = remote_control
def get_volume(self): try: vol = self._remote_control.get_volume() print('Volume is currently set to {}'.format(vol)) except (socket.timeout, TimeoutError, OSError): print('TV is switched off.')
def set_volume(self, vol): try: self._remote_control.set_volume(vol) print('Successfully set volume to {}'.format(vol)) except (socket.timeout, TimeoutError, OSError): print('TV is switched off.')
def get_mute(self): try: mute = self._remote_control.get_mute() if mute: print('TV is muted.') else: print('TV is not muted.') except (socket.timeout, TimeoutError, OSError): print('TV is switched off.')
def set_mute(self, mute): try: mute = bool(mute) self._remote_control.set_mute(mute) print('Successfully set mute to {}'.format(mute)) except (socket.timeout, TimeoutError, OSError): print('TV is switched off.')
def turn_off(self): try: self._remote_control.turn_off() print('Successfully turned TV off.') except (socket.timeout, TimeoutError, OSError): print('TV is switched off.')
def volume_up(self): try: self._remote_control.volume_up() print('Successfully turned volume up.') except (socket.timeout, TimeoutError, OSError): print('TV is switched off.')
def volume_down(self): try: self._remote_control.volume_down() print('Successfully turned volume down.') except (socket.timeout, TimeoutError, OSError): print('TV is switched off.')
def mute_volume(self): try: self._remote_control.mute_volume() print('Successfully muted volume.') except (socket.timeout, TimeoutError, OSError): print('TV is switched off.')
def send_key(self, key): try: key = str(key) self._remote_control.send_key(key) print('Successfully sent key {}.'.format(key)) except (socket.timeout, TimeoutError, OSError): print('TV is switched off.')
def main():
“”" Handle command line execution. “”"
parser = argparse.ArgumentParser(prog=‘panasonic_viera’,
description=‘Remote control a Panasonic Viera TV.’)
parser.add_argument(‘host’, metavar=‘host’, type=str,
help=‘Address of the Panasonic Viera TV’)
parser.add_argument(‘port’, metavar=‘port’, type=int, nargs=‘?’,
default=panasonic_viera.DEFAULT_PORT,
help=‘Port of the Panasonic Viera TV. Defaults to {}.’.format(panasonic_viera.DEFAULT_PORT))
parser.add_argument(‘–verbose’, dest=‘verbose’, action=‘store_const’,
const=True, default=False,
help=‘debug output’)
args = parser.parse_args()
if args.verbose: logging.basicConfig(level=logging.DEBUG)
remote_control = RemoteControl(panasonic_viera.RemoteControl(args.host, args.port)) runner = CommandRunner() runner.command('get_volume', remote_control.get_volume) runner.command('set_volume', remote_control.set_volume) runner.command('get_mute', remote_control.get_mute) runner.command('set_mute', remote_control.set_mute) runner.command('turn_off', remote_control.turn_off) runner.command('volume_up', remote_control.volume_up) runner.command('volume_down', remote_control.volume_down) runner.command('mute_volume', remote_control.mute_volume) runner.command('send_key', remote_control.send_key) return Console(runner).run()
if name == ‘main’:
sys.exit(main())
How can i use the Keys defined in the python script?
I’m running into the same issue. I can turn my Panasonic TV on and off, but no idea how to switch channels
I created the following action within an automation (to switch to my HDMI1 channel), but not sure if I use the wrong source naming or if it’s something else.
Anyone able to help me?
action:
- alias: ''
data:
entity_id: media_player.goodietv_panasonic
source: HDMI1
service: media_player.select_source
Hi @goodie80,
With Home-Assistant is it not possible. I did solve it with Nodered combined with Home-Assistant.
You can find Nodered-Nodes for Viera here:
I use MQTT for talking between Nodered and Homeassistant. For Channel up and Channel down i use a simple Script in Homeassistant:
tv_channel_down:
alias: Sender -
sequence:
- data:
payload: CH_DOWN
topic: tvcontrol
service: mqtt.publish
as you can see, you can use all possible commands from the Vieranode with MQTT.
For switch HDMI the payload is CHG_INPUT
You can find all possible Command in the Vieranode help.
The Flow in Nodered is very simple:
Here is my flow exported:
[{“id”:“9a8e7187.a3ca”,“type”:“tab”,“label”:“ControlTV”,“disabled”:false,“info”:“Controls Viera TV from HomeAssistant via MQTT”},{“id”:“16574178.1d025f”,“type”:“viera write”,“z”:“9a8e7187.a3ca”,“name”:“sendCommand”,“host”:“192.168.0.86”,“function”:“sendCommand”,“x”:570,“y”:104,“wires”:},{“id”:“f3133c0d.6ce2”,“type”:“mqtt in”,“z”:“9a8e7187.a3ca”,“name”:“”,“topic”:“tvcontrol”,“qos”:“2”,“broker”:“49a636a8.7a9ef8”,“x”:173.5,“y”:102,“wires”:[[“16574178.1d025f”]]},{“id”:“49a636a8.7a9ef8”,“type”:“mqtt-broker”,“z”:“”,“name”:“”,“broker”:“192.168.0.58”,“port”:“1883”,“clientid”:“nodered”,“usetls”:false,“compatmode”:true,“keepalive”:“60”,“cleansession”:true,“birthTopic”:“”,“birthQos”:“0”,“birthPayload”:“”,“willTopic”:“”,“willQos”:“0”,“willPayload”:“”}]
It took me some time to get Nodered up and running, but it works now!
The CHG_INPUT cycles through the HDMI input menu. But what should I do if I want to set it to a specific AV channel (like HDMI2).
I see nothing in the help regarding setting a specific channel.
Edit - Nevermind I found how to install it under palette…
I’m ready to jump into node red, just for control of Viera, but first a newbie question. I loaded the node-red add-on into hassio, but don’t see the ability to install using a command line:
npm install node-red-contrib-viera
Is it not possible with the node-red add on?
Yours cycles? When I send CHG_INPUT, my input select menu comes up on the screen. I then follow up with D1-D6 depending upon which input I want. For example:
- data:
payload: D3
topic: tvcontrol
service: mqtt.publish
At my setup the D3 controls the directional pad of the remote. So if my TV is on HDMI2 and it does CHG_INPUT, followed by D3, it moves to HDMI3. If it does it while the TV is on HDMI3, it will move to HDMI4.
I want the TV to power on, set to HDMI2 when I drop the topic tvcontrol/playstation4/on
When I use the Panasonic remote, I can press 3 on the numeric pad to choose HDMI2 when the input select menu is on the screen. Therefore to simulate that, you send a payload of D3 according to the node red viera component. While in node red, the info screen for the viera component lists the following as “numeric buttons”
D1 D2 D3 D4 D5 D6 D7 D8 D9 D0
I’m confused on why D3 would be the directional pad for you. D3 chooses HDMI2 for me every time, regardless of which choice is selected prior to sending the payload. This is working flawlessly for me to switch between Directv and Fire Tv inputs on my Viera Tv.
Sorry to do a necro bump, but could really do with some help here.
Followed some of the above, got Node-Red and Mosquitto installed and setup the basic send command script, that’s where the good part ends.
Even just trying to use the example tv_channel_down script above doesn’t work and comes up with this error:
Message malformed: extra keys not allowed @ data[‘sequence’][0][‘tv_channel_down’]
Any help for appreciated!
Sorry for digging up an old thread, but I’m trying to do something similar with the Panasonic Viera integrations.
I see that the remote has been added and I can use a service to call the remote.sendcommand for the Panasonic TV, but I can’t see a simple way to change the source. Thus far I can send remote.input_key followed by remote.up or remote.down and then press remote.enter, but this is relative to what input is on when the remote.input_key is called. I will try it with a number input to see if that works.
With all that said, my main query though is how to add sources to the Panasonic TV. I can’t see how to do this? On other video’s such as LG WebOS, I’ve seen them listed in the yaml and an attribute of sources added, would this work if I add the Panasonic TV’s through the YAML file rather than the integration? Do I need to remove the devices from the integration that I did in the UI for this to work and not duplicate?