Control Mediabox Ziggo Next with Domoticz

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
gschmidt
Posts: 200
Joined: Thursday 20 December 2018 11:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Control Mediabox Ziggo Next with Domoticz

Post by gschmidt »

Hi,

I have a Mediabox (Ziggo Next) which I want to control with Domoticz.
On GitHub i have found a Simple webinterface for the Ziggo Next setopbox: https://github.com/basst85/NextRemoteJs
I have installed this on a raspberry pi (other than my domoticz system): 192.168.1.51:8080

It is a Java Script which uses MQTT to communicate with the Ziggo Next:

This is the script: https://pastebin.com/C9hTNU3n

I was wondering if it is possible to create Virtual Devices (Like ON/OFF, Current Status, Channel List/Select Channel, Pause) and use dzVents to send http requests....or maybe to create a sort of an interface?

Greetzzz,

Gerben
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Control Mediabox Ziggo Next with Domoticz

Post by waaren »

gschmidt wrote: Sunday 01 November 2020 11:15 I was wondering if it is possible to create Virtual Devices (Like ON/OFF, Current Status, Channel List/Select Channel, Pause) and use dzVents to send http requests....or maybe to create a sort of an interface?
I don't have a Next Mediabox (still on the old one) so cannot test but if the next Mediabox can be controlled via MQTT or HTTP get, post or put it should be possible.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
gschmidt
Posts: 200
Joined: Thursday 20 December 2018 11:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Control Mediabox Ziggo Next with Domoticz

Post by gschmidt »

waaren wrote: Sunday 01 November 2020 11:35
gschmidt wrote: Sunday 01 November 2020 11:15 I was wondering if it is possible to create Virtual Devices (Like ON/OFF, Current Status, Channel List/Select Channel, Pause) and use dzVents to send http requests....or maybe to create a sort of an interface?
I don't have a Next Mediabox (still on the old one) so cannot test but if the next Mediabox can be controlled via MQTT or HTTP get, post or put it should be possible.
It is a great box ;)
How would you approach this?

This is the HTML page which sends the commands to the java script "index.js":

Code: Select all

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Next remote</title>
	</head>
	<body>
		<h1>Next remote</h1>
		<br/>
		<br/>
		<p id="stbStatus"></p>
		<p id="stbCurrentChannel"></p>
		
		<button id="Power" onCLick="powerKey()">Power</button>
		<button id="Escape" onCLick="escapeKey()">Back/Escape</button>
		<button id="Pause" onCLick="pauseKey()">Pause</button>		
		<br/>
		<br/>
		<b>Click on channelbutton to switch to channel</b>
		<br/>
		<div id="stationsList" />
		
		<script>
			// Get channels
			fetch('/api/stations')
				.then(function(response) {
					return response.json();
				})
				.then(function(stations) {
					for (let s = 0; s < 15; s++) {
						let stationBtn = document.createElement('button');
						stationBtn.setAttribute('style', 'width: 100px; height: 100px; padding: 5px; background: url(' + stations[s].images[3].url + ') no-repeat; background-size: 100%;');
						stationBtn.id = stations[s].serviceId;
						document.getElementById('stationsList').appendChild(stationBtn); 
					}
					
					document.addEventListener('click', function(e) {
						if(e.srcElement.nodeName == 'BUTTON' && e.srcElement.id.includes("_")){
							setChannel(e.srcElement.id);
						}
					});
				});

			function setChannel(channel){
				// Switch channel
				fetch('/api', {
					method: 'POST',
					headers: {'Content-Type': 'application/json; charset=utf-8'},
					body: JSON.stringify({
						action: 'pushChannel',
						channel: channel
					}),
					json: true
				});
			};
			
			function powerKey(){
				// Power on/off
				fetch('/api', {
					method: 'POST',
					headers: {'Content-Type': 'application/json; charset=utf-8'},
					body: JSON.stringify({
						action: 'powerKey'
					}),
					json: true
				});
			};	
			
			function escapeKey(){
				// Escape key
				fetch('/api', {
					method: 'POST',
					headers: {'Content-Type': 'application/json; charset=utf-8'},
					body: JSON.stringify({
						action: 'escapeKey'
					}),
					json: true
				});
			};	

			function pauseKey(){
				// Pause key
				fetch('/api', {
					method: 'POST',
					headers: {'Content-Type': 'application/json; charset=utf-8'},
					body: JSON.stringify({
						action: 'pauseKey'
					}),
					json: true
				});			
			};
			
			function getStatus(){
				fetch('/api/status')
					.then(function(response) {
						return response.json();
					})
					.then(function(status) {
						if(status.setopboxState){
							document.getElementById("stbStatus").innerHTML = 'Setopbox status: ' + status.setopboxState;
							if(status.currentChannel){
								document.getElementById("stbCurrentChannel").innerHTML = 'Current channel: ' + status.currentChannel;
							}
						}
					});
			};
			
			setInterval(function(){ getStatus(); }, 1000);
		</script>
	</body>
</html>	
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Control Mediabox Ziggo Next with Domoticz

Post by waaren »

gschmidt wrote: Sunday 01 November 2020 11:52 How would you approach this?
I would only start with this when I have the box myself or if someone could give me the exact MQTT and/or HTTP commands needed to get the info from the box and send the commands to the box.
On this forum you can find some example scripts which show you how to send HTPP (with openURL) and MQTT commands (using os.execute(mosquitto))
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
gschmidt
Posts: 200
Joined: Thursday 20 December 2018 11:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Control Mediabox Ziggo Next with Domoticz

Post by gschmidt »

waaren wrote: Sunday 01 November 2020 12:02
gschmidt wrote: Sunday 01 November 2020 11:52 How would you approach this?
I would only start with this when I have the box myself or if someone could give me the exact MQTT and/or HTTP commands needed to get the info from the box and send the commands to the box.
On this forum you can find some example scripts which show you how to send HTPP (with openURL) and MQTT commands (using os.execute(mosquitto))
I think the MQTT commands/functions can be found in this js script: https://pastebin.com/C9hTNU3n

E.g. this function would toggle the ON/OFF:

Code: Select all

function powerKey() {
    console.log('Power on/off');
    mqttClient.publish(mqttUsername + '/' + setopboxId, '{"id":"' + makeId(8) + '","type":"CPE.KeyEvent","source":"' + varClientId + '","status":{"w3cKey":"Power","eventType":"keyDownUp"}}')
};
User avatar
FireWizard
Posts: 1886
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Control Mediabox Ziggo Next with Domoticz

Post by FireWizard »

Hello @gschmidt,

1. Please do not X-post.
See your post, almost a year ago: viewtopic.php?t=28352

2. Did you already try the link is that post: https://pypi.org/project/ziggonext/#history?
As I can see, it is under active development.

3. An approach could be that you install Mosquitto on the same device and look what the published topics are with a client, such as MQTT Explorer.
See: https://raspberrypi.tilburgs.com/mosquitto-mqtt/
and: http://mqtt-explorer.com/

From there you can easy find the published topics.
The next step is to decide, whether you want to use @waaren 's proposal to use dZvents or to use a tool like Node Red and to push the desired messages to Domoticz.

Regards
gschmidt
Posts: 200
Joined: Thursday 20 December 2018 11:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Control Mediabox Ziggo Next with Domoticz

Post by gschmidt »

FireWizard wrote: Sunday 01 November 2020 14:49 Hello @gschmidt,

1. Please do not X-post.
See your post, almost a year ago: viewtopic.php?t=28352

2. Did you already try the link is that post: https://pypi.org/project/ziggonext/#history?
As I can see, it is under active development.

3. An approach could be that you install Mosquitto on the same device and look what the published topics are with a client, such as MQTT Explorer.
See: https://raspberrypi.tilburgs.com/mosquitto-mqtt/
and: http://mqtt-explorer.com/

From there you can easy find the published topics.
The next step is to decide, whether you want to use @waaren 's proposal to use dZvents or to use a tool like Node Red and to push the desired messages to Domoticz.

Regards
Hi @FireWizard,

1. I guess you mean with X-post same question? Sorry for that, I wasn’t aware that a solution using a plug-in or creating it with scripts were the same.

2. I thought that was a plug-in for Home Assistant?

3. I have node-red installed on the same device...I have some flows who work this way, only for pushing audio messages to my Google home speakers. But I try to avoid using 2 programs for a method. My programming skills are still in learning phase, so that is why I ask for some help and advice.
User avatar
FireWizard
Posts: 1886
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Control Mediabox Ziggo Next with Domoticz

Post by FireWizard »

Hello @gschmidt

You wrote:
I thought that was a plug-in for Home Assistant?
As I do not own a Ziggo Next box. I'm not able to verify. So it could be that this script is only for Hone Assistant,
However some Python script, intended for HA, might also be useful and applicable for Domoticz.

I see many script, prove of concepts and also a Homebridge plugin for Node Red. These seems to use all the MQTT protiocol.

Did you already try to use MQTT-explorer and try to connect to the box?
If you are able to communicate with the box, like all other clients, it should be possible to communicate with Domoticz.

Whether you want to use Node Red or a dzVents script, it is up to you.

Regards
Sholofly
Posts: 2
Joined: Sunday 12 January 2020 20:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Control Mediabox Ziggo Next with Domoticz

Post by Sholofly »

Hi there,

I am the developer of the python package and the home assistant plugin. My code is open source and available on:

https://github.com/Sholofly/ziggonext-python
https://github.com/Sholofly/ziggonext

You can use the python package in Domoticz! Please note that i am not a python developer so there is room voor improvements (error handling i.e.).

Feel free to contact me for questions or add some functionality if you like..

greets,

Rudolf
User avatar
jjnh
Posts: 33
Joined: Sunday 09 December 2018 14:06
Target OS: Linux
Domoticz version: 2023.1
Location: Netherlands
Contact:

Re: Control Mediabox Ziggo Next with Domoticz

Post by jjnh »

Hi,

Did anyone make any headway with integrating this plugin into Domoticz?
Odroid N2+ 4GB, with an RfxTrx433E, Zigbee with Slaesh's CC2652RB, Z-Wave, BroadLink IR using RM mini 3 and P1 connected.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest